public void UpdateRecord(Objects.Offices obj) { try { SqlCommand cmd = new SqlCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "SP_OfficesUpdate"; cmd.Parameters.AddWithValue("@OfficeID", obj.OfficeID); cmd.Parameters.AddWithValue("@Description", obj.Description); new Database(connectionstring).ExecuteNonQueryOnly(cmd); } catch (Exception exc) { throw exc; } }
private void CmdSave_Click_1(object sender, EventArgs e) { try { if (TxtName.Text.Trim() == string.Empty) { MessageBox.Show("Please Enter Office Name", "Office Name"); TxtName.Focus(); return; } Objects.Offices obj = new Objects.Offices(); obj.Description = TxtName.Text.Trim(); if (!vOpenMode) { obj.OfficeID = Int32.Parse(objDAL.getNextNo().ToString()); objDAL.InsertRecord(obj); } else { // UPdate obj.OfficeID = Int16.Parse(TxtName.Tag.ToString()); objDAL.UpdateRecord(obj); } MessageBox.Show("Record Saved Succesfully", "Save"); CmdClear_Click(sender, e); LoadGrid(); } catch (Exception exc) { MessageBox.Show(exc.Message); } }