public void UpdateRecord(Objects.BankDeposits obj) { try { SqlCommand cmd = new SqlCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "SP_BankDepositsUpdate"; cmd.Parameters.AddWithValue("@DepositID", obj.DepositID); cmd.Parameters.AddWithValue("@DepositDate", obj.DepositDate); cmd.Parameters.AddWithValue("@IsCheque", obj.IsCheque); cmd.Parameters.AddWithValue("@ChequeNo", obj.ChequeNo); cmd.Parameters.AddWithValue("@ChequeDate", obj.ChequeDate); cmd.Parameters.AddWithValue("@SlipNo", obj.SlipNo); cmd.Parameters.AddWithValue("@BankAccountNo", obj.BankAccountNo); cmd.Parameters.AddWithValue("@AccountNo", obj.AccountNo); cmd.Parameters.AddWithValue("@Amount", obj.Amount); cmd.Parameters.AddWithValue("@DepositedBy", obj.DepositedBy); cmd.Parameters.AddWithValue("@Narration", obj.Narration); cmd.Parameters.AddWithValue("@UserID", obj.UserID); cmd.Parameters.AddWithValue("@EntryDate", obj.EntryDate); cmd.Parameters.AddWithValue("@IsPosted", obj.IsPosted); new Database(connectionstring).ExecuteNonQueryOnly(cmd); } catch (Exception exc) { throw exc; } }
private void btnSave_Click(object sender, EventArgs e) { try { string vMessage = string.Empty; if (txtSlipNo.Text.Trim() == string.Empty) { vMessage = "Please Enter Bank Deposit Slip Number."; new Speak().SayIt(vMessage); MessageBox.Show(vMessage, "Information Missing"); txtSlipNo.Focus(); return; } if (txtCheqNo.Text.Trim() == string.Empty) { vMessage = "Please Enter Cheque Number."; new Speak().SayIt(vMessage); MessageBox.Show(vMessage, "Information Missing"); txtCheqNo.Focus(); return; } if (txtAccountName.Text.Trim() == string.Empty) { vMessage = "Please Select From Account."; new Speak().SayIt(vMessage); MessageBox.Show(vMessage, "Information Missing"); txtAccountNo.Focus(); return; } if (txtBankAccName.Text.Trim() == string.Empty) { vMessage = "Please Select Bank Account."; new Speak().SayIt(vMessage); MessageBox.Show(vMessage, "Information Missing"); txtBankAccNo.Focus(); return; } Int64 vAmount; Int64.TryParse(txtAmount.Text, out vAmount); if (vAmount == 0) { vMessage = "Deposited Amount not entered."; new Speak().SayIt(vMessage); MessageBox.Show(vMessage, "Information Missing"); txtAmount.Focus(); return; } Objects.BankDeposits obj = new Objects.BankDeposits(); obj.DepositID = Int64.Parse(txtID.Text); obj.DepositDate = dtDepositDate.Value; obj.SlipNo = txtSlipNo.Text.Trim(); obj.AccountNo = txtAccountNo.Text; obj.BankAccountNo = txtBankAccNo.Text; obj.Amount = vAmount; obj.DepositedBy = txtDepositby.Text; obj.Narration = txtNarration.Text; DAL.Settings obSet = new DAL.Settings(); obSet.connectionstring = objDAL.connectionstring; obj.IsPosted = Convert.ToBoolean(obSet.GetSettingValue(DAL.Settings.ProSettings.IsAutoPost)); obj.UserID = vUserID; obj.EntryDate = DateTime.Now.Date; obj.ChequeDate = dtCheqDate.Value; obj.ChequeNo = txtCheqNo.Text; obj.IsCheque = true; if (!vOpenMode) { //Insert Activity obj.DepositID = Int64.Parse(objDAL.getNextNo().ToString()); objDAL.InsertRecord(obj); } else { objDAL.UpdateRecord(obj); } vMessage = "Record Saved Successfully."; new Speak().SayIt(vMessage); MessageBox.Show(vMessage, "Confirmation"); PrintVoucher(obj.DepositID); btnClear_Click(sender, e); } catch (Exception exc) { MessageBox.Show(exc.Message.ToString(), "Error"); } }