Esempio n. 1
0
        private void removeSupplierBtn_Click(object sender, EventArgs e)
        {
            try
            {
                string query1 = "SELECT * FROM SUPPLIER WHERE supplier_id= '" + removeSupplierId.Text.ToString() + "' ";

                int count1 = DatabaseHandler.returnRowCountWithoutParams(query1);
                Console.WriteLine("Selected supplier " + removeSupplierId.Text.ToString());
                Console.WriteLine("Row count" + count1);
                if (count1 == 0)
                {
                    MessageBox.Show("Error! Supplier doesn't exist! ");
                    return;
                }
                string query = "DELETE FROM SUPPLIER WHERE supplier_id=@supplierCode";
                List <MySqlParameter> paramList = new List <MySqlParameter>();
                paramList.Clear();
                paramList.Add(new MySqlParameter("@supplierCode", removeSupplierId.Text));
                int rowsAffected = DatabaseHandler.insertOrDeleteRow(query, paramList);

                if (rowsAffected != 0)
                {
                    MessageBox.Show("Supplier Removed Successfully!");
                    populateGrid();
                }
                else
                {
                    MessageBox.Show("Error! The supplier may have unremoved items. Remove items first!");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Error! The supplier may have unremoved items. Remove items first!");
            }
        }
Esempio n. 2
0
        private void setproductlbl()
        {
            string querry = "SELECT * FROM item WHERE qty<50 ";
            int    count  = DatabaseHandler.returnRowCountWithoutParams(querry);

            products_lbl.Text = count.ToString();
        }
Esempio n. 3
0
        private void setmateriallbl()
        {
            string querry = "SELECT * FROM raw_material WHERE qty<10 ";
            int    count  = DatabaseHandler.returnRowCountWithoutParams(querry);

            material_lbl.Text = count.ToString();
        }
Esempio n. 4
0
        private void populate_item_order()
        {
            int pending  = DatabaseHandler.returnRowCountWithoutParams("SELECT * from itemorder WHERE approval='Pending'");
            int declined = DatabaseHandler.returnRowCountWithoutParams("SELECT * from itemorder WHERE approval='Declined'");

            itemOrder_lbl.Text      = pending.ToString();
            declinedOrders_lbl.Text = declined.ToString();
        }
Esempio n. 5
0
        private void addItemBtn_Click(object sender, EventArgs e)
        {
            string itemSupplierCode = itemSupplierCodeTxt.Text;
            string itemId           = itemIdTxt.Text;
            string itemName         = itemNameTxt.Text;
            string unitPrice        = unitPriceText.Text;
            string lead_time        = leadTime_txt.Text;

            if (String.IsNullOrEmpty(itemSupplierCode) || String.IsNullOrEmpty(itemId) || String.IsNullOrEmpty(itemName) || String.IsNullOrEmpty(unitPrice))
            {
                MessageBox.Show("One or more feilds are empty!");
            }
            else if (!String.IsNullOrEmpty(itemSupplierCode) && !String.IsNullOrEmpty(itemId) && !String.IsNullOrEmpty(itemName) && !String.IsNullOrEmpty(unitPrice))
            {
                if (DatabaseHandler.returnRowCountWithoutParams("SELECT * FROM raw_material where material_id='" + itemIdTxt.Text + "'") != 0)
                {
                    try
                    {
                        // MessageBox.Show("Such material exists, it will be added to the supplier mentioned");

                        string query = "INSERT INTO supplier_material(material_id,supplier_id,unit_price,lead_time) VALUES (@itemId,@itemSupplierCode,@unitPrice,@leadTime)";
                        List <MySqlParameter> paramList = new List <MySqlParameter>();
                        paramList.Add(new MySqlParameter("@itemSupplierCode", itemSupplierCode));
                        paramList.Add(new MySqlParameter("@itemId", itemId));
                        paramList.Add(new MySqlParameter("@unitPrice", unitPrice));
                        paramList.Add(new MySqlParameter("@leadTime", lead_time));

                        int rowsAffected = DatabaseHandler.insertOrDeleteRow(query, paramList);

                        if (rowsAffected != 0)
                        {
                            MessageBox.Show("Item Added Successfully!");
                            itemSupplierCodeTxt.Text = "";
                            itemIdTxt.Text           = "";
                            itemNameTxt.Text         = "";
                            unitPriceText.Text       = "";
                            leadTime_txt.Text        = "";
                            populateGrid();
                        }
                        else
                        {
                            MessageBox.Show("Error Occured! Please check the Info entered!");
                        }
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Error Occured! Please check if the Item already exists with the mentioned supplier!");
                    }
                }
                else
                {
                    MessageBox.Show("Error Occured! No such material exists!");
                }
            }
        }
Esempio n. 6
0
        private void addItemBtn_Click(object sender, EventArgs e)
        {
            string itemCode = addItemCodeTxt.Text;
            string itemQty  = addItemQty.Text;

            int i = dataGridView4.Rows.Count;

            for (int row = 0; row < i - 1; row++)
            {
                if (dataGridView4.Rows[row].Cells[0].Value.ToString() == itemCode)
                {
                    MessageBox.Show("Item already entered !!!");
                    return;
                }
            }
            List <MySqlParameter> paramList = new List <MySqlParameter>();

            paramList.Add(new MySqlParameter("@itemCode", itemCode));
            int returnedRowCount  = DatabaseHandler.returnRowCount("SELECT * FROM raw_material WHERE material_id = @itemCode", paramList);
            int returnedRowCount2 = DatabaseHandler.returnRowCountWithoutParams("SELECT * FROM supplier_material WHERE material_id='" + itemCode + "' AND supplier_id='" + selectedSupplier + "'");

            if (returnedRowCount != 0 && returnedRowCount2 != 0)
            {
                //Get Item Name from DB
                paramList.Clear();
                paramList.Add(new MySqlParameter("@itemCode", itemCode));
                string itemName  = DatabaseHandler.returnOneValue("SELECT name as 'Material Name' from raw_material where material_id=@itemCode", paramList, "Material Name");
                String unitPrice = DatabaseHandler.returnOneValueWithoutParams("SELECT unit_price as 'Material Price' from supplier_material where material_id='" + itemCode + "' AND supplier_id='" + selectedSupplier + "'", "Material Price");

                //Add to dataViewGrid4
                int index = dataGridView4.Rows.Count;
                dataGridView4.Rows.Add(itemCode, itemName, itemQty, unitPrice);
                Console.WriteLine("In Add Btn: Current Index: " + index);

                supplierComboBox.Enabled = false;
            }
            else if (returnedRowCount == 0)
            {
                MessageBox.Show("Invalid Item Code!");
            }
            else
            {
                MessageBox.Show("Selected supplier doesn't offer that item!");
            }
            Console.WriteLine("In Add Btn: Current Index2: " + dataGridView4.DisplayedRowCount(true));
        }
Esempio n. 7
0
 private void itemIdTxt_Leave(object sender, EventArgs e)
 {
     if (DatabaseHandler.returnRowCountWithoutParams("SELECT * FROM raw_material where material_id='" + itemIdTxt.Text + "'") != 0)
     {
         String matrialName;
         matrialName                = DatabaseHandler.returnOneValueWithoutParams("SELECT name FROM raw_material WHERE material_id='" + itemIdTxt.Text + "'", "name").ToString();
         itemNameTxt.Text           = matrialName;
         itemNameTxt.Enabled        = false;
         addNewMaterial_btn.Enabled = false;
         addItemBtn.Enabled         = true;
     }
     else
     {
         itemNameTxt.Enabled        = true;
         addNewMaterial_btn.Enabled = true;
         addItemBtn.Enabled         = false;
     }
 }
Esempio n. 8
0
        private void removeBtn_Click(object sender, EventArgs e)
        {
            if (removeUsername.Text == GlobalLoginData.username)
            {
                MessageBox.Show("Sorry, you cannot remove the account in use.");
                return;
            }
            else
            {
                try
                {
                    string query1 = "SELECT * FROM USER WHERE username= '******' ";

                    int count1 = DatabaseHandler.returnRowCountWithoutParams(query1);
                    Console.WriteLine("Selected user " + removeUsername.Text.ToString());
                    Console.WriteLine("Row count" + count1);
                    if (count1 == 0)
                    {
                        MessageBox.Show("Error! User doesn't exist! ");
                        return;
                    }
                    string query = "DELETE FROM USER WHERE username=@username";
                    List <MySqlParameter> paramList = new List <MySqlParameter>();
                    paramList.Clear();
                    paramList.Add(new MySqlParameter("@username", removeUsername.Text));
                    int rowsAffected = DatabaseHandler.insertOrDeleteRow(query, paramList);

                    if (rowsAffected != 0)
                    {
                        MessageBox.Show("User Removed Successfully!");
                        populateGrid();
                    }
                    else
                    {
                        MessageBox.Show("No such user found!");
                        return;
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("User has had interations with System! Cannot Remove!");
                }
            }
        }
        private void Add_btn_Click(object sender, EventArgs e)
        {
            string bomId;

            bomId = bomId_txt.Text;
            if (bomId == null)
            {
                MessageBox.Show("Invalid Selection!");
                return;
            }
            int rowcount = DatabaseHandler.returnRowCountWithoutParams("select id from material_dispatch where bom_id='" + bomId + "'");

            if (rowcount == 1)
            {
                MessageBox.Show("MATERIAL DISPATCH ORDER EXISTS FOR THE SELECTED BOM ID!!!");
                return;
            }
            else
            {
                string selectStatement = "SELECT bom_item.material_id as 'Material ID', bom_item.qty as 'Quantity', raw_material.name as 'Material Name' FROM raw_material INNER JOIN bom_item ON bom_item.material_id = raw_material.material_id WHERE bom_item.bom_id = '" + bomId + "' ";
                DatabaseHandler.populateGridViewWithBinding(selectStatement, dataGridView4);
            }
        }
Esempio n. 10
0
        private void RemoveBtn_Click(object sender, EventArgs e)
        {
            try
            {
                string query1 = "SELECT * FROM client WHERE client_id= '" + removeClient.Text.ToString() + "' ";

                int count1 = DatabaseHandler.returnRowCountWithoutParams(query1);
                Console.WriteLine("Selected client " + removeClient.Text.ToString());
                Console.WriteLine("Row count" + count1);
                if (count1 == 0)
                {
                    MessageBox.Show("Error! Client doesn't exist! ");
                    return;
                }
                string query = "DELETE FROM CLIENT WHERE client_id=@ClientCode";
                List <MySqlParameter> paramList = new List <MySqlParameter>();

                paramList.Add(new MySqlParameter("@clientCode", removeClient.Text.ToString()));

                int rowsAffected = DatabaseHandler.insertOrDeleteRow(query, paramList);
                paramList.Clear();

                if (rowsAffected != 0)
                {
                    MessageBox.Show("Client Removed Successfully!");
                    populateGrid();
                }
                else
                {
                    MessageBox.Show("Error! Client has already intracted with the system! Cannot remove!");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Error! Client has already intracted with the system! Cannot remove!");
            }
        }
Esempio n. 11
0
        private void fill_materialDispatch_order()
        {
            int pending = DatabaseHandler.returnRowCountWithoutParams("SELECT * from material_dispatch WHERE approval='Pending'");

            materialDispatch_lbl.Text = pending.ToString();
        }
Esempio n. 12
0
        private void fill_production_order()
        {
            int pending = DatabaseHandler.returnRowCountWithoutParams("SELECT * from productionorder WHERE approval='Pending'");

            productionOrder_lbl.Text = pending.ToString();
        }