/// <summary> /// Save or edit function, its for checking the invalid entries /// </summary> public void SaveOrEditFunction() { try { txtVoucherDate.Text = txtVoucherDate.Text.Trim(); cmbAccountLedger.Text = cmbAccountLedger.Text.Trim(); txtAmount.Text = txtAmount.Text.Trim(); cmbBank.Text = cmbBank.Text.Trim(); txtChequeDate.Text = txtChequeDate.Text.Trim(); txtcheckNo.Text = txtcheckNo.Text.Trim(); txtNarration.Text = txtNarration.Text.Trim(); bool isOk = true; bool isAmountOk = false; try { if (decimal.Parse(txtAmount.Text) > 0) isAmountOk = true; } catch { txtAmount.Text = string.Empty; } if (isOk) { if (txtvoucherNo.Text == string.Empty) { Messages.InformationMessage("Enter voucher no"); txtvoucherNo.Focus(); } else if (txtVoucherDate.Text == string.Empty) { Messages.InformationMessage("Select date"); txtVoucherDate.Focus(); } else if (cmbAccountLedger.SelectedValue == null) { Messages.InformationMessage("Select account ledger"); cmbAccountLedger.Focus(); } else if (!isAmountOk) { Messages.InformationMessage("Select amount"); txtAmount.Focus(); } else if (cmbBank.SelectedValue == null) { Messages.InformationMessage("Select bank "); cmbBank.Focus(); } else if (txtcheckNo.Text == string.Empty) { Messages.InformationMessage("Enter cheque no"); txtcheckNo.Focus(); } else if (txtChequeDate.Text == string.Empty) { Messages.InformationMessage("Select cheque date"); txtChequeDate.Focus(); } else { if (PublicVariables.isMessageAdd) { isOk = false; PDCPayableMasterSP SpPDCpayable = new PDCPayableMasterSP(); if (!isInEditMode) { if (Messages.SaveMessage()) if (!SpPDCpayable.PDCpayableCheckExistence(txtvoucherNo.Text.Trim(), decPDCpayableVoucherTypeId, 0)) { SaveFunction(); } else { Messages.InformationMessage("Voucher number already exist"); } } else { if (Messages.UpdateMessage()) if (isInEditMode && SpPDCpayable.PDCPayableVoucherCheckRreference(decPDCpayableEditId, decPDCpayableVoucherTypeId)) { MessageBox.Show("Can't update,reference exist", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { SaveFunction(); } if (BillallocationObj != null) { this.Close(); BillallocationObj.Enabled = true; BillallocationObj.BillAllocationGridFill(); } } } if (isOk) { if (CheckUserPrivilege.PrivilegeCheck(PublicVariables._decCurrentUserId, this.Name, btnSave.Text)) { PDCPayableMasterSP SpPDCpayable = new PDCPayableMasterSP(); if (isInEditMode && SpPDCpayable.PDCPayableVoucherCheckRreference(decPDCpayableEditId, decPDCpayableVoucherTypeId)) { MessageBox.Show("Can't update,reference exist", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { SaveFunction(); } } else { Messages.NoPrivillageMessage(); } } } } } catch (Exception ex) { MessageBox.Show("PP12:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }