Ejemplo n.º 1
0
        private void frmPayments_Load(object sender, EventArgs e)
        {
            try
            {
                DataTable db     = ClassPayments.getPaymentId();
                string    payId  = db.Rows[0][0].ToString();
                int       npayId = Int32.Parse(payId) + 1;
                txtPaymentId.Text = npayId.ToString();


                AutoCompleteStringCollection collection = classCustomers.getAutoCompleteCustomersNames();

                txtCusName.AutoCompleteCustomSource = collection;


                dgvPaymentView.DataSource            = ClassPayments.PaymentSearch();
                dgvPaymentView.Columns[0].HeaderText = "Payment ID";
                dgvPaymentView.Columns[1].HeaderText = "Customer Id";
                dgvPaymentView.Columns[2].HeaderText = "Customer Name";
                dgvPaymentView.Columns[3].HeaderText = "Date";
                dgvPaymentView.Columns[4].HeaderText = "Amount";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 2
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            float Payingvalue;
            int   x = 1;

            try
            {
                if (txtcusId.Text == "")
                {
                    throw new Exception("Enter a Customer.");
                }
                Payingvalue = float.Parse(txtAmountPaying.Text);
                if (txtAmountPaying.ForeColor == Color.Red)
                {
                    throw new Exception("Enter a less paying amount.");
                }

                x = 2;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                txtAmountPaying.Text = "";
            }
            if (x == 2)
            {
                var payement = new ClassPayments
                {
                    paymentid     = txtPaymentId.Text,
                    paymentdate   = lblDate.Text,
                    paymentamount = float.Parse(txtAmountPaying.Text),
                    customerid    = txtcusId.Text
                };

                int pay      = payement.insertTopayment(payement);
                int customer = classCustomers.updateCustomerCreditValue(txtAmountPaying.Text, txtcusId.Text);

                foreach (var c in this.Controls)
                {
                    if (c is TextBox)
                    {
                        ((TextBox)c).Text = String.Empty;
                    }
                }
            }

            dgvPaymentView.DataSource            = ClassPayments.PaymentSearch();
            dgvPaymentView.Columns[0].HeaderText = "Payment ID";
            dgvPaymentView.Columns[1].HeaderText = "Customer Id";
            dgvPaymentView.Columns[2].HeaderText = "Customer Name";
            dgvPaymentView.Columns[3].HeaderText = "Date";
            dgvPaymentView.Columns[4].HeaderText = "Amount";
        }