Exemple #1
0
        public void fillStockIDComboBox()
        {
            MySqlConnection conn = Connection.getConnection();

            try
            {
                conn.Open();
                MySqlCommand    command    = new MySqlCommand("SELECT * FROM shophope.stocks", conn);
                MySqlDataReader dataReader = command.ExecuteReader();
                while (dataReader.Read())
                {
                    string s = dataReader.GetString("stockID");
                    stockIDComboBox.Items.Add(s);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("error occured at stock manager");
            }
            finally {
                conn.Close();
            }
        }
Exemple #2
0
        private void returnWeightComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            MySqlConnection conn = Connection.getConnection();

            try
            {
                conn.Open();
                MySqlCommand    command    = new MySqlCommand("SELECT * FROM shophope.stocks WHERE catagory ='" + returnCatagoryComboBox.Text + "' and brand ='" + returnBrandComboBox.Text + "' and name = '" + returnNameComboBox.Text + "' and weight = '" + returnWeightComboBox.Text + "'", conn);
                MySqlDataReader dataReader = command.ExecuteReader();
                while (dataReader.Read())
                {
                    returnedId = dataReader.GetString("stockID");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("error occured at stock manager weight combo");
            }
            finally
            {
                conn.Close();
            }
        }
Exemple #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            MySqlConnection conn = Connection.getConnection();

            try
            {
                conn.Open();
                MySqlCommand command;
                if (stockIDComboBox.Text.Length > 0)
                {
                    command = new MySqlCommand("SELECT * FROM shophope.stocks WHERE stockID = '" + stockIDComboBox.Text + "'", conn);
                }
                else
                {
                    command = new MySqlCommand("SELECT * FROM shophope.stocks WHERE catagory = '" + catagoryComboBox.Text + "' and brand = '" + brandComboBox.Text + "' and name = '" + nameComboBox.Text + "' and weight = '" + weightComboBox.Text + "'", conn);
                }
                MySqlDataReader dataReader = command.ExecuteReader();
                bool            flag       = false;
                while (dataReader.Read())
                {
                    MessageBox.Show("Available stock quantity is " + dataReader.GetString("quantity"));
                    flag = true;
                }
                if (!flag)
                {
                    MessageBox.Show("No stocks available.");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("error occured at stock manager " + ex.Message);
            }
            finally
            {
                conn.Close();
            }
            conn = Connection.getConnection();
            string updatingString = "";

            try
            {
                conn.Open();
                MySqlCommand    command    = new MySqlCommand("SELECT * FROM shophope.system WHERE id = '1'", conn);
                MySqlDataReader dataReader = command.ExecuteReader();
                while (dataReader.Read())
                {
                    updatingString = dataReader.GetString("isStocksUpdating");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("error occured at stock manager");
            }
            finally
            {
                conn.Close();
            }
            if (updatingString.Equals("true"))
            {
                MessageBox.Show("Stocks are in updating mode.");
            }
        }
        private static void checkOfferClose()
        {
            MySqlConnection conn = Connection.getConnection();
            DateTime        date = DateTime.Today;

            try
            {
                conn.Open();
                MySqlCommand    command    = new MySqlCommand("SELECT * FROM shophope.stocks", conn);
                MySqlDataReader dataReader = command.ExecuteReader();
                while (dataReader.Read())
                {
                    if (dataReader.GetString("offerDate").Length == 0)
                    {
                        continue;
                    }
                    if (int.Parse(dataReader.GetString("offerDate")) < int.Parse(date.ToString("yyyyMMdd")))
                    {
                        string          id             = dataReader.GetString("stockId");
                        MySqlConnection conn1          = Connection.getConnection();
                        string          realPrice      = "";
                        string          realOfferPrice = "";
                        try
                        {
                            conn1.Open();
                            MySqlCommand    command1    = new MySqlCommand("SELECT * FROM shophope.stocks WHERE stockId = '" + id + "'", conn1);
                            MySqlDataReader dataReader1 = command1.ExecuteReader();
                            while (dataReader1.Read())
                            {
                                realPrice      = dataReader1.GetString("realPrice");
                                realOfferPrice = dataReader1.GetString("price");
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("error occured at stock manager " + ex.Message);
                        }
                        finally
                        {
                            conn1.Close();
                        }
                        conn1 = Connection.getConnection();
                        try
                        {
                            conn1.Open();
                            MySqlCommand    command1    = new MySqlCommand("UPDATE shophope.stocks SET price = '" + realPrice + "', offerDate = '' WHERE stockId = '" + id + "'", conn1);
                            MySqlDataReader dataReader1 = command1.ExecuteReader();
                            while (dataReader1.Read())
                            {
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("error occured at stock manager " + ex.Message);
                        }
                        finally
                        {
                            conn1.Close();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("error occured at stock manager " + ex.Message);
            }
            finally
            {
                conn.Close();
            }
        }
Exemple #5
0
        private void signUpSecondBtn_Click(object sender, EventArgs e)
        {
            if (!(nameTxt.Text.Length > 0 && IDTxt.Text.Length > 0 && PhoneNoTxt.Text.Length > 0 && mailTxt.Text.Length > 0 && ageTxt.Text.Length > 0 && confirmCodeTxt.Text.Length > 0))
            {
                MessageBox.Show("Please fill all boxes.");
                return;
            }
            MySqlConnection conn = Connection.getConnection();

            try
            {
                conn.Open();
                MySqlCommand    command    = new MySqlCommand("SELECT * FROM shophope.employeetable WHERE userId = '1'", conn);
                MySqlDataReader dataReader = command.ExecuteReader();
                while (dataReader.Read())
                {
                    if (!dataReader.GetString("passWord").Equals(confirmCodeTxt.Text))
                    {
                        MessageBox.Show("Confirmation code wrong!");
                        return;
                    }
                }
                conn.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine("error occured at stock manager    " + ex.Message);
            }
            finally {
                conn.Close();
            }

            lock (lockObject)
            {
                try
                {
                    conn = Connection.getConnection();
                    conn.Open();
                    MySqlCommand    command    = new MySqlCommand("SELECT * FROM shophope.employeetable WHERE userName = '******'", conn);
                    MySqlDataReader dataReader = command.ExecuteReader();
                    while (dataReader.Read())
                    {
                        MessageBox.Show("User name already exist");
                        return;
                    }
                    conn.Close();
                }
                catch (Exception ex)
                {
                    Console.WriteLine("error occured at stock manager    " + ex.Message);
                }
                finally
                {
                    conn.Close();
                }
                signUpPanel.Visible = false;
                if (salesManRadioBtn.Checked)
                {
                    SalesMan.getEmployee(nameTxt.Text, IDTxt.Text, mailTxt.Text, long.Parse(PhoneNoTxt.Text), int.Parse(ageTxt.Text), passwordSecondTxt.Text, "SalesMan");
                    userNameTxt.Text       = nameTxt.Text;
                    nameTxt.Text           = "";
                    IDTxt.Text             = "";
                    mailTxt.Text           = "";
                    PhoneNoTxt.Text        = "";
                    ageTxt.Text            = "";
                    passwordSecondTxt.Text = "";
                }
                else if (stockManagerRadioBtn.Checked)
                {
                    StockManager.getEmployee(nameTxt.Text, IDTxt.Text, mailTxt.Text, long.Parse(PhoneNoTxt.Text), int.Parse(ageTxt.Text), passwordSecondTxt.Text, "StockManager");
                    userNameTxt.Text       = nameTxt.Text;
                    nameTxt.Text           = "";
                    IDTxt.Text             = "";
                    mailTxt.Text           = "";
                    PhoneNoTxt.Text        = "";
                    ageTxt.Text            = "";
                    passwordSecondTxt.Text = "";
                }
                else
                {
                    Labour.getEmployee(nameTxt.Text, IDTxt.Text, mailTxt.Text, long.Parse(PhoneNoTxt.Text), int.Parse(ageTxt.Text), passwordSecondTxt.Text, "Labour");
                    userNameTxt.Text       = nameTxt.Text;
                    nameTxt.Text           = "";
                    IDTxt.Text             = "";
                    mailTxt.Text           = "";
                    PhoneNoTxt.Text        = "";
                    ageTxt.Text            = "";
                    passwordSecondTxt.Text = "";
                }
                signUpPanel.Visible = false;
            }
        }
Exemple #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            double          oldPrice  = 0;
            MySqlConnection conn      = Connection.getConnection();
            string          offerDate = "";
            bool            flag      = false;

            try
            {
                conn.Open();
                MySqlCommand    command    = new MySqlCommand("SELECT * FROM shophope.stocks WHERE stockID = '" + stockIDLbl.Text + "'", conn);
                MySqlDataReader dataReader = command.ExecuteReader();
                while (dataReader.Read())
                {
                    oldPrice  = double.Parse(dataReader.GetString("price"));
                    offerDate = dataReader.GetString("offerDate");
                    flag      = true;
                }
                conn.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine("error occured at stock manager change btn in stocks " + ex.Message);
            }
            finally
            {
                conn.Close();
            }
            if (!flag)
            {
                MessageBox.Show("Product Info Wrong");
                return;
            }
            if (offerDate.Length > 0)
            {
                Mediator.notifyManager("Offer deleted for stock " + stockIDLbl.Text);
            }
            if (!oldPrice.ToString().Equals(priceTxt.Text))
            {
                MessageBox.Show("Notified");
                Mediator.notifyManager("Stock " + nameComboBox.Text + " changed from " + oldPrice.ToString() + " to " + priceTxt.Text);
            }

            try
            {
                conn = Connection.getConnection();
                conn.Open();
                string temp = int.Parse(quantityTxt.Text).ToString();
                if (addQuantityTxt.Text.Length != 0)
                {
                    temp = (int.Parse(addQuantityTxt.Text) + int.Parse(quantityTxt.Text)).ToString();
                }
                MySqlCommand    command    = new MySqlCommand("UPDATE shophope.stocks SET price ='" + priceTxt.Text + "', realPrice ='" + priceTxt.Text + "', quantity = '" + temp + "',expirydate = '" + expieryTxt.Text + "',warningLevel='" + warningLevelTxt.Text + "',offerDate = '' WHERE stockID = '" + stockIDLbl.Text + "'", conn);
                MySqlDataReader dataReader = command.ExecuteReader();
                while (dataReader.Read())
                {
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("error occured at stock manager change btn " + ex.Message);
            }
            finally
            {
                conn.Close();
            }
        }
Exemple #7
0
        public static void checkEmployeesAsAbsent()
        {
            MySqlConnection conn                = Connection.getConnection();
            List <bool>     attandanceList      = new List <bool>();
            List <int>      attandanceCountList = new List <int>();
            List <int>      overTimeList        = new List <int>();
            List <int>      userIdList          = new List <int>();
            List <string>   leavesCountList     = new List <string>();

            try
            {
                conn.Open();
                MySqlCommand    command    = new MySqlCommand("SELECT * FROM shophope.employeetable", conn);
                MySqlDataReader dataReader = command.ExecuteReader();
                while (dataReader.Read())
                {
                    attandanceCountList.Add(int.Parse(dataReader.GetString("monthlyAttandance")));
                    userIdList.Add(int.Parse(dataReader.GetString("userId")));
                    overTimeList.Add(int.Parse(dataReader.GetString("todayOverTime")) + int.Parse(dataReader.GetString("overTime")));
                    leavesCountList.Add(dataReader.GetString("leavesPerMonth"));
                    if (dataReader.GetString("presence").Equals("t"))
                    {
                        attandanceList.Add(true);
                    }
                    else
                    {
                        attandanceList.Add(false);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("error occured at stock manager weight combo " + ex.Message);
            }
            finally
            {
                conn.Close();
            }
            for (int i = 0; i < attandanceList.Count; i++)
            {
                if (attandanceList[i])
                {
                    try
                    {
                        conn = Connection.getConnection();
                        conn.Open();
                        MySqlCommand    command    = new MySqlCommand("UPDATE shophope.employeetable SET monthlyAttandance = '" + (attandanceCountList[i] + 1).ToString() + "', overTime = '" + overTimeList[i].ToString() + "',todayOverTime = '0', presence = 'f' WHERE userId = '" + userIdList[i].ToString() + "'", conn);
                        MySqlDataReader dataReader = command.ExecuteReader();
                        while (dataReader.Read())
                        {
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("error occured at stock manager weight combo " + ex.Message);
                    }
                    finally
                    {
                        conn.Close();
                    }
                }
                else
                {
                    try
                    {
                        conn = Connection.getConnection();
                        conn.Open();
                        MySqlCommand    command    = new MySqlCommand("UPDATE shophope.employeetable SET leavesPerMonth = '" + (int.Parse(leavesCountList[i]) + 1).ToString() + "',todayOverTime = '0' WHERE userId = '" + userIdList[i].ToString() + "'", conn);
                        MySqlDataReader dataReader = command.ExecuteReader();
                        while (dataReader.Read())
                        {
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("error occured at stock manager weight combo " + ex.Message);
                    }
                    finally
                    {
                        conn.Close();
                    }
                }
            }
        }
Exemple #8
0
 private void createOfferBtn_Click(object sender, EventArgs e)
 {
     if (!price.Equals(priceTxt.Text))
     {
         string          oldPrice  = "";
         string          dateTime  = dateTimePicker1.Value.ToString("yyyyMMdd");
         string          offerDate = "";
         MySqlConnection conn      = Connection.getConnection();
         try
         {
             conn.Open();
             MySqlCommand    command    = new MySqlCommand("SELECT * FROM shophope.stocks WHERE catagory ='" + catagoryComboBox.Text + "' and brand ='" + brandComboBox.Text + "' and name = '" + nameComboBox.Text + "' and weight = '" + weightComboBox.Text + "'", conn);
             MySqlDataReader dataReader = command.ExecuteReader();
             while (dataReader.Read())
             {
                 oldPrice  = dataReader.GetString("price");
                 offerDate = dataReader.GetString("offerDate");
             }
             //MessageBox.Show("Offer Created...");
         }
         catch (Exception ex)
         {
             Console.WriteLine("error occured at stock manager weight combo " + ex.Message);
         }
         finally
         {
             conn.Close();
         }
         if (offerDate.Length > 0)
         {
             MessageBox.Show("Already an offer created");
             return;
         }
         conn = Connection.getConnection();
         try
         {
             conn.Open();
             MySqlCommand    command    = new MySqlCommand("UPDATE shophope.stocks SET price = '" + priceTxt.Text + "' , offerPrice = '" + oldPrice + "', offerDate = '" + dateTime + "' WHERE catagory ='" + catagoryComboBox.Text + "' and brand ='" + brandComboBox.Text + "' and name = '" + nameComboBox.Text + "' and weight = '" + weightComboBox.Text + "'", conn);
             MySqlDataReader dataReader = command.ExecuteReader();
             while (dataReader.Read())
             {
             }
             MessageBox.Show("Offer Created...");
         }
         catch (Exception ex)
         {
             Console.WriteLine("error occured at stock manager weight combo " + ex.Message);
         }
         finally
         {
             conn.Close();
         }
         dateTimePicker1.Enabled = false;
         brandComboBox.Text      = "";
         nameComboBox.Text       = "";
         weightComboBox.Text     = "";
         priceTxt.Text           = "";
         createOfferBtn.Enabled  = false;
         brandComboBox.Items.Clear();
         nameComboBox.Items.Clear();
         weightComboBox.Items.Clear();
     }
 }
Exemple #9
0
        private void notificationPanel_MouseClick(object sender, MouseEventArgs e)
        {
            performResetCountDown();
            lock (lockObject)
            {
                notificationCountLbl.Text = "";
                MySqlConnection conn = Connection.getConnection();
                for (int i = 0; i < notificationStringList.Count - 1; i++)
                {
                    //MessageBox.Show("notificatiion split: " + notificationStringList[i]);
                    if (notificationStringList[i].Length == 0)
                    {
                        continue;
                    }
                    if (notificationStringList[i].Substring(0, 1).Equals("/"))
                    {
                        DialogResult dialog = MessageBox.Show(notificationStringList[i].Substring(1), "", MessageBoxButtons.YesNo);
                        string       temp   = notificationStringList[i].Substring(7);

                        string quantity       = "";
                        string returnQuantity = "";

                        try
                        {
                            conn.Open();
                            MySqlCommand    command    = new MySqlCommand("SELECT * FROM shophope.stocks WHERE stockId = '" + getId(temp) + "'", conn);
                            MySqlDataReader dataReader = command.ExecuteReader();
                            while (dataReader.Read())
                            {
                                quantity       = dataReader.GetString("quantity");
                                returnQuantity = dataReader.GetString("returnQuantity");
                            }
                            conn.Close();
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("error occured at stock manager timer elapsed " + ex.Message);
                        }
                        finally
                        {
                            conn.Close();
                        }
                        if (dialog == DialogResult.Yes)
                        {
                            try
                            {
                                conn = Connection.getConnection();
                                conn.Open();
                                //MessageBox.Show(getQuantity(temp) + " " + returnQuantity);
                                MySqlCommand    command    = new MySqlCommand("UPDATE shophope.stocks SET returnQuantity = '" + (int.Parse(getQuantity(temp)) + int.Parse(returnQuantity)).ToString() + "' WHERE stockId = '" + getId(temp) + "'", conn);
                                MySqlDataReader dataReader = command.ExecuteReader();
                                while (dataReader.Read())
                                {
                                }
                            }

                            catch (Exception ex)
                            {
                                Console.WriteLine("error occured at stock manager timer elapsed " + ex.Message);
                            }
                            finally
                            {
                                conn.Close();
                            }
                        }
                        else
                        {
                            try
                            {
                                conn = Connection.getConnection();
                                conn.Open();
                                MySqlCommand    command    = new MySqlCommand("UPDATE shophope.stocks SET quantity = '" + (int.Parse(getQuantity(temp)) + int.Parse(quantity)).ToString() + "' WHERE stockId = '" + getId(temp) + "'", conn);
                                MySqlDataReader dataReader = command.ExecuteReader();
                                while (dataReader.Read())
                                {
                                }
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine("error occured at stock manager timer elapsed " + ex.Message);
                            }
                            finally
                            {
                                conn.Close();
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show(notificationStringList[i]);
                    }
                }
                notificationStringList.Clear();
                conn = Connection.getConnection();
                try
                {
                    conn.Open();
                    MySqlCommand command = new MySqlCommand("UPDATE shophope.employeetable SET notificationSpace= '' WHERE userId = 1", conn);
                    notificationString = "";
                    MySqlDataReader dataReader = command.ExecuteReader();
                    while (dataReader.Read())
                    {
                    }
                    conn.Close();
                }
                catch (Exception ex)
                {
                    Console.WriteLine("error occured at stock manager click " + ex.Message);
                }
                finally
                {
                    conn.Close();
                }
            }
        }