//Consructor that gets full details about some party and create it. public Parties(string PartyName, int membersSize, string platform) { this.partyName = PartyName; this.MembersSize = membersSize; this.Platform = platform; con = sqlConnection.Instance; }
/// <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!"); } }
//Conturctor that gets a raw from Parties DB and create an object. public Parties(DataRow party) { con = sqlConnection.Instance; partyName = party["partyName"].ToString(); membersSize = int.Parse(party["memberSize"].ToString()); platform = party["platform"].ToString(); mode = Boolean.Parse(party["mode"].ToString()); }
private string RemoveVoter(string id) { sqlConnection con = sqlConnection.Instance; con.sqlCommand("RemoveVoter"); con.InsertValstring("@id", id); return(con.getVal("@result")); }
public void RemoveAcompanier(string Id) { sqlConnection p1 = sqlConnection.Instance; //sql conection p1.sqlCommand("RemoveAcompanier"); //sql Procedure p1.InsertValstring("@Id", Id); //sending parameters p1.NonQueryE(); //Updating }
//Cheacking name of parties public string CheakParty(string name) { sqlConnection sql = sqlConnection.Instance; //sql conection sql.sqlCommand("CheakParty"); //sql Procedure sql.InsertValstring("@partyName", name); //sending parameters return(sql.getVal("@Result")); }
public string addKalpiToVoter(String id, String kalpiCode) { sqlConnection p1 = sqlConnection.Instance; //sql conection p1.sqlCommand("addKalpiToVoter"); //sql Procedure p1.InsertValstring("@id", id); //sending parameters p1.InsertValstring("@kalpiCode", kalpiCode); //sending parameters return(p1.getVal("@Result")); //Updating }
private string UpdateLastDate(string id) { sqlConnection con = sqlConnection.Instance; con.sqlCommand("UpdateLastDate"); con.InsertValstring("@id", id); con.InsertValDate("@lastdate", DateTime.Now.Date); return(con.getVal("@result")); }
public void unblockCalpi(String kalpiCode) { sqlConnection p1 = sqlConnection.Instance; //sql conection p1.sqlCommand("unblockKalpi"); //sql Procedure p1.InsertValstring("@kalpiCode", kalpiCode); //sending parameters p1.InsertValstring("@openKalpi", "True"); //sending parameters p1.NonQueryE(); //Updating }
public AddCommissioner(ElectionsManager man) { InitializeComponent(); con = sqlConnection.Instance; electionManager = new ElectionsManager(man); KalpiManager = new KalpiManager(man); worker = null; flag = false; }
/// <summary> /// Update new Accompanier Id in database /// </summary> /// <param name="accomId"></param> /// <param name="id"></param> public void addAccompanierId(string accomId, string id) { sqlConnection p1 = sqlConnection.Instance; //sql conection p1.sqlCommand("addAccompanierId"); //sql Procedure p1.InsertValstring("@id", id); //sending parameters p1.InsertValstring("@accomId", accomId); //sending parameters p1.NonQueryE(); //Updating }
/// <summary> /// Update new password in database /// </summary> /// <param name="password"></param> /// <param name="id"></param> public void changePass(string password, string id) { sqlConnection p1 = sqlConnection.Instance; //sql conection p1.sqlCommand("changePassword"); //sql Procedure p1.InsertValstring("@id", id); //sending parameters p1.InsertValstring("@password", password); //sending parameters p1.NonQueryE(); //Updating }
/// <summary> /// the method unblockes a voter, allowing him to vote /// </summary> /// <param name="id">the id of the voter needs to be unblocked</param> public void UnblockedCitizen(string id) { sqlConnection p1 = sqlConnection.Instance; //sql conection p1.sqlCommand("unblockCitizen"); //sql Procedure p1.InsertValstring("@id", id); //sending parameters p1.InsertValstring("@isBlocked", "False"); //sending parameters p1.NonQueryE(); //Updating }
public int changeKalpiVote(string kalpiC) { sqlConnection con = sqlConnection.Instance; con.sqlCommand("updateVoterKalpi"); con.InsertValstring("@prev_kalpi", kalpiCode); con.InsertValstring("@kalpiCode", kalpiC); con.InsertValstring("@id", id); return(int.Parse(con.getVal("res").ToString())); }
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]); }
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]); }
//Consructor that gets full details about some member and create him. public PartyMember(int Code, string nameParty, string name, string lastname, DateTime brithDate, int sizeMemberSize, string exp, string education) { con = sqlConnection.Instance; memberCode = Code; PartyName = nameParty; FName = name; LName = lastname; SetDob(brithDate); ListPlace = sizeMemberSize; Education = education; Experience = exp; Mode = true; }
//Consructor that gets full kalpi details and creates a new Kalpi. public Kalpi(string kalpi_code, string id_manager, string kalpi_name, string address, string city, string area, int voters_amount, int max_voters, Boolean invalid_access) { this.kalpiCode = kalpi_code; this.managerID = id_manager; this.kalpiName = kalpi_name; this.address = address; this.city = city; this.area = area; this.votersAmount = voters_amount; this.maxVoters = max_voters; this.invalidAccess = invalid_access; con = sqlConnection.Instance; }
//Conturctor that gets a raw from Parties DB and create an object. public PartyMember(DataRow member) { con = sqlConnection.Instance; memberCode = int.Parse(member["memberCode"].ToString()); partyName = member["partyName"].ToString(); listPlace = int.Parse(member["listPlace"].ToString()); fName = member["fName"].ToString(); lName = member["lName"].ToString(); dob = DateTime.Parse(member["dob"].ToString()); education = member["education"].ToString(); experience = member["experience"].ToString(); mode = Boolean.Parse(member["mode"].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); }
//Constructor that creates a new Kalpi using a datarow from a table in the database public Kalpi(DataRow kalpi) { con = sqlConnection.Instance; kalpiCode = kalpi["kalpiCode"].ToString(); managerID = kalpi["managerID"].ToString(); kalpiName = kalpi["kalpiName"].ToString(); address = kalpi["address"].ToString(); city = kalpi["city"].ToString(); area = kalpi["area"].ToString(); votersAmount = int.Parse(kalpi["votersAmount"].ToString()); maxVoters = int.Parse(kalpi["maxVoters"].ToString()); invalidAccess = Boolean.Parse(kalpi["invalidAccess"].ToString()); mode = Boolean.Parse(kalpi["mode"].ToString()); }
public string UpdateVoterDetails(string Id, string fname, string lName, string addres, string area, string city, string tell) { sqlConnection p1 = sqlConnection.Instance; //sql conection p1.sqlCommand("UpdateVoterDetails"); //sql Procedure p1.InsertValstring("@Id", Id); //sending parameters p1.InsertValstring("@fname", fname.Trim()); //sending parameters p1.InsertValstring("@lname", lName.Trim()); //sending parameters p1.InsertValstring("@address", addres.Trim()); //sending parameters p1.InsertValstring("@area", area.Trim()); //sending parameters p1.InsertValstring("@city", city.Trim()); //sending parameters p1.InsertValstring("@tell", tell.Trim()); //sending parameters return(p1.getVal("@Result").ToString()); // p1.NonQueryE(); //Updating }
//Update worker to Commissioner public string DeleteWorker(Voter worker) { try { sqlConnection con = sqlConnection.Instance; con.sqlCommand("RemoveWorker"); con.InsertValstring("@id", worker.Id); string value = con.getVal("@Result"); return(value); } catch { return("Data Base id Filed"); } }
//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); } }
public int countWhiteNots(KalpiManager kalpiManager) { try { int count = 0; sqlConnection con = sqlConnection.Instance; con.sqlCommand("getNumOfWhiteNotes"); con.InsertValstring("@kalpiCode", kalpiManager.KalpiCode); count = int.Parse(con.getVal("@Result")); return(count); } catch { return(0); } }
public string updateAreaManager(string id, string name, string lastname, string username, string password, DateTime birthDay, string addres, string area, string city, string tell) { sqlConnection con = sqlConnection.Instance; con.sqlCommand("updateAreaManager"); con.InsertValstring("@idVoter", id); con.InsertValstring("@name", name); con.InsertValstring("@lastname", lastname); con.InsertValstring("@username", username); con.InsertValstring("@password", password); con.InsertValDate("@birthDay", birthDay); con.InsertValstring("@address", addres); con.InsertValstring("@area", area); con.InsertValstring("@city", city); con.InsertValstring("@tell", tell); return(con.getVal("@Result")); }
/// <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); }
//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!"); } }