private void simpleButtonOK_Click(object sender, System.EventArgs e) { decimal paymentAmt = 0; if (lkpEdtPayment.EditValue.ToString() == "") { MessageBox.Show(this, "Please select the payment mode."); this.DialogResult = DialogResult.None; return; } else if (txtEdtPaymentAmt.Text.Length == 0) { MessageBox.Show(this, "Please enter payment amount."); this.DialogResult = DialogResult.None; return; } else if (lkpEdtPaymentGroup.EditValue.ToString() == ACMSPOS2.PaymentGroupCode.IPP && lkpEdtIPP.EditValue.ToString().Trim() == "") { MessageBox.Show(this, "Please select an IPP ID."); this.DialogResult = DialogResult.None; return; } else if (lkpEdtPaymentGroup.EditValue.ToString() == ACMSPOS2.PaymentGroupCode.IPP && txtEdtRefNo.Text.Trim() == "") { MessageBox.Show(this, "Please Enter Reference No."); this.DialogResult = DialogResult.None; return; } else if ((lkpEdtPaymentGroup.EditValue.ToString() == ACMSPOS2.PaymentGroupCode.CHEQUE || lkpEdtPaymentGroup.EditValue.ToString() == ACMSPOS2.PaymentGroupCode.VOUCHER) && txtEdtRefNo.Text == "") { MessageBox.Show(this, "Please enter reference code."); this.DialogResult = DialogResult.None; return; } else if ((lkpEdtPaymentGroup.EditValue.ToString() == ACMSPOS2.PaymentGroupCode.VOUCHER) && txtEdtRefNo.Text == "" && lkpEdtPayment.Text == "CASHVOUCHER") { MessageBox.Show(this, "Please enter reference code."); this.DialogResult = DialogResult.None; return; } else if (txtEdtPaymentAmt.Text.Length > 0) { ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider(); TblCashVoucher sqlCV = new TblCashVoucher(); sqlCV.MainConnectionProvider = connProvider; try { if (lkpEdtPayment.Text == "CASHVOUCHER") { string strCVCode = txtEdtRefNo.Text.Trim(); sqlCV.StrSN = strCVCode; DataTable table = sqlCV.SelectOne(); if (table.Rows.Count > 0) { if (Array.IndexOf(sqlCV.StrCategoryIDs.ToString().Split(','), myPOS.NCategoryID.ToString()) < 0) { MessageBox.Show(this, "Cannot redeem this voucher because it belongs to different category!"); this.DialogResult = DialogResult.None; return; } if (sqlCV.StrSoldToID.IsNull) { MessageBox.Show(this, "Cannot redeem this voucher because it haven't sold out!"); this.DialogResult = DialogResult.None; return; } if (!sqlCV.StrRedeemedByID.IsNull) { MessageBox.Show(this, "Cannot redeem this voucher because it already redeemed!"); this.DialogResult = DialogResult.None; return; } if (sqlCV.StrDurationUnit.ToString() == "MONTH" && Convert.ToDateTime(sqlCV.DtSoldDate.ToString()).AddMonths(Convert.ToInt32(sqlCV.NValidDuration.ToString())) < DateTime.Now) { MessageBox.Show(this, "Cannot redeem this voucher because it already expired! Expired Date: " + Convert.ToDateTime(sqlCV.DtSoldDate.ToString()).AddMonths(Convert.ToInt32(sqlCV.NValidDuration.ToString())).ToShortDateString()); this.DialogResult = DialogResult.None; return; } if (sqlCV.StrDurationUnit.ToString() == "WEEK" && Convert.ToDateTime(sqlCV.DtSoldDate.ToString()).AddDays(Convert.ToInt32(sqlCV.NValidDuration.ToString()) * 7) < DateTime.Now) { MessageBox.Show(this, "Cannot redeem this voucher because it already expired! Expired Date: " + Convert.ToDateTime(sqlCV.DtSoldDate.ToString()).AddDays(Convert.ToInt32(sqlCV.NValidDuration.ToString()) * 7).ToShortDateString()); this.DialogResult = DialogResult.None; return; } if (sqlCV.StrDurationUnit.ToString() == "DAY" && Convert.ToDateTime(sqlCV.DtSoldDate.ToString()).AddDays(Convert.ToInt32(sqlCV.NValidDuration.ToString())) < DateTime.Now) { MessageBox.Show(this, "Cannot redeem this voucher because it already expired! Expired Date: " + Convert.ToDateTime(sqlCV.DtSoldDate.ToString()).AddDays(Convert.ToInt32(sqlCV.NValidDuration.ToString())).ToShortDateString()); this.DialogResult = DialogResult.None; return; } txtEdtPaymentAmt.EditValue = ACMS.Convert.ToDecimal(table.Rows[0]["mValue"]); paymentAmt = ACMS.Convert.ToDecimal(table.Rows[0]["mValue"]); } else { MessageBox.Show(this, "Invalid Serial No! Please enter again!"); this.DialogResult = DialogResult.None; return; } } else { decimal paymentAmt_temp; decimal remainder; if (txtEdtPaymentAmt.EditValue.ToString() == "") { paymentAmt = ACMS.Convert.ToDecimal(0); } else { if (lkpEdtPayment.Text == "CASH") { paymentAmt_temp = ACMS.Convert.ToDecimal(txtEdtPaymentAmt.EditValue); remainder = paymentAmt_temp % ACMS.Convert.ToDecimal(0.05); //myPOS.MTotalAmount = myPOS.MTotalAmount - remainder; //txtEdtPaymentAmt.EditValue = myPOS.MTotalAmount.ToString(); txtEdtPaymentAmt.EditValue = (paymentAmt_temp - remainder).ToString(); } paymentAmt = ACMS.Convert.ToDecimal(txtEdtPaymentAmt.EditValue); } /* * if (txtEdtPaymentAmt.EditValue == "") * paymentAmt = ACMS.Convert.ToDecimal(0); * else * paymentAmt = ACMS.Convert.ToDecimal(txtEdtPaymentAmt.EditValue);*/ } } catch (Exception) { MessageBox.Show(this, "Invalid payment amount."); this.DialogResult = DialogResult.None; return; } finally { if (connProvider.CurrentTransaction != null) { connProvider.CurrentTransaction.Dispose(); } if (connProvider.DBConnection != null) { if (connProvider.DBConnection.State == ConnectionState.Open) { connProvider.DBConnection.Close(); } } sqlCV.MainConnactionIsCreatedLocal = true; } } int ipp = 0; if (lkpEdtIPP.EditValue.ToString().Length > 0) { ipp = ACMS.Convert.ToInt32(lkpEdtIPP.EditValue); } myPOS.NewReceiptPayment(lkpEdtPayment.EditValue.ToString(), paymentAmt, ipp, txtEdtRefNo.Text); }
private void simpleButtonOK_Click(object sender, System.EventArgs e) { decimal paymentAmt = 0; if (lkpEdtPayment.EditValue.ToString() == "") { MessageBox.Show(this, "Please select the payment mode."); this.DialogResult = DialogResult.None; return; } else if (txtEdtPaymentAmt.Text.Length == 0) { MessageBox.Show(this, "Please enter payment amount."); this.DialogResult = DialogResult.None; return; } else if (lkpEdtPaymentGroup.EditValue.ToString() == ACMSPOS2.PaymentGroupCode.IPP && lkpEdtIPP.EditValue.ToString().Trim() == "") { MessageBox.Show(this, "Please select an IPP ID."); this.DialogResult = DialogResult.None; return; } else if (lkpEdtPaymentGroup.EditValue.ToString() == ACMSPOS2.PaymentGroupCode.IPP && txtEdtRefNo.Text.Trim() == "") { MessageBox.Show(this, "Please Enter Reference No."); this.DialogResult = DialogResult.None; return; } else if ((lkpEdtPaymentGroup.EditValue.ToString() == ACMSPOS2.PaymentGroupCode.CHEQUE || lkpEdtPaymentGroup.EditValue.ToString() == ACMSPOS2.PaymentGroupCode.VOUCHER) && txtEdtRefNo.Text == "") { MessageBox.Show(this, "Please enter reference code."); this.DialogResult = DialogResult.None; return; } else if (txtEdtPaymentAmt.Text.Length > 0) { try { paymentAmt = ACMS.Convert.ToDecimal(txtEdtPaymentAmt.EditValue); } catch (Exception) { MessageBox.Show(this, "Invalid payment amount."); this.DialogResult = DialogResult.None; return; } } int ipp = 0; if (lkpEdtIPP.EditValue.ToString().Length > 0) { ipp = ACMS.Convert.ToInt32(lkpEdtIPP.EditValue); } myPOS.NewReceiptPayment(lkpEdtPayment.EditValue.ToString(), paymentAmt, ipp, txtEdtRefNo.Text); }