private void btnReg_Click(object sender, EventArgs e) { SqlConnection connection; SqlCommand command; string sql = null; sql = "insert into MemberDetails(memberNumber,firstname, lastname,phoneNo, Gender,NKPhone, contactAddress,DateOfReg) values(" + Convert.ToInt32(maskedTextBox1.Text) + ",'" + txtFirstN.Text + "','" + txtLastN.Text + "','" + mtxtPhonee.Text + "','" + cboGend.Text + "','" + ccc.Text + "','" + txtContact.Text + "','" + dtpRegdate.Text + "')"; connection = new SqlConnection(connectionString); try { connection.Open(); command = new SqlCommand(sql, connection); command.ExecuteNonQuery(); command.Dispose(); connection.Close(); MessageBox.Show(" Member Registered Succcessfully.", "Member Registration", MessageBoxButtons.OK, MessageBoxIcon.Information); string number, message3; number = mtxtPhonee.Text; message3 = "Dear" + txtFirstN.Text + " " + txtLastN.Text + "Your Unique Member Number is " + label1.Text + " You are now a member of INUA JAMII Sacco. Pamoja Tuinuke. Karibu"; SMS sm = new SMS(cboModemPorts.Text); sm.Opens(); sm.sendSMS(number, message3); sm.Closes(); } catch (Exception ex) { MessageBox.Show("Registration Failed!" + ex.Message, "Member Registration", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error); } }
private void btnApprov_Click(object sender, EventArgs e) { SqlConnection connection; SqlCommand command; string sql = null; SqlDataReader dataReader; sql = "Select firstname,lastname, phoneNo from MemberDetails WHERE memberNumber='" + mtxtMNo.Text + "'"; connection = new SqlConnection(connectionString); try { connection.Open(); command = new SqlCommand(sql, connection); dataReader = command.ExecuteReader(); while (dataReader.Read()) { phone = dataReader.GetValue(2).ToString(); fn = dataReader.GetValue(0).ToString(); ln = dataReader.GetValue(1).ToString(); } dataReader.Close(); command.Dispose(); connection.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } string number, message1, message2, message3; txtReffcode.Text = (RandomString(8, false)); number = phone; message1 = "Dear" + " " + fn + " " + ln + ". Your Loan Of Kshs. " + " " + txtAmount.Text + " REF.NO" + " " + txtReffcode.Text + " has been Approved." + " You will receive the money within 24 hrs. Thank You."; message2 = "Dear" + " " + fn + " " + ln + ". Your Loan request Of Kshs. " + " " + txtAmount.Text + " REF.NO " + " " + txtReffcode.Text + " was denied. Please pay the existing loan."; message3 = "Dear" + " " + fn + " " + ln + ". Your Loan Application Of Kshs. " + " " + txtAmount.Text + " REF.NO " + " " + txtReffcode.Text + " has been Received. You shall be notified upon processing."; SMS sm = new SMS(cboComPorts.Text); sm.Opens(); if (cboLoanStat.Text == "Approved") { sm.sendSMS(number, message1); } else if (cboLoanStat.Text == "Denied") { sm.sendSMS(number, message2); } else if (cboLoanStat.Text == "Registered") { sm.sendSMS(number, message3); } else { cboLoanStat.Visible = false; } sm.Closes(); MessageBox.Show("Message Was Sent Successfully!", "Messaging Report", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void button1_Click(object sender, EventArgs e) { SqlConnection connection; SqlCommand command; SqlCommand command1; SqlCommand command2; string sql = null; SqlDataReader dataReader1; SqlDataReader dataReader2; string sql1 = null; string sql2 = null; sql = "insert into contribute(amount, date) values(" + textBox2.Text + ",'" + dateTimePicker1.Text + "' WHERE memberNumber='" + mtxtMNumber.Text + "')"; sql1 = "Select firstname, phoneNo from MemberDetails WHERE memberNumber=" + mtxtMNumber.Text + ""; sql2 = "Select TotalSaved from contribute WHERE memberNumber=" + mtxtMNumber.Text + ""; connection = new SqlConnection(connectionString); try { connection.Open(); command = new SqlCommand(sql, connection); command.ExecuteNonQuery(); command1 = new SqlCommand(sql1, connection); dataReader1 = command1.ExecuteReader(); command2 = new SqlCommand(sql1, connection); dataReader2 = command1.ExecuteReader(); string number = null, message, firstName = null; int totalsavings = 0; while (dataReader1.Read()) { number = dataReader1.GetValue(0).ToString(); firstName = dataReader1.GetValue(2).ToString(); } dataReader2 = command.ExecuteReader(); while (dataReader2.Read()) { totalsavings = dataReader2.GetInt32(0); } dataReader1.Close(); dataReader2.Close(); command.Dispose(); command1.Dispose(); command2.Dispose(); connection.Close(); message = "Dear" + firstName + ",Your Savings of Kshs." + textBox2.Text + "" + "has been received. Your total Savings as at" + DateTime.Now.ToString("M - d - yyyy") + "was Kshs." + totalsavings + "" + "Thank you"; SMS sm = new SMS(cboComPorts.Text); sm.Opens(); sm.sendSMS(number, message); sm.Closes(); MessageBox.Show(" Records Succcessfully Saved.", "Member Savings", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnSendBulk_Click(object sender, EventArgs e) { int a; progressBar1.Minimum = 0; progressBar1.Maximum = 200; for (a = 0; a <= 200; a++) { progressBar1.Value = a; label16.Text = "Sending Message.This will take a few more seconds seconds. Please wait..."; } SqlConnection connection; SqlCommand command; SqlDataAdapter adapter = new SqlDataAdapter(); DataSet ds = new DataSet(); int i = 0; string sql = null; sql = "Select firstname, phoneNo from MemberDetails"; connection = new SqlConnection(connectionString); try { connection.Open(); command = new SqlCommand(sql, connection); adapter.SelectCommand = command; adapter.Fill(ds); adapter.Dispose(); command.Dispose(); connection.Close(); for (i = 0; i <= ds.Tables[0].Rows.Count - 1; i++) { string jina = (ds.Tables[0].Rows[i].ItemArray[0]).ToString(); string number = ((ds.Tables[0].Rows[i].ItemArray[1])).ToString(); string messo = "Hi " + jina + ". " + rchMessageBulk.Text; SMS sm = new SMS(cboComPorts.Text); sm.Opens(); sm.sendSMS(number, messo); sm.Closes(); } MessageBox.Show("All Messages sent!", "Bulk SMS Report", MessageBoxButtons.OK, MessageBoxIcon.Information); label16.Text = "Sending Bulk SMS"; progressBar1.Visible = false; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnSendSing_Click(object sender, EventArgs e) { string number, message; number = txtPhone.Text; message = "Dear" + " " + fn + rchMessage.Text; SMS sm = new SMS(cboComPorts.Text); sm.Opens(); sm.sendSMS(number, message); sm.Closes(); MessageBox.Show("Message Was Sent Successfully!", "Messaging Report", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void button6_Click(object sender, EventArgs e) { int i; progressBar1.Minimum = 0; progressBar1.Maximum = 200; for (i = 0; i <= 200; i++) { progressBar1.Value = i; label11.Text = "Deleting All Member Details.This May take upto 30 seconds. Please wait..."; } SqlConnection connection; SqlCommand command; SqlCommand command1; string sql = null, sql1 = null; SqlDataReader dataReader, dataReader1; sql1 = "Select firstname,lastname, phoneNo from MemberDetails WHERE memberNumber='" + maskedTextBox1.Text + "'"; sql = "delete from MemberDetails,Loan,contribute,LoanRepayment,memberSavings WHERE memberNumber='" + maskedTextBox1.Text + "'"; connection = new SqlConnection(connectionString); try { command = new SqlCommand(sql, connection); command1 = new SqlCommand(sql1, connection); dataReader1 = command1.ExecuteReader(); connection.Open(); MessageBox.Show("Are Sure you want to Remove all data for this Member? ", "Confirm Deletion", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); DialogResult dlg = new DialogResult(); if (dlg == DialogResult.OK) { command = new SqlCommand(sql, connection); command.ExecuteNonQuery(); command.Dispose(); connection.Close(); dataReader = command.ExecuteReader(); } dataReader = command1.ExecuteReader(); while (dataReader.Read()) { string fn = dataReader.GetValue(2).ToString(); string ln = dataReader.GetValue(3).ToString(); string phone = dataReader.GetValue(4).ToString(); string message = "Dear" + " " + fn + " " + ln + ". Your are no longer a member of INUA JAMII SACCO. We Regret your exit. Please consider Reapplying again."; SMS sm = new SMS(cboModemPorts.Text); sm.sendSMS(phone, message); sm.Opens(); sm.Closes(); MessageBox.Show("All Member Details Removed!", "Member Account Deletion", MessageBoxButtons.OK, MessageBoxIcon.Information); label11.Text = "Action Deletion Progress"; progressBar1.Visible = false; } dataReader.Close(); command.Dispose(); connection.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }