protected void LinkButton2_Click(object sender, EventArgs e) { Auth p = new Auth(); auth.login("Select *from Agents_Reg where National_ID='" + TextBox1.Text + "' or Username='******'"); if (auth.log) { Label2.Text = "Error! The user with above ID or Username already exist!."; } else { OpenClass.inserting("Insert into Agents_Reg(Station_ref,National_ID,Full_names,Username,Password,Location,Phone,Role) VALUES('" + DropDownList1.SelectedItem.Value + "','" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "','" + TextBox5.Text + "','" + TextBox7.Text + "','2')"); TextBox4.Text = "12345678"; Label2.Text = "Submitted successfully!"; //SEND MESSAGE string message1 = "Hae " + TextBox2.Text + " ,Your have been registered as an fuel sales agent at " + TextBox5.Text + " fuel Station.\n"; message1 += "Your username is:YOUR NATIONAL ID"; message1 += " and your password is: " + TextBox4.Text; message1 += ".\nPlease use above credentials to log in every evening at 5:00pm and submit meter readings to the manager.You will be directed to set new strong password.\n Call 0712035642 for assistance."; OpenClass send = new OpenClass(); string Phone = TextBox7.Text; p.SendMessage(p.Add254(Phone), message1); OpenClass.ClearInputs(Page.Controls); } }
protected void confirmRefilling(object sender, EventArgs e) { //REFILING TANK string str = ConfigurationManager.ConnectionStrings["Fuel_systemConnectionString"].ToString(); SqlConnection con = new SqlConnection(str); SqlCommand cmd = new SqlCommand("select *from Fuel WHERE Station_ref='" + Session["Station_ref"] + "' AND Fuel_ref='" + Session["Fuel_ref"] + "'", con); con.Open(); SqlDataReader myDataReadert = cmd.ExecuteReader(); if (myDataReadert.Read()) { float prev = float.Parse(myDataReadert["Current_capacity"].ToString()); float toBeRefilled = float.Parse(Label25.Text.ToString()); float newValue = prev + toBeRefilled; generalClass.test(newValue); if (generalClass.check) { tableConfirming.Visible = false; LinkButton9.Visible = true; TextBox2.Visible = true; Label27.Text = "The value you entered is greater than the tank capacity!!."; Label27.ForeColor = System.Drawing.Color.Red; } else { generalClass.inserting("UPDATE FUEL SET Current_capacity ='" + newValue + "' WHERE Station_ref='" + Session["Station_ref"] + "' AND Fuel_ref='" + Session["Fuel_ref"] + "'"); SqlConnection cont = new SqlConnection(str); SqlCommand cmdt = new SqlCommand("select *from Agents_Reg WHERE Station_ref='" + Session["Station_ref"] + "'", cont); cont.Open(); SqlDataReader myDataReadertt = cmdt.ExecuteReader(); if (myDataReadertt.Read()) { string message1 = "" + Session["Fuel_ref"] + "' has been refilled current volume: "; string message2 = +newValue + ". "; string message3 = message1 + message2 + "Please contact station manager for more details."; generalClass.SendMessage(generalClass.Add254(myDataReadertt["Phone"].ToString()), message3); //generalClass.SendMessage(generalClass.Add254(myDataReadertt["Phone"].ToString()), message3); Label27.Text = "Submitted successfully and notification was sent to " + myDataReadertt["Full_names"]; Label27.ForeColor = System.Drawing.Color.Green; cont.Close(); beforeSubmit.Visible = true; Label28.Text = "Success!"; Label22.Text = ""; Label299.Text = ""; } else { Label28.Text = "Success!"; Label22.Text = ""; Label299.Text = ""; con.Close(); Label27.Text = "Submitted successfully but notification was not sent to Agent because there was no corresponding contacts!"; Label27.ForeColor = System.Drawing.Color.Red; beforeSubmit.Visible = true; } } } actions(); Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "refill()", true); }