public void UpdateRecord(Objects.PartyGroups obj) { try { SqlCommand cmd = new SqlCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "SP_PartyGroupsUpdate"; cmd.Parameters.AddWithValue("@GroupID", obj.GroupID); cmd.Parameters.AddWithValue("@GroupName", obj.GroupName); new Database(connectionstring).ExecuteNonQueryOnly(cmd); } catch (Exception exc) { throw exc; } }
private void CmdSave_Click(object sender, EventArgs e) { try { if (TxtName.Text.Trim() == string.Empty) { MessageBox.Show("Please Enter Party Name", " Party Name"); TxtName.Focus(); return; } Objects.PartyGroups obj = new Objects.PartyGroups(); obj.GroupName = TxtName.Text.Trim(); if (!vOpenMode) { obj.GroupID = Int32.Parse(objDAL.getNextNo().ToString()); objDAL.InsertRecord(obj); } else { // UPdate obj.GroupID = 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); } }