コード例 #1
0
        private void addItemBtn_Click(object sender, EventArgs e)
        {
            string itemCode = addItemCodeTxt.Text;
            string itemQty  = addItemQty.Text;

            List <MySqlParameter> paramList = new List <MySqlParameter>();

            paramList.Add(new MySqlParameter("@itemCode", itemCode));
            int returnedRowCount = DatabaseHandler.returnRowCount("SELECT*FROM STORE WHERE item_code=@itemCode", paramList);

            if (returnedRowCount != 0)
            {
                //Get Item Name from DB
                paramList.Clear();
                paramList.Add(new MySqlParameter("@itemCode", itemCode));
                string itemName = DatabaseHandler.returnOneValue("SELECT item_name as 'Item Name' from STORE where item_code=@itemCode", paramList, "Item Name");


                //Add to dataViewGrid4
                int index = dataGridView4.DisplayedRowCount(true);
                dataGridView4.Rows.Add();
                Console.WriteLine("In Add Btn: Current Index: " + index);
                dataGridView4.Rows[index - 1].Cells[0].Value = itemCode;
                dataGridView4.Rows[index - 1].Cells[1].Value = itemName;
                dataGridView4.Rows[index - 1].Cells[2].Value = itemQty;

                supplierComboBox.Enabled = false;
            }
            else
            {
                MessageBox.Show("Invalid Item Code!");
            }
        }
コード例 #2
0
        private void manualSubstractBtn_Click(object sender, EventArgs e)
        {
            List <MySqlParameter> paramList = new List <MySqlParameter>();

            paramList.Clear();
            paramList.Add(new MySqlParameter("@itemCode", manualProductId.Text));
            int returnedRowCount = DatabaseHandler.returnRowCount("SELECT * FROM STORE WHERE item_code = @itemCode", paramList);

            if (returnedRowCount == 1)
            {
                try
                {
                    List <MySqlParameter> paramList3 = new List <MySqlParameter>();
                    paramList3.Clear();
                    paramList3.Add(new MySqlParameter("@itemCode", manualProductId.Text));
                    paramList3.Add(new MySqlParameter("@value", manualQty.Text));
                    string queryGetQtyCondition = "SELECT IF(qty >= @value,'Yes','No') AS possibility FROM STORE WHERE item_code = @itemCode";
                    string possibility          = DatabaseHandler.returnOneValue(queryGetQtyCondition, paramList3, "possibility");
                    Console.WriteLine("String Possobility " + possibility);
                    if (string.Compare(possibility, "Yes") == 0)
                    {
                        Console.WriteLine("String Possobility Inside If ");
                        try
                        {
                            List <MySqlParameter> paramList2 = new List <MySqlParameter>();
                            paramList2.Clear();
                            paramList2.Add(new MySqlParameter("@itemQty", manualQty.Text));
                            paramList2.Add(new MySqlParameter("@itemCode", manualProductId.Text));
                            int responseChange = DatabaseHandler.insertOrDeleteRow("UPDATE STORE SET qty = qty - @itemQty WHERE item_code = @itemCode", paramList2);
                            if (responseChange == 1)
                            {
                                MessageBox.Show("Update Successful");
                            }
                            else
                            {
                                MessageBox.Show("Error Occured!");
                            }
                        }
                        catch (Exception)
                        {
                            MessageBox.Show("Error Occured!");
                        }
                    }
                }
                catch (Exception err)
                {
                    MessageBox.Show("Sorry, Invalid Item Code");
                }
            }
            else
            {
                MessageBox.Show("Sorry, Invalid Item Code");
            }
            populateGrid();
        }
コード例 #3
0
        private void manualAddBtn_Click(object sender, EventArgs e)
        {
            List <MySqlParameter> paramList = new List <MySqlParameter>();

            paramList.Clear();
            paramList.Add(new MySqlParameter("@itemCode", manualProductId.Text));
            int returnedRowCount = DatabaseHandler.returnRowCount("SELECT * FROM STORE WHERE item_code = @itemCode", paramList);

            if (returnedRowCount == 1)
            {
                try
                {
                    List <MySqlParameter> paramList2 = new List <MySqlParameter>();
                    paramList2.Clear();
                    paramList2.Add(new MySqlParameter("@itemQty", manualQty.Text));
                    paramList2.Add(new MySqlParameter("@itemCode", manualProductId.Text));
                    int responseChange = DatabaseHandler.insertOrDeleteRow("UPDATE STORE SET qty = qty + @itemQty WHERE item_code = @itemCode", paramList2);
                    if (responseChange == 1)
                    {
                        MessageBox.Show("Update Successful");
                    }
                    else
                    {
                        MessageBox.Show("Error Occured!");
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("Error Occured!");
                }
            }
            else
            {
                MessageBox.Show("Sorry, Invalid Item Code");
            }
            populateGrid();
        }
コード例 #4
0
        private void applyBtn_Click(object sender, EventArgs e)
        {
            string poNum = poNumTxt.Text;
            List <MySqlParameter> paramList = new List <MySqlParameter>();

            paramList.Add(new MySqlParameter("@poNum", poNum));
            paramList.Add(new MySqlParameter("@recieved", "No"));
            paramList.Add(new MySqlParameter("@approval", "Approved"));

            int returnedRowCount = DatabaseHandler.returnRowCount("SELECT*FROM purchaseorder WHERE po = @poNum AND recieved=@recieved AND approval=@approval", paramList);

            if (returnedRowCount == 1)
            {
                poNumTxt.Enabled = false;
                string select = "select supplier.supplier_name from purchaseorder inner join supplier on purchaseorder.supplier_code = supplier.supplier_code where purchaseorder.po ='" + poNum + "'";
                string returnedSupplierName = DatabaseHandler.returnOneValueWithoutParams(select, "supplier_name");
                supplierNameLbl.Text = returnedSupplierName;

                string query = "SELECT po_item.item_code as 'Item Code', STORE.item_name as 'Item', po_item.qty as 'Qty' FROM po_item INNER JOIN STORE ON po_item.item_code = STORE.item_code WHERE po_item.po = '" + poNum + "'";
                DatabaseHandler.populateGridViewWithBinding(query, dataGridView3);

                string selectedPo = "SELECT purchaseorder.po as 'Order #', supplier.supplier_name as 'Supplier', purchaseorder.creation_time as 'Order Creation Time', purchaseorder.postedUser as 'Posted By' FROM purchaseorder INNER JOIN supplier ON purchaseorder.supplier_code = supplier.supplier_code WHERE purchaseorder.approval = 'Approved' AND purchaseorder.po='" + poNum + "'";
                DatabaseHandler.populateGridViewWithBinding(selectedPo, dataGridView1);

                commitBtn.Enabled = true;
            }
            else
            {
                poNumTxt.Enabled = true;
                MessageBox.Show("No such uncommited Purchase Order or the Order may not be approved. Please Try again..");
                poNumTxt.Clear();
                dataGridView3.DataSource = null;
                dataGridView3.Refresh();

                supplierNameLbl.Text = "";
            }
        }
コード例 #5
0
        private void loginBtn_Click(object sender, EventArgs e)
        {
            List <MySqlParameter> paramList = new List <MySqlParameter>();

            paramList.Add(new MySqlParameter("@username", usernameTxt.Text));
            paramList.Add(new MySqlParameter("@password", passwordTxt.Text));
            int returnedRowCount = DatabaseHandler.returnRowCount("SELECT*FROM USER WHERE username=@username and password=@password", paramList);

            if (returnedRowCount == 1)
            {
                GlobalLoginData.username = usernameTxt.Text;
                paramList.Clear();
                paramList.Add(new MySqlParameter("@username", usernameTxt.Text));
                GlobalLoginData.userRole = DatabaseHandler.returnOneValue("SELECT role FROM USER WHERE username = @username", paramList, "role");

                this.Hide();
                Dashboard dash = new Dashboard();
                dash.Show();
            }
            else
            {
                MessageBox.Show("Invalid Credentials, Please Try Again!");
            }
        }