private void btnAccount_Click(object sender, EventArgs e) { try { if (txtTender.Text != string.Empty&& Convert.ToDouble(txtTender.Text)>0) { frmPaymentAcc frm = new frmPaymentAcc(); if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK) { AccountModel accItem = new AccountModel(); accItem.PaymentID = 4; accItem.Total = Convert.ToDouble(txtTender.Text); UCAccPayment acc = new UCAccPayment(); acc.lblStt.Text = "#" + CountUcPayMent().ToString(); acc.lblMethodType.Text = btnAccount.Text; acc.lblTotal.Text = "$" + money.Format2((Convert.ToDouble(txtTender.Text)) * 1000); acc.Tag = accItem; acc.Click += acc_Click; OrderMain.CusItem = frm.itemS; OrderMain.Account = Convert.ToInt32(Convert.ToDouble(txtTender.Text) * 1000); addPayment(accItem); flpPaymentType.Controls.Add(acc); } } } catch (Exception ex) { LogPOS.WriteLog("frmPayment::::::::::::::::::::btnAccount_Click:::::::::::::::::" + ex.Message); } }
private int CheckPaymentSplitBill(AccountModel item) { int index = -1; try { if (lstPaymentSplitBill.Count > 0) { for (int i = 0; i < lstPaymentSplitBill.Count; i++) { if (lstPaymentSplitBill[i].PaymentTypeID == item.PaymentID) { index = i; } } } } catch (Exception ex) { LogPOS.WriteLog("frmPayMent::::::::CheckPayment::::::::::::::::::::CashModel::::::::::::::::" + ex.Message); } return index; }
private void addPayment(AccountModel item) { try { int result = CheckPayment(item); int resulSplit = CheckPaymentSplitBill(item); if (result != -1) { lstPayment[result].Total = lstPayment[result].Total + item.Total; } else { PayMentModel pay = new PayMentModel(); pay.PaymentTypeID = item.PaymentID; pay.Total = item.Total; lstPayment.Add(pay); } ///////////// if (resulSplit != -1) { lstPaymentSplitBill[result].Total = lstPaymentSplitBill[result].Total + item.Total; } else { PayMentModel pay = new PayMentModel(); pay.PaymentTypeID = item.PaymentID; pay.Total = item.Total; lstPaymentSplitBill.Add(pay); } } catch (Exception ex) { LogPOS.WriteLog("frmPayMent::::::::addPayment:::::::::::::::::::::::::::CashModel::::::::::::::::::::::::::" + ex.Message); } }