Пример #1
0
        private void duebillPaymentButton_Click(object sender, EventArgs e)
        {
            if (tempSearchOrderInfo.DueBill > 0)
            {

                DueBillPaymentForm aDueBillPaymentForm = new DueBillPaymentForm();
                aDueBillPaymentForm.ShowDialog();

                double amount = 0.0;

                if (DueBillPaymentForm.inputResult.Equals("Cancel"))
                    return;

                string amt = DueBillPaymentForm.inputResult.Substring(Program.currency.Length);

                if (Convert.ToDouble(amt) == 0.00)
                {
                    CMessageBox tempMessageBox = new CMessageBox("Error!", "Price cannot be zero.");
                    tempMessageBox.ShowDialog();
                    return;
                }
                amount = Convert.ToDouble(amt);

                string paymentmethod = "";
                string cardName = "";
                PaymentMethod aPaymentMethod = new PaymentMethod();
                aPaymentMethod.ShowDialog();
                paymentmethod = PaymentMethod.inputResult;

                if (paymentmethod == "Card")
                {
                    EFTOptionForm eFTOptionForm = new EFTOptionForm();

                    DialogResult dr = eFTOptionForm.ShowDialog();

                    if (dr == DialogResult.Cancel)
                        return;

                    saveEFTCardAgainsOrderid(EFTOptionForm.seletedEFTCard);
                }

                PaymentDueBill aPaymentDueBill = new PaymentDueBill();
                CPayment aPayment = new CPayment();
                aPayment.OrderID = orderID;

                double tempamount = 0;
                if (amount - tempSearchOrderInfo.DueBill >= 0)
                {
                    tempamount = tempSearchOrderInfo.DueBill;
                }
                else if (tempSearchOrderInfo.DueBill - amount > 0)
                {
                    tempamount = amount;
                }
                if (paymentmethod == "Cash")
                {
                    aPayment.CashAmount = tempamount;
                    aPayment.EFTAmount = 0;
                    aPaymentDueBill.CashAmount = tempamount;
                }

                else if (paymentmethod == "Card")
                {
                    aPayment.EFTAmount = tempamount;
                    aPayment.CashAmount = 0;
                    aPaymentDueBill.CardAmount = tempamount;

                }
                aPayment.ChequeAmount = tempSearchOrderInfo.DueBill - tempamount;
                aPaymentDueBill.PaymentDate = DateTime.Now;

                CPaymentDAO aPaymentDao = new CPaymentDAO();
                string sr = aPaymentDao.UpdatePaymentForDueBill(aPayment, aPaymentDueBill);
                MessageBox.Show(sr);
                this.Close();
            }
            else
            {
                MessageBox.Show("Due Bill Must be greater than zero");
            }
        }
Пример #2
0
        private PaymentDueBill ReaderToReadDueBill(IDataReader oReader)
        {
            PaymentDueBill aPaymentDueBill = new PaymentDueBill();
            try
            {
                aPaymentDueBill.BillId = Convert.ToInt32(oReader["billId"]);
            }
            catch (Exception)
            {
            }
            try
            {
                aPaymentDueBill.CashAmount = Convert.ToDouble(oReader["cashamount"]);
            }
            catch (Exception)
            {
            }
            try
            {
                aPaymentDueBill.CardAmount = Convert.ToDouble(oReader["cardamount"]);
            }
            catch (Exception)
            {
            }
            try
            {
                aPaymentDueBill.Cheque = Convert.ToDouble(oReader["chequeamount"]);
            }
            catch (Exception)
            {
            }
            try
            {
                aPaymentDueBill.PaymentDate = Convert.ToDateTime(oReader["paymentdate"]);
            }
            catch (Exception)
            {
            }

            return aPaymentDueBill;
        }
Пример #3
0
        public string UpdatePaymentForDueBill(CPayment aPayment, PaymentDueBill aPaymentDueBill)
        {
            string result = "";
            try
            {
                this.OpenConnection();
                string sSql = string.Format(SqlQueries.GetQuery(Query.UpdatePaymentForDueBill), aPayment.OrderID, aPayment.CashAmount, aPayment.EFTAmount, aPayment.ChequeAmount);
                this.ExecuteNonQuery(sSql);
                result = "Due Bill Payment Successfully";
                int billid = CheckExistsDueBill(aPaymentDueBill);
                if (billid > 0)
                {
                    aPaymentDueBill.BillId = billid;
                    sSql = string.Format(SqlQueries.GetQuery(Query.UpdateTotalDueBillPayment), aPaymentDueBill.BillId, aPaymentDueBill.CashAmount, aPaymentDueBill.CardAmount, aPaymentDueBill.Cheque);
                    this.ExecuteNonQuery(sSql);
                }
                else
                {
                    sSql = string.Format(SqlQueries.GetQuery(Query.InsertTotalDueBillPayment), aPaymentDueBill.CashAmount, aPaymentDueBill.CardAmount, aPaymentDueBill.Cheque, DateTime.Now.Date);
                    this.ExecuteNonQuery(sSql);
                }

            }
            catch (Exception ex)
            {
                result = "Sorry Please Try again";
                Logger.Write("Exception : " + ex + " in UpdatePaymentVatStat()", LogLevel.Error, "Database");

            }
            finally
            {
                this.CloseConnection();
            }

            return result;
        }
Пример #4
0
        private int CheckExistsDueBill(PaymentDueBill aPaymentDueBill)
        {
            int result = 0;
            try
            {
                this.OpenConnection();
                string sSql = string.Format(SqlQueries.GetQuery(Query.CheckExistsDueBill), DateTime.Now.Date);
                IDataReader oReader = this.ExecuteReader(sSql);

                if (oReader != null)
                {
                    while (oReader.Read())
                    {
                        result = Convert.ToInt32(oReader[0]);
                    }

                    oReader.Close();
                }

            }
            catch (Exception ex)
            {

                Logger.Write("Exception : " + ex + " in CheckExistsDueBill()", LogLevel.Error, "Database");

            }
            finally
            {
                this.CloseConnection();
            }

            return result;
        }
Пример #5
0
        public List<PaymentDueBill> GetTotalDuePayment(DateTime duebillfromDate, DateTime duebilltoDate)
        {
            List<PaymentDueBill> aPaymentDueBills = new List<PaymentDueBill>();
            try
            {
                this.OpenConnection();
                string sSql = string.Format(SqlQueries.GetQuery(Query.GetTotalDuePayment), duebillfromDate, duebilltoDate);
                IDataReader oReader = this.ExecuteReader(sSql);

                if (oReader != null)
                {
                    while (oReader.Read())
                    {
                        PaymentDueBill aPaymentDueBill = new PaymentDueBill();
                        aPaymentDueBill = ReaderToReadDueBill(oReader);
                        aPaymentDueBills.Add(aPaymentDueBill);
                    }

                    oReader.Close();
                }

            }
            catch (Exception ex)
            {

                Logger.Write("Exception : " + ex + " in CheckExistsDueBill()", LogLevel.Error, "Database");

            }
            finally
            {
                this.CloseConnection();
            }

            return aPaymentDueBills;
        }