//Update worker to Commissioner public string updateWorker(string id, string kalpiCode, string name, string lastname, string username, string password, string permission, DateTime birthDay, string addres, string area, string city, string tell) { Voter worker = new Voter(id, kalpiCode, name, lastname, username, password, permission, birthDay, addres, area, city, tell, "Commissioner", true, false, true); sqlConnection con = sqlConnection.Instance; con.sqlCommand("updateWorker"); con.InsertValstring("@idVoter", worker.Id); con.InsertValstring("@kalpiCode", worker.KalpiCode); con.InsertValstring("@name", worker.FName); con.InsertValstring("@lastname", worker.LName); con.InsertValstring("@username", worker.username); con.InsertValstring("@password", worker.Passowrd); con.InsertValstring("@permission", worker.Permission); con.InsertValstring("@address", worker.Address); con.InsertValstring("@area", worker.Area); con.InsertValstring("@city", worker.City); con.InsertValDate("@birthDay", worker.DOB); con.InsertValstring("@tell", worker.Tell); return(con.getVal("@Result")); }
/// <summary> /// The function Chack if kalpi Name Equals with kalpi manager /// and blocked Voter. /// </summary> private void button1_Click(object sender, EventArgs e) { try { int i; bool success = int.TryParse(textBox1.Text, out i); if (textBox1.Text.Length == 9 && success == true && int.Parse(textBox1.Text) > 0) // Checks for valid input { sqlConnection con = sqlConnection.Instance; //sql conection con.sqlCommand("getCalpiCodeById"); //sql Procedure con.InsertValstring("@id", textBox1.Text.Trim()); //sql insert Value DataTable kCode = con.GetData("getCalpiCodeById"); if (kCode.Rows.Count == 0) { throw new Exception(); } foreach (DataRow code in kCode.Rows) { if (code["kalpiCode"].ToString().Equals(manager.KalpiCode)) { manager.BlockedCitizen(textBox1.Text); //call to blocked Function MessageBox.Show("Block Voter Succeeded"); this.Close(); } else { MessageBox.Show("can't block voter, he doesn't belong to your kalpi"); this.Close(); } } } else { MessageBox.Show(" Invalid input"); } } catch { MessageBox.Show("The Id is invalid!"); } }
public Boolean login(string id, string username, string password)//this function check the details accordingly to the data base. { con.sqlCommand("login"); con.InsertValstring("@id", id.Trim()); con.InsertValstring("@username", username.Trim()); con.InsertValstring("@password", password.Trim()); DataTable temp = con.GetData("login"); if ((textBox1.Text == "") || (textBox2.Text == "") || (textBox3.Text == "")) //check if One or more of the fields are empty. { MessageBox.Show("One or more of the fields are empty"); return(false); } try { int.Parse(textBox1.Text);//check id field - contain only numbers. } catch { MessageBox.Show("Invalid input in Id Field"); return(false); } if (temp.Rows.Count > 0) { var factory = new FactroryVoter() as ICreateVoters; user = factory.createVoter(temp.Rows[0]);//if the user found in data base return(true); } else { MessageBox.Show("Doesn't Exist In Data Base!!"); textBox1.Text = ""; textBox2.Text = ""; textBox3.Text = "";//clean fields return(false); } }
public int addNewKalpi(Kalpi kalpi) { con.sqlCommand("addNewKalpi"); con.InsertValstring("@kalpiCode", kalpi.KalpiCode); con.InsertValstring("@kalpiName", kalpi.KalpiName); con.InsertValstring("@address", kalpi.Address); con.InsertValstring("@city", kalpi.City); con.InsertValstring("@area", this.Area); con.InsertValint("@maxVoters", kalpi.MaxVoters); return(int.Parse(con.getVal("Result").ToString())); }
public DataTable getVotesForPrime() { con.sqlCommand("getPrimeVotes"); con.InsertValstring("@kalpiCode", this.KalpiCode); return(con.GetData("getPrimeVotes")); }