private void UpdateBtn_Click(object sender, EventArgs e) { int x;
WorldDA.UpdateCommand = new SqlCommand("UPDATE RaceTbl SET RaceName=@RaceName, Adulthood=@Adulthood, MiddleAge=@MiddleAge, OldAge=@OldAge, MaxAge=@MaxAge, Vision=@Vision WHERE ID=@ID", WorldConn); WorldDA.UpdateCommand.Parameters.Add("@ID", SqlDbType.Int).Value = RaceDGView.CurrentRow.Cells["ID"].Value; WorldDA.UpdateCommand.Parameters.Add("@RaceName", SqlDbType.NChar).Value = raceNameTxt.Text; WorldDA.UpdateCommand.Parameters.Add("@Adulthood", SqlDbType.NChar).Value = AdulthoodTxt.Text; WorldDA.UpdateCommand.Parameters.Add("@MiddleAge", SqlDbType.NChar).Value = MiddleAgeTxt.Text; WorldDA.UpdateCommand.Parameters.Add("@OldAge", SqlDbType.NChar).Value = OldAgeTxt.Text; WorldDA.UpdateCommand.Parameters.Add("@MaxAge", SqlDbType.NChar).Value = MaxAgeTxt.Text; WorldDA.UpdateCommand.Parameters.Add("@Vision", SqlDbType.NChar).Value = VisionCBox.Text; WorldConn.Open(); x = WorldDA.UpdateCommand.ExecuteNonQuery(); WorldConn.Close(); if (x >= 1) MessageBox.Show("recored updated"); dgRefresh(); } private void dgRefresh() { RaceDGView.ClearSelection(); RaceDGView.Rows[RaceBS.Position].Selected = true; } private void MoveNextBtn_Click(object sender, EventArgs e) { RaceBS.MoveNext(); dgRefresh(); } private void MovePreviousBtn_Click(object sender, EventArgs e) { RaceBS.MovePrevious(); dgRefresh(); }
|