private void PercentageVotersReportByArea_Load(object sender, EventArgs e) { double amount = 0, sum = 0; con.sqlCommand("ReturnKalpiesCodes"); con.InsertValstring("@area", area_manager.Area); DataTable KalpiCode = con.GetData("ReturnKalpiesCodes"); for (int i = 0; i < KalpiCode.Rows.Count; i++) { DataRow code = KalpiCode.Rows[i]; con.sqlCommand("getSumOfVoters"); con.InsertValstring("@kalpiCode", code["kalpiCode"].ToString()); DataTable amou = con.GetData("getSumOfVoters"); sum += amou.Rows.Count; } con.sqlCommand("getAmountVOtersInArea"); con.InsertValstring("@area", area_manager.Area); DataTable temp = con.GetData("getAmountVOtersInArea"); for (int i = 0; i < temp.Rows.Count; i++) { DataRow perVoters = temp.Rows[i]; amount += int.Parse(perVoters["votersAmount"].ToString()); } textBox.Text = ((sum * 100) / amount).ToString() + "%"; }
public DataRow SearchVoterToAdd(String ID) { con.sqlCommand("SearchVoterToAdd"); con.InsertValstring("@id", ID); DataTable tab = con.GetData("SearchVoterToAdd"); return(tab.Rows[0]); }
public DataRow SearchKalpi(string c) { con.sqlCommand("SearchKalpi"); con.InsertValstring("@KalpiCode", c.Trim()); DataTable tab = con.GetData("searchKalpi"); return(tab.Rows[0]); }
private void comboBoxArea_SelectedIndexChanged(object sender, EventArgs e) { con.sqlCommand(PROC_CITIES); con.InsertValstring("@area", comboBoxArea.Text); cities = con.GetData(PROC_CITIES); comboBoxCity.Text = "Select"; comboBoxKalpiName.Text = "Select"; comboBoxCity.Items.Clear(); foreach (DataRow city in cities.Rows) { comboBoxCity.Items.Add(city["City"].ToString()); } }
/// <summary> /// The function check kalpi code exist and unblock him. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { try { sqlConnection con = sqlConnection.Instance; //sql conection con.sqlCommand("getCalpiCode"); //sql Procedure con.InsertValstring("@kalpiCode", textBox1.Text); //sql insert Value DataTable kCode = con.GetData("getCalpiCode"); if (kCode.Rows.Count == 0) { throw new Exception(); } foreach (DataRow code in kCode.Rows) { if (code["kalpiCode"].ToString().Equals(textBox1.Text)) { areaManager.unblockCalpi(textBox1.Text); //call to blocked Function MessageBox.Show("Block is sucsses"); this.Close(); } } } catch { MessageBox.Show("The Kalpi Code is invalid!"); } }
private void button1_Click(object sender, EventArgs e) { try { sqlConnection con = sqlConnection.Instance; //sql conection con.sqlCommand("getCalpiCode"); //sql Procedure con.InsertValstring("@kalpiCode", KalpiCodetextBox.Text); //sql insert Value DataTable kCode = con.GetData("getCalpiCode"); //Check if the kalpi does't exists if (kCode.Rows.Count == 0) { throw new Exception(); } //Check if equals to kalpi manager kalpi code if (kalpiManager.KalpiCode.Equals(KalpiCodetextBox.Text)) { kalpiManager.CloseKalpi(KalpiCodetextBox.Text); //call to CloseKalpi Function MessageBox.Show("Close kalpi is sucsses"); } else { MessageBox.Show("The input KalpiCode does not match to the Kalpi Manager kalpiCode!"); } } catch { MessageBox.Show("The Kalpi Code is invalid!"); } }
//Searching party in DB. public DataRow SerachParty(string key) { con.sqlCommand("SearchParty"); con.InsertValstring("@partyName", key.Trim()); DataTable tab = con.GetData("SearchParty"); return(tab.Rows[0]); }
public DataRow SerachMember(int key) { con.sqlCommand("SearchPartyMember"); con.InsertValint("@member_code", key); DataTable tab = con.GetData("SearchPartyMember"); return(tab.Rows[0]); }
public DataRow SearchVoterToUpdate(string id) { sqlConnection p1 = sqlConnection.Instance; p1.sqlCommand("SearchVoterToUpdate"); p1.InsertValstring("@id", id); DataTable tab = p1.GetData("SearchVoterToUpdate"); return(tab.Rows[0]); }
public DataRow SearchVoter(string id) { sqlConnection p1 = sqlConnection.Instance;//sql conection p1.sqlCommand("SearchVoter"); p1.InsertValstring("@id", id); //sending parameters DataTable tab = p1.GetData("SearchVoter"); return(tab.Rows[0]); }
private DataTable kalpies; //will hold kalpis details in area manager area /// <summary> /// constructor /// </summary> /// <param name="mngr">instance of area manager</param> public ElectionsResultArea(AreaManager mngr) { InitializeComponent(); area_manager = mngr; l_area.Text = mngr.Area; con.sqlCommand("ReturnKalpiesInArea"); con.InsertValstring("@area", area_manager.Area); //sending parameters kalpies = con.GetData("ReturnKalpiesInArea"); showPartyResults(); showPrimeResults(); }
public void ShowMandates() { con.sqlCommand("ShowMandat");//Get info from procedure DataTable t = con.GetData("ShowMandat"); foreach (DataRow row in t.Rows) { listView1.Items.Add(row["Name"].ToString()); int val = int.Parse(row["Total"].ToString()) / 3; listView2.Items.Add(val.ToString()); } }
/// <summary> /// Search Party in database /// </summary> /// <param name="name"></param> /// public Parties searchPartyName(string name) { Parties party = null; if ("1".Equals(this.CheakParty(name.Trim()))) { sqlConnection sql = sqlConnection.Instance; sql.sqlCommand("SearchParty"); //sql conection sql.InsertValstring("@partyName", name); //sending parameters party = new Parties(sql.GetData("SearchParty").Rows[0]); } return(party); }
private void ShowKalpiesInArea_Load(object sender, EventArgs e) { comboBox1.Text = "Select"; //show at first "select" con.sqlCommand("SearchKalpiesByArea"); con.InsertValstring("@area", area_manager.Area); //pass the area manager area String result = con.getVal("@Result"); if (result.Equals("1")) { con.sqlCommand("ReturnKalpiesCodes"); con.InsertValstring("@area", area_manager.Area); DataTable KalpiCode = con.GetData("ReturnKalpiesCodes"); foreach (DataRow code in KalpiCode.Rows) { comboBox1.Items.Add(code["kalpiCode"].ToString()); //add kalpies codes } } else { MessageBox.Show("There are no kalpies in your area"); } }
//Serach Worker by Id public Voter SearchWorker(string id) { try { sqlConnection con = sqlConnection.Instance; con.sqlCommand("SearchWorker"); con.InsertValstring("@id", id); DataTable worker = con.GetData("SearchWorker"); return(new Voter(worker.Rows[0])); } catch { return(null); } }
/// <summary> /// Search Party member in database /// </summary> /// <param name="name"></param> /// public List <PartyMember> searchPartyNameBy(string name) { List <PartyMember> party = new List <PartyMember>(); if ("1".Equals(this.CheckNameOFPartyMember(name))) { sqlConnection sql = sqlConnection.Instance; sql.sqlCommand("SearchPartyMemberByName"); //sql conection sql.InsertValstring("@partyName", name); //sending parameters DataTable temp = sql.GetData("SearchPartyMemberByName"); foreach (DataRow i in temp.Rows) { party.Add(new PartyMember(i)); } } return(party); }
private void WatchKalpi_Load(object sender, EventArgs e) { if (voter.KalpiCode == "0") { MessageBox.Show("You are not assigned to any Kalpi!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } con.sqlCommand("getKalpiByCode"); con.InsertValstring("@kalpiCode", voter.KalpiCode); DataTable temp = con.GetData("getKalpiByCode"); DataRow kalpi = temp.Rows[0]; textBoxCity.Text = kalpi["city"].ToString(); textBoxKalpi.Text = kalpi["kalpiName"].ToString(); textBoxAddress.Text = kalpi["address"].ToString(); }
private void TotalVotePercentage_Load(object sender, EventArgs e) { con.sqlCommand("getTotalprecentage"); DataTable t = con.GetData("getTotalprecentage"); DataRow r = t.Rows[0]; double res = 0; try { res = double.Parse(r[0].ToString()); } catch { MessageBox.Show("Unknown error!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } labelRes.Text = res.ToString() + " %"; }
/// <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!"); } }
//the procedur of searching invalid kalpies private void butt_Click(object sender, EventArgs e) { comBox1.Text = "Select"; //show at first "select" con.sqlCommand("SearchKalpiByCity"); //the procedure con.InsertValstring("@city", voter.City); String result = con.getVal("@Result"); if (result.Equals("1")) { con.sqlCommand("SearchInvalidKalpies"); //the procedure con.InsertValstring("@city", voter.City); DataTable KalpiCode = con.GetData("SearchInvalidKalpies"); foreach (DataRow code in KalpiCode.Rows) { comBox1.Items.Add(code["kalpiCode"].ToString()); //add kalpies codes } } else { MessageBox.Show("There are no kalpies with invalid access"); } }
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 DataTable getVotesForPrime() { con.sqlCommand("getPrimeVotes"); con.InsertValstring("@kalpiCode", this.KalpiCode); return(con.GetData("getPrimeVotes")); }