Example #1
0
        public void ImportPyments()
        {
            Payment p = null;

            try
            {
                SqlCompactConnection conn = new SqlCompactConnection();
                conn.connect();
                lblStatus.Text = "Connected to mobile database";
                RefreshForm();
                string    sql        = "select * from payment";
                DataTable dtPayments = conn.GetDataTable(sql);
                int       rows       = dtPayments.Rows.Count;
                if (rows == 0)
                {
                    lblStatus.Text += "\nNo payments found";
                    //MessageBox.Show("There are no records to import", "MICS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
                lblStatus.Text       = "Importing Payments..";
                progressBar1.Minimum = 0;
                progressBar1.Maximum = rows;
                RefreshForm();
                int count = 0;
                foreach (DataRow dr in dtPayments.Rows)
                {
                    p             = new Payment();
                    p.InvoiceID   = Int32.Parse(dr["InvoiceId"].ToString());
                    p.PaymentType = "S";
                    p.PaymentDate = DateTime.Parse(dr["PaymentDate"].ToString());
                    p.Amount      = decimal.Parse(dr["Amount"].ToString());
                    p.CheckNumber = dr["CheckNumber"].ToString();
                    p.Comments    = "Mobile Payment";
                    if (dr["Comments"].ToString() != String.Empty)
                    {
                        p.Comments += " : " + dr["Comments"].ToString();
                    }
                    //p.PaymentCode = dr["PaymentCode"].ToString();;
                    p.ModifiedDate = DateTime.Today;
                    p.AddPayment(p);
                    lblStatus.Text = "removing mobile payment..";
                    sql            = "delete payment where InvoiceId=" + p.InvoiceID;
                    conn.Execute(sql);
                    UpdatePaymentStatus(p.InvoiceID);
                    progressBar1.Value = count++;
                    RefreshForm();
                }
                lblStatus.Text     = rows.ToString() + " payments imported successfully";
                progressBar1.Value = rows;
                RefreshForm();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        protected void AddNewPayment()
        {
            PaymentObject payment = new PaymentObject();

            payment.payment = TextBox_payment.Text;
            payment.service = TextBox_Service.Text;
            payment.price   = decimal.Parse(TextBox_price.Text);

            payDal.AddPayment(payment);
            Response.Redirect("~/Admin/List_Payment.aspx");
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            bool blnSelected = false;

            foreach (DataGridViewRow dgvRow in dgvPayment.Rows)
            {
                bool isSelected = Convert.ToBoolean(dgvRow.Cells["chkColumn"].Value);
                if (isSelected)
                {
                    blnSelected = true;
                    break;
                }
            }
            if (!blnSelected)
            {
                MessageBox.Show("Select at least one row for payment", "Select row", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            else
            {
                try
                {
                    string  strXML       = CreatePaymentXML();
                    string  strPaymentId = string.Empty;
                    Payment _obj         = new Payment();
                    bool    blnSuccess   = _obj.AddPayment(strXML, intTotalRow, out strPaymentId);
                    if (blnSuccess)
                    {
                        MessageBox.Show("Payment saved successfully", "Payment saved", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        PaymentReceipt receipt = new PaymentReceipt(strPaymentId);
                        receipt.ShowDialog();
                        btnClear_Click(sender, e);
                    }
                    else
                    {
                        MessageBox.Show("Payment failed. Try again later", "Payment failed", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Payment failed. Try again later", "Payment failed", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    LogError.LogEvent("SavePayment", ex.Message, "Save Payment");
                }
            }
        }