private void VodacomListView_VisibleChanged(object sender, EventArgs e) { BussinessLogic checkMpesa = new BussinessLogic(); checkMpesa.checkCash(); }
private void SubmitButton_Click(object sender, EventArgs e) { //ErrorHandling resetlabels(); error = false; int cassh; ErrorHandling(); if (error == true) { AlertMain.Visible = true; //AlertMain.ForeColor = System.Drawing.Color.White; } else if (error == false) { //connect // MessageBox.Show("Success");\ XDocument hela = XDocument.Load(@"RuntimeData.xml"); var users = from usr in hela.Descendants("settings") select new { csh = usr.Element("cashIn").Value }; foreach (var use in users) { cassh = int.Parse(use.csh); dif = cassh - int.Parse(TransactionValue_TextBox.Text); } if (dif < 0) { MessageBox.Show("Balance insufficient"); } else { saveactvtydate(); if (CustomerIdNo_TextBox.Text == "") { CustomerIdNo_TextBox.Text = "000000000"; } if (CustomerIdType_TextBox.Text == "") { CustomerIdType_TextBox.Text = ""; } CustomerCellPhone_TextBox.Text = CustomerCellPhone_TextBox.Text; String trans_id = TransactionId_TextBox.Text; float trans_value = float.Parse(TransactionValue_TextBox.Text); String cust_name = CustomerName_TextBox.Text; int customer_phone_no = int.Parse(CustomerCellPhone_TextBox.Text); int customer_id = int.Parse(CustomerIdNo_TextBox.Text); String customer_id_type = CustomerIdType_TextBox.Text; String trans_type = ""; if (PokeaButton.Checked) { trans_type = "Pokea"; } else if (ToaButton.Checked) { trans_type = "Toa"; } // switch (label1.Text) { case "VODACOM M-PESA FORM": tablename = "mpesa"; Databasecon inserting = new Databasecon(); BussinessLogic calc = new BussinessLogic(); //BussinessLogic cashInhand = new BussinessLogic(); if (trans_type == "Pokea") { balance = calc.pokea(trans_value, "mpesa"); cash = calc.getCash(); } else if (trans_type == "Toa") { balance = calc.Toa(trans_value, "mpesa"); cash = calc.getCash(); } inserting.Insertdata(tablename, trans_id, trans_type, trans_value, cust_name, customer_phone_no, customer_id, customer_id_type, balance, cash); // turn = true; //vodz.reload(); Close(); //this.DialogResult = DialogResult.OK; break; case "TIGO PESA FORM": tablename = "tigopesa"; Databasecon insertin = new Databasecon(); BussinessLogic calculation = new BussinessLogic(); //BussinessLogic cashInhand = new BussinessLogic(); if (trans_type == "Pokea") { balance = calculation.pokea(trans_value, "tigopesa"); cash = calculation.getCash(); } else if (trans_type == "Toa") { balance = calculation.Toa(trans_value, "tigopesa"); cash = calculation.getCash(); } insertin.Insertdata(tablename, trans_id, trans_type, trans_value, cust_name, customer_phone_no, customer_id, customer_id_type, balance, cash); // turn = true; //vodz.reload(); Close(); //this.DialogResult = DialogResult.OK; break; case "EZYPESA FORM": tablename = "ezypesa"; Databasecon insert = new Databasecon(); BussinessLogic calculate = new BussinessLogic(); //BussinessLogic cashInhand = new BussinessLogic(); if (trans_type == "Pokea") { balance = calculate.pokea(trans_value, "ezypesa"); cash = calculate.getCash(); } else if (trans_type == "Toa") { balance = calculate.Toa(trans_value, "ezypesa"); cash = calculate.getCash(); } insert.Insertdata(tablename, trans_id, trans_type, trans_value, cust_name, customer_phone_no, customer_id, customer_id_type, balance, cash); // turn = true; //vodz.reload(); Close(); //this.DialogResult = DialogResult.OK; break; case "CRDB BANK FORM": tablename = "crdb"; Databasecon insertt = new Databasecon(); BussinessLogic calculatt = new BussinessLogic(); //BussinessLogic cashInhand = new BussinessLogic(); if (trans_type == "Pokea") { balance = calculatt.pokea(trans_value, "crdb"); cash = calculatt.getCash(); } else if (trans_type == "Toa") { balance = calculatt.Toa(trans_value, "crdb"); cash = calculatt.getCash(); } insertt.Insertdata(tablename, trans_id, trans_type, trans_value, cust_name, customer_phone_no, customer_id, customer_id_type, balance, cash); // turn = true; //vodz.reload(); Close(); //this.DialogResult = DialogResult.OK; break; case "AIRTEL MONEY FORM": tablename = "airtel"; Databasecon inserttt = new Databasecon(); BussinessLogic calculattt = new BussinessLogic(); //BussinessLogic cashInhand = new BussinessLogic(); if (trans_type == "Pokea") { balance = calculattt.pokea(trans_value, "airtel"); cash = calculattt.getCash(); } else if (trans_type == "Toa") { balance = calculattt.Toa(trans_value, "airtel"); cash = calculattt.getCash(); } inserttt.Insertdata(tablename, trans_id, trans_type, trans_value, cust_name, customer_phone_no, customer_id, customer_id_type, balance, cash); // turn = true; //vodz.reload(); Close(); //this.DialogResult = DialogResult.OK; break; } } } /* Connection to database * String tablename = "mpesa"; Databasecon inserting = new Databasecon(); */ //kazi kwako kupitisha variable checki mfumo wa function yangu Insertdata //inserting.Insertdata(tablename, 990, "toa", 10000,"sele", 091475533, 4, "passport",2000); //inserting.selectdata(); }