private void btnSave_Click(object sender, EventArgs e) { if (MessageBox.Show("Do you want to save current record ? ", "Confirmation ", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { int VoucherStatus = MyPay.GetPVNStatus(txtPVNno.Text); switch (VoucherStatus) { case 2: Program.InformationMessage("This is aproval payment voucher, cannot chage"); break; case 3: Program.InformationMessage("Already Accounted, cannot chage"); break; default: if (!MyPay.ExistPayment_General(txtPVNno.Text)) { AccountTypes.Payment_GeneralDataType _SaveHeader = new AccountTypes.Payment_GeneralDataType(); string respond = ""; string PVN = ""; string SelItem = MyCommon.GetSelectedID(cmbPayFor, true); if (SelItem == "5") { MyAccount.SaveotherPayee(cmbPayTo.Text, lblAddress.Text); } respond = SetHeaderDatatoClass(out _SaveHeader); if (respond == "True") { respond = MyPay.SavePayment_General(_SaveHeader, out PVN); if (respond == "True") { txtPVNno.Text = PVN; LoadExtPaymentList(); MessageBox.Show("Data Saved Successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { txtPVNno.Text = ""; Program.VerningMessage(respond); } } } else { Program.VerningMessage("Use Update Button"); } break; } } }
private string SetHeaderDatatoClass(out AccountTypes.Payment_GeneralDataType _SaveHeader) { _SaveHeader = new AccountTypes.Payment_GeneralDataType(); try { _SaveHeader.AccountID = MyCommon.GetSelectedID(cmbFromAcc, true); _SaveHeader.ChequeNumber = cmbMethodObg.Text; _SaveHeader.Cr = decimal.Parse(txtToalAmountLKR.Text); _SaveHeader.CurRate = decimal.Parse(txtExRate.Text); _SaveHeader.Description = txtfromMemo.Text; _SaveHeader.FCr = decimal.Parse(txtToalAmountFCR.Text); _SaveHeader.PaymentID = txtPVNno.Text; _SaveHeader.PaymentMethod = int.Parse(MyCommon.GetSelectedID(cmbPayMethod, true)); _SaveHeader.PayStatus = 0; _SaveHeader.TrUser = Program.AccountStatic.UserName; _SaveHeader.CompanyID = Program.AccountStatic.CompanyID; _SaveHeader.AccPeriod = Program.AccountStatic.CurrentAccPeriod; _SaveHeader.PayToCatID = int.Parse(MyCommon.GetSelectedID(cmbPayFor, true)); _SaveHeader.PayToName = cmbPayTo.Text; _SaveHeader.PayActualDate = dtpPVNDate.Value; if (chkAsAdvancePayment.Checked) { _SaveHeader.IsAdvancePayment = 1; } else { _SaveHeader.IsAdvancePayment = 0; } List <AccountTypes.Payment_GeneralDetailsDataType> _SaveDetailList; string respond = SetDetailDataToClass(out _SaveDetailList); _SaveHeader.Details = _SaveDetailList; return("True"); } catch (Exception ex) { return(ex.Message); } }