Example #1
0
        private void BTN_Delete_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Are You sure want you to delete?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dialogResult == DialogResult.Yes)
            {
                if (dgv_StockView.SelectedRows.Count > 0)
                {
                    ConnectionClass con = new ConnectionClass();
                    con.OpenCon();
                    string stockNumber = dgv_StockView.CurrentRow.Cells[0].Value.ToString();
                    if (IfProductExists(con.Connection, stockNumber))
                    {
                        con.OpenCon();
                        string     sqlQuery = @"DELETE FROM [dbo].[Stocks] WHERE [Stock_Number] = '" + Convert.ToInt32(stockNumber) + "'";
                        SqlCommand cmd      = new(sqlQuery, con.Connection);
                        cmd.ExecuteNonQuery();
                        con.CloseCon();
                        FRM_Products.Show_MSG(LBL_StockMSG, "Record deleted", Color.Green);
                    }
                    else
                    {
                        FRM_Products.Show_MSG(LBL_StockMSG, "Error!", Color.Red);
                    }
                    LoadData();
                }
            }
        }
Example #2
0
        private void BTN_edit_Click(object sender, EventArgs e)
        {
            ConnectionClass con = new ConnectionClass();

            con.OpenCon();
            bool status;

            if (CBX_ProductStatus.SelectedIndex == 0)
            {
                status = true;
            }
            else
            {
                status = false;
            }

            if (FRM_Products.IfProductExists(con.Connection, TXT_ProductCode.Text))
            {
                string sqlQuery = @"UPDATE [dbo].[Products] SET [Product_Name] = '" + TXT_ProductName.Text + "',[Product_Status] = '" + status + "' " +
                                  "WHERE [Product_ID] = '" + TXT_ProductCode.Text + "'";
                FRM_Products.Show_MSG(LBL_AddMSG, "Porduct updated", Color.Green);

                SqlCommand cmd = new(sqlQuery, con.Connection);
                cmd.ExecuteNonQuery();
                con.CloseCon();
            }
            else
            {
                FRM_Products.Show_MSG(LBL_AddMSG, "Error", Color.Red);
            }
        }
Example #3
0
 private void BTN_Add_Click(object sender, EventArgs e)
 {
     if (Validation())
     {
         ConnectionClass con = new ConnectionClass();
         con.OpenCon();
         string     sqlQuery = @"INSERT INTO Stocks (Product_ID, Transaction_Date, Quantity)
                         VALUES ('" + CBX_ProductCode.Text + "', GETDATE(),'" + TXT_StockQuantity.Text + "')";
         SqlCommand cmd      = new SqlCommand(sqlQuery, con.Connection);
         cmd.ExecuteNonQuery();
         con.CloseCon();
         FRM_Products.Show_MSG(LBL_AddMSG, "Stock added", Color.Green);
     }
 }
Example #4
0
        private void BTN_add_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(TXT_OrderNumber.Text))
            {
                FRM_Products.Show_MSG(LBL_AddMSG, "Insert order number", Color.Red);
            }
            else
            {
                selectedStockNumber.Clear();
                quantityList.Clear();
                productList.Clear();

                foreach (DataGridViewRow rows in dgv_ProductView.Rows)
                {
                    if (Convert.ToBoolean(rows.Cells["clm_Select"].Value))
                    {
                        selectedStockNumber.Add(Convert.ToInt32(rows.Cells["clm_StockNumber"].Value));
                        quantityList.Add(Convert.ToInt32(rows.Cells["clm_Quantity"].Value));
                        productList.Add(Convert.ToInt32(rows.Cells["clm_ProductCode"].Value));
                    }
                }
                ConnectionClass con = new ConnectionClass();
                con.OpenCon();
                int i = 0;
                foreach (var item in selectedStockNumber)
                {
                    string     sqlQuery = @"INSERT INTO Orders (Order_Nu, Product_ID, Quantity, Stock_Number) VALUES ('" + TXT_OrderNumber.Text + "','" + productList[i] + "', '" + quantityList[i] + "','" + item + "') ";
                    SqlCommand cmd      = new SqlCommand(sqlQuery, con.Connection);
                    cmd.ExecuteNonQuery();
                    i++;
                }
                int n = 0;
                foreach (var item in selectedStockNumber)
                {
                    string     sqlQuery = @"UPDATE [dbo].[Stocks] SET Quantity = Quantity - '" + quantityList[n] + "' WHERE Stock_Number = '" + selectedStockNumber[n] + "'";
                    SqlCommand cmd      = new SqlCommand(sqlQuery, con.Connection);
                    cmd.ExecuteNonQuery();
                    n++;
                }
                FRM_Products.Show_MSG(LBL_AddMSG, "Order added", Color.Green);
                con.CloseCon();
            }
        }
Example #5
0
        private void BTN_Add_Click(object sender, EventArgs e)
        {
            string ProductCode   = TXT_ProductCode.Text;
            string ProductName   = TXT_ProductName.Text;
            int    ProductStatus = CBX_ProductStatus.SelectedIndex;

            if (FRM_Products.Validation(ERP_ProductAdd, ProductCode, ProductName, ProductStatus, TXT_ProductCode, TXT_ProductName, CBX_ProductStatus))
            {
                ConnectionClass con = new ConnectionClass();
                con.OpenCon();
                bool status;
                if (CBX_ProductStatus.SelectedIndex == 0)
                {
                    status = true;
                }
                else
                {
                    status = false;
                }
                if (FRM_Products.IfProductExists(con.Connection, TXT_ProductCode.Text))
                {
                    FRM_Products.Show_MSG(LBL_AddMSG, "Product with this code already exists", Color.OrangeRed);
                }
                else
                {
                    string     sqlQuery = @"INSERT INTO [dbo].[Products]
                                ([Product_ID],
                                [Product_Name],
                                [Product_Status])
                                VALUES
                                ('" + TXT_ProductCode.Text + "','" + TXT_ProductName.Text + "','" + status + "')";
                    SqlCommand cmd      = new(sqlQuery, con.Connection);
                    cmd.ExecuteNonQuery();
                    con.CloseCon();
                    FRM_Products.Show_MSG(LBL_AddMSG, "Product added to list", Color.LightGreen);
                }
            }
        }
Example #6
0
 private void BTN_Refresh_Click(object sender, EventArgs e)
 {
     LoadData();
     FRM_Products.Show_MSG(LBL_StockMSG, "Done!", Color.Green);
 }
Example #7
0
 public void BTN_Reset_Click(object sender, EventArgs e)
 {
     FRM_Products.ResetRecords(TXT_ProductCode, TXT_ProductName, CBX_ProductStatus);
 }