Example #1
0
        public Form1(String customer_id)
        {
            this.customer_id = customer_id;
            InitializeComponent();
            dataGridView2.Visible          = false;
            cbx_creditPeriod.DropDownStyle = ComboBoxStyle.DropDownList;
            cbx_loanCategory.DropDownStyle = ComboBoxStyle.DropDownList;
            lbl_customerBalance.Text       = String.Format(new CultureInfo("en-US"), "{0:C}", customerDal.getBalance(customer_id));
            String customer_name = customerDal.getCustomerName(customer_id).ToString();

            lbl_welcome.Text      = "WELCOME" + " " + customer_name.ToUpper();;
            lbl_customerName.Text = "Dear Customer " + customer_name.ToUpper() + " You Can Easily Apply For a Loan";
            double customerDebt = customerDal.getCustomerCreditDebt(customer_id);

            lbl_customerCreditDebt.Visible = false;
            if (customerDebt != 0)
            {
                lbl_customerCreditDebt.Visible = true;

                lbl_customerCreditDebt.Text = ($" Your Remaining Loan Debt is  {String.Format(new CultureInfo("en-US"), "{0:C}", customerDebt)} ");
            }
        }
Example #2
0
        public void PayBill(String customer_id, double customer_balance, double bill_amount, int bill_id, String type)
        {
            int j;

            try
            { connection.openConnection();
              double       updated_balance = customer_balance - bill_amount;
              MySqlCommand command         = new MySqlCommand("DELETE FROM bill WHERE Bill_ID =@Id ", connection.mysqlconnect);
              command.Parameters.AddWithValue("@Id", bill_id);
              int         i           = command.ExecuteNonQuery();
              CustomerDal customerDal = new CustomerDal();

              if (type == "loan")
              {
                  double debt         = customerDal.getCustomerCreditDebt(customer_id);
                  double updated_debt = debt - bill_amount;

                  MySqlCommand command2 = new MySqlCommand("Update customer set creditDebt=@updated_debt where customer_id=@Id", connection.mysqlconnect);
                  command2.Parameters.AddWithValue("@Id", customer_id);
                  command2.Parameters.AddWithValue("@updated_debt", updated_debt);
                  j = command2.ExecuteNonQuery();


                  int k = customerDal.updateBalance(customer_id, updated_balance);
              }
              else
              {
                  j = customerDal.updateBalance(customer_id, updated_balance);
              }



              if (i > 0 && j > 00)
              {
                  MessageBox.Show("Bill was paid succesfully");
              }
              else
              {
                  MessageBox.Show("Operation could not complete please try again");
              } }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }

            connection.closeConnection();
        }