public int isInVoteDB(string partyName, string kalpiCode)
 {
     con.sqlCommand("IsInVoteDB");
     con.InsertValstring("@partyName", partyName);
     con.InsertValstring("@kalpiCode", kalpiCode);
     return(int.Parse(con.getVal("Result").ToString()));
 }
        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() + "%";
        }
Beispiel #3
0
 /// <summary>
 /// The function updates the party details.
 /// </summary>
 /// <returns></returns> Returns if the update succseed or not
 public string UpdateParty()
 {
     con.sqlCommand("UpdatePartyDetails");
     con.InsertValstring("@partyName", PartyName.Trim());
     con.InsertValint("@member_size", membersSize);
     con.InsertValstring("@platform", platform.Trim());
     return(con.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
        }
        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
        }
Beispiel #6
0
        /// <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
        }
Beispiel #7
0
        /// <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
        }
Beispiel #8
0
        /// <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
        }
Beispiel #9
0
        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()));
        }
        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();
        }
        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());
            }
        }
        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!");
            }
        }
        /// <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!");
            }
        }
Beispiel #14
0
        //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"));
        }
Beispiel #15
0
        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
        }
Beispiel #16
0
        private string RemoveVoter(string id)
        {
            sqlConnection con = sqlConnection.Instance;

            con.sqlCommand("RemoveVoter");
            con.InsertValstring("@id", id);
            return(con.getVal("@result"));
        }
        public int CountMandate(string partyName)
        {
            con.sqlCommand("CountMandate");
            con.InsertValstring("@partyName", partyName);
            int res = int.Parse(con.getVal("Result").ToString());

            return(res / 3);
        }
        //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]);
        }
Beispiel #19
0
        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"));
        }
Beispiel #20
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]);
        }
Beispiel #21
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]);
        }
        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"));
        }
Beispiel #23
0
        /// <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);
        }
        //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");
            }
        }
Beispiel #25
0
        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");
            }
        }
Beispiel #26
0
        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);
            }
        }
 //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);
            }
        }
Beispiel #29
0
 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);
     }
 }
Beispiel #30
0
        /// <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);
        }