private void deleteBtn_Click(object sender, EventArgs e)
        {
            if (categoryDataGrid.RowCount != 0)
            {
                int selectedIndex = categoryDataGrid.CurrentCell.RowIndex;
                if (selectedIndex > -1)
                {
                    string catId   = categoryDataGrid.Rows[selectedIndex].Cells[0].Value.ToString();
                    string catName = categoryDataGrid.Rows[selectedIndex].Cells[1].Value.ToString();
                    string catDesc = categoryDataGrid.Rows[selectedIndex].Cells[2].Value.ToString();

                    itemCategory selectedCategory = new itemCategory(int.Parse(catId), catName, catDesc);

                    stockDataManipulations stockDataManipulations = new stockDataManipulations();
                    Boolean categoryDeletion = stockDataManipulations.deleteCategory(selectedCategory);

                    if (categoryDeletion)
                    {
                        MessageBox.Show("Deletion Successfull. Data deleted successfully", "Important Note",
                                        MessageBoxButtons.OK);
                    }
                    else
                    {
                        MessageBox.Show("Deletion Failed. Error occured while deleting data", "Important Note",
                                        MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    }
                }
            }
        }
        public int insertCatagory(itemCategory tempCat)
        {
            int result = 1;

            try
            {
                using (SqlConnection con = new SqlConnection(conString))
                {
                    if (con.State == ConnectionState.Closed)
                    {
                        con.Open();
                    }
                    SqlCommand cmd = new SqlCommand("InsertCatagory", con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    //cmd.Parameters.AddWithValue("@prod_Cat_Id", tempCat.ItemCatID);
                    cmd.Parameters.AddWithValue("@prod_Cat_Name", tempCat.Item_Category_Name);
                    cmd.Parameters.AddWithValue("@prod_Cat_Description", tempCat.Item_Category_Description);
                    cmd.ExecuteScalar();
                    if (con.State == ConnectionState.Open)
                    {
                        con.Close();
                    }
                }
            }
            catch (Exception e)
            {
                logger.Error("DAL Error in insertCatagory: " + e.Message);
                //Console.WriteLine("DAL Error in insertCatagory: " + e.Message);
                result = 0;
            }
            return(result);
        }
Пример #3
0
        private void btnAddCatagory_Click(object sender, EventArgs e)
        {
            String catName = ((txtCatName.Text).Replace(" ", string.Empty)).Clone().ToString();

            if (catName == "")
            {
                catnameVerify.Show();
                hideLabelsTimer();
            }
            else
            {
                String itmCatName = (txtCatName.Text).Clone().ToString();
                String itmCatDesc = (txtCatDsc.Text).Clone().ToString();

                itemCategory           itemCat = new itemCategory(-1, itmCatName, itmCatDesc);
                stockDataManipulations stockDataManipulations = new stockDataManipulations();
                Boolean catInsertion = stockDataManipulations.addNewItemCat(itemCat);
                if (catInsertion)
                {
                    MessageBox.Show("Insertion Successfull. Data saved successfully", "Important Note",
                                    MessageBoxButtons.OK);
                    clearForm();
                }
                else
                {
                    MessageBox.Show("Insertion Failed.Check the insert data again", "Important Note",
                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                }
            }
        }
        private void deleteBtn_Click(object sender, EventArgs e)
        {
            int selectedIndex = productsDataGrid.CurrentCell.RowIndex;

            if (selectedIndex > -1)
            {
                string       productId          = productsDataGrid.Rows[selectedIndex].Cells[0].Value.ToString();
                string       productCode        = productsDataGrid.Rows[selectedIndex].Cells[1].Value.ToString();
                string       productName        = productsDataGrid.Rows[selectedIndex].Cells[2].Value.ToString();
                string       productMake        = productsDataGrid.Rows[selectedIndex].Cells[3].Value.ToString();
                string       productModel       = productsDataGrid.Rows[selectedIndex].Cells[4].Value.ToString();
                string       productDescription = productsDataGrid.Rows[selectedIndex].Cells[5].Value.ToString();
                string       productPrice       = productsDataGrid.Rows[selectedIndex].Cells[7].Value.ToString();
                string       quantity           = productsDataGrid.Rows[selectedIndex].Cells[8].Value.ToString();
                itemCategory itemCat            = (itemCategory)productsDataGrid.Rows[selectedIndex].Cells[9].Value;


                products selectedProduct = new products(int.Parse(productId), productCode, productName, productMake, productModel,
                                                        productDescription, decimal.Parse(productPrice), itemCat, int.Parse(quantity));

                stockDataManipulations stockDataManipulations = new stockDataManipulations();
                Boolean stockDeletion = stockDataManipulations.deleteProduct(selectedProduct);

                if (stockDeletion)
                {
                    MessageBox.Show("Deletion Successfull. Data deleted successfully", "Important Note",
                                    MessageBoxButtons.OK);
                }
                else
                {
                    MessageBox.Show("Deletion Failed. Error occured while deleting data", "Important Note",
                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                }
            }
        }
Пример #5
0
        public IActionResult Index()
        {
            itemCategory itemCategory = new itemCategory();

            itemCategory.Name = "لحوم";
            //service.(itemCategory);
            return(View());
        }
Пример #6
0
 public itemLimit(string name, string displayName, int maxCount, itemCategory category, itemPermision[] permissions, string imageURL, int price = 0)
 {
     this.maxCount    = maxCount;
     this.permissions = permissions;
     this.displayName = displayName;
     this.name        = name;
     this.category    = category;
     this.imageURL    = imageURL;
     this.price       = price;
 }
        public Boolean addNewItemCat(itemCategory itemCat)
        {
            CatagoryDataAccess cda1 = new CatagoryDataAccess();
            int insertResult        = cda1.insertCatagory(itemCat);

            if (insertResult.Equals(1))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #8
0
        public List <products> getAllProducts()
        {
            List <products> productLst = new List <products>();

            try
            {
                using (SqlConnection con = new SqlConnection(conString))
                {
                    if (con.State == ConnectionState.Closed)
                    {
                        con.Open();
                    }
                    SqlCommand cmd = new SqlCommand("GetALLProducts", con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    using (SqlDataReader rdr = cmd.ExecuteReader())
                    {
                        while (rdr.Read())
                        {
                            products tmpProd = new products();
                            tmpProd.ProductID          = (int)rdr["pId"];
                            tmpProd.ProductCode        = (String)rdr["pCode"];
                            tmpProd.ProductName        = (String)rdr["pName"];
                            tmpProd.ProductMake        = (String)rdr["pMake"];
                            tmpProd.ProductModel       = (String)rdr["pModel"];
                            tmpProd.ProductDescription = (String)rdr["pDsc"];
                            tmpProd.ProductPrice       = (Decimal)rdr["pPrice"];
                            tmpProd.Quantity           = (Int32)rdr["prdQty"];
                            itemCategory tmpItmCat = new itemCategory();
                            tmpItmCat.Item_Category_ID          = (int)rdr["pcatID"];
                            tmpItmCat.Item_Category_Name        = (String)rdr["pcatName"];
                            tmpItmCat.Item_Category_Description = (String)rdr["pcatDsc"];
                            tmpProd.ProductCateogery            = tmpItmCat;
                            productLst.Add(tmpProd);
                        }
                    }

                    if (con.State == ConnectionState.Open)
                    {
                        con.Close();
                    }
                }
            }
            catch (Exception e)
            {
                logger.Error("DAL Error in getAllProducts: " + e.Message);
                //Console.WriteLine("DAL Error in getAllProducts: " + e.Message);
            }
            return(productLst);
        }
        private void categoryDataBindings()
        {
            stockDataManipulations            stockDataManipulation = new stockDataManipulations();
            List <itemCategory>               categories            = stockDataManipulation.getAllCategories();
            Dictionary <itemCategory, string> productCategory       = new Dictionary <itemCategory, string>();
            itemCategory defCategory = new itemCategory(-1, "Default", null);

            productCategory.Add(defCategory, defCategory.Item_Category_Name);
            foreach (itemCategory category in categories)
            {
                productCategory.Add(category, category.Item_Category_Name);
            }
            combProCat.DataSource    = new BindingSource(productCategory, null);
            combProCat.DisplayMember = "Value";
            combProCat.ValueMember   = "Key";
        }
        public itemCategory getCatByID(int prod_Cat_Id)
        {
            itemCategory tmpCat = new itemCategory();

            try
            {
                using (SqlConnection con = new SqlConnection(conString))
                {
                    if (con.State == ConnectionState.Closed)
                    {
                        con.Open();
                    }
                    SqlCommand cmd = new SqlCommand("GetCatagoryById", con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@prod_Cat_Id", prod_Cat_Id);

                    using (SqlDataReader rdr = cmd.ExecuteReader())
                    {
                        while (rdr.Read())
                        {
                            if (!rdr[0].ToString().Equals("0"))
                            {
                                tmpCat.Item_Category_ID          = (int)rdr["prod_Cat_Id"];
                                tmpCat.Item_Category_Name        = (String)rdr["prod_Cat_Name"];
                                tmpCat.Item_Category_Description = (String)rdr["prod_Cat_Description"];
                            }
                        }
                    }
                    if (con.State == ConnectionState.Open)
                    {
                        con.Close();
                    }
                }
            }
            catch (Exception e)
            {
                logger.Error("DAL Error in getCatByID:" + e.ToString());
                //Console.WriteLine("DAL Error in getCatByID:" + e.ToString());
            }
            return(tmpCat);
        }
        public List <itemCategory> getAllCatagories()
        {
            List <itemCategory> catagoryLst = new List <itemCategory>();

            try
            {
                using (SqlConnection con = new SqlConnection(conString))
                {
                    if (con.State == ConnectionState.Closed)
                    {
                        con.Open();
                    }
                    SqlCommand cmd = new SqlCommand("GetALLCatagories", con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    using (SqlDataReader rdr = cmd.ExecuteReader())
                    {
                        while (rdr.Read())
                        {
                            itemCategory tmpCat = new itemCategory();
                            tmpCat.Item_Category_ID          = (int)rdr["prod_Cat_Id"];
                            tmpCat.Item_Category_Name        = (String)rdr["prod_Cat_Name"];
                            tmpCat.Item_Category_Description = (String)rdr["prod_Cat_Description"];
                            catagoryLst.Add(tmpCat);
                        }
                    }

                    if (con.State == ConnectionState.Open)
                    {
                        con.Close();
                    }
                }
            }
            catch (Exception e)
            {
                logger.Error("DAL Error in getAllCatagories: " + e.Message);
                //Console.WriteLine("DAL Error in getAllCatagories: " + e.Message);
            }
            return(catagoryLst);
        }
        private void updateBtn_Click(object sender, EventArgs e)
        {
            int selectedIndex = productsDataGrid.CurrentCell.RowIndex;

            if (selectedIndex > -1)
            {
                string       productId          = productsDataGrid.Rows[selectedIndex].Cells[0].Value.ToString();
                string       productCode        = productsDataGrid.Rows[selectedIndex].Cells[1].Value.ToString();
                string       productName        = productsDataGrid.Rows[selectedIndex].Cells[2].Value.ToString();
                string       productMake        = productsDataGrid.Rows[selectedIndex].Cells[3].Value.ToString();
                string       productModel       = productsDataGrid.Rows[selectedIndex].Cells[4].Value.ToString();
                string       productDescription = productsDataGrid.Rows[selectedIndex].Cells[5].Value.ToString();
                string       productPrice       = productsDataGrid.Rows[selectedIndex].Cells[7].Value.ToString();
                string       quantity           = productsDataGrid.Rows[selectedIndex].Cells[8].Value.ToString();
                itemCategory itemCat            = (itemCategory)productsDataGrid.Rows[selectedIndex].Cells[9].Value;


                products selectedProduct = new products(int.Parse(productId), productCode, productName, productMake, productModel,
                                                        productDescription, decimal.Parse(productPrice), itemCat, int.Parse(quantity));

                editProducts editProduct = new editProducts(selectedProduct, this);
                editProduct.Show();
            }
        }
        private void btnUpdateProduct_Click(object sender, EventArgs e)
        {
            String       pCode     = ((txtProductCode.Text).Replace(" ", string.Empty)).Clone().ToString();
            String       pName     = ((txtProductName.Text).Replace(" ", string.Empty)).Clone().ToString();
            String       pPrice    = ((txtProductPrc.Text).Replace(" ", string.Empty)).Clone().ToString();
            String       quantity  = ((txtPrdQty.Text).Replace(" ", string.Empty)).Clone().ToString();
            itemCategory pCategory = ((KeyValuePair <itemCategory, string>)combProCat.SelectedItem).Key;

            if (pCode == "")
            {
                pcodeVerify.Show();
                hideLabelsTimer();
            }
            else if (pName == "")
            {
                pnameVerify.Show();
                hideLabelsTimer();
            }
            else if (pPrice == "")
            {
                ppriceVerify.Show();
                hideLabelsTimer();
            }
            else if (quantity == "")
            {
                ppriceVerify.Show();
                hideLabelsTimer();
            }
            else if (pCategory.Item_Category_Name == "Default")
            {
                cmbCatVerify.Show();
                hideLabelsTimer();
            }
            else
            {
                string       productCode        = txtProductCode.Text;
                string       productName        = txtProductName.Text;
                string       productMake        = txtProductMake.Text;
                string       productModel       = txtProductModel.Text;
                string       productDescription = txtProductDesc.Text;
                string       productPrice       = txtProductPrc.Text;
                int          qty     = (int)txtPrdQty.Value;
                itemCategory itemCat = ((KeyValuePair <itemCategory, string>)combProCat.SelectedItem).Key;


                products product1 = new products(product.ProductID, productCode, productName, productMake, productModel,
                                                 productDescription, decimal.Parse(productPrice), itemCat, qty);

                stockDataManipulations stockDataManipulations = new stockDataManipulations();
                Boolean stockDeletion = stockDataManipulations.updateProduct(product1);

                if (stockDeletion)
                {
                    MessageBox.Show("Update Successfull. Data updated successfully", "Important Note",
                                    MessageBoxButtons.OK);
                    currentView.updateDataTableData();
                    this.Dispose();
                }
                else
                {
                    MessageBox.Show("Update Failed. Error occured while Updating data", "Important Note",
                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                }
            }
        }
        public Boolean deleteCategory(itemCategory catItem)
        {
            CatagoryDataAccess cda1 = new CatagoryDataAccess();

            return(cda1.DeleteCatagory(catItem.Item_Category_ID));
        }
        private void btnAddProduct_Click(object sender, EventArgs e)
        {
            String       pCode     = ((txtProductCode.Text).Replace(" ", string.Empty)).Clone().ToString();
            String       pName     = ((txtProductName.Text).Replace(" ", string.Empty)).Clone().ToString();
            String       pPrice    = ((txtProductPrc.Text).Replace(" ", string.Empty)).Clone().ToString();
            String       quantity  = ((txtPrdQty.Text).Replace(" ", string.Empty)).Clone().ToString();
            itemCategory pCategory = ((KeyValuePair <itemCategory, string>)combProCat.SelectedItem).Key;

            if (pCode == "")
            {
                pcodeVerify.Show();
                hideLabelsTimer();
            }
            else if (pName == "")
            {
                pnameVerify.Show();
                hideLabelsTimer();
            }
            else if (pPrice == "")
            {
                ppriceVerify.Show();
                hideLabelsTimer();
            }
            else if (quantity == "")
            {
                ppriceVerify.Show();
                hideLabelsTimer();
            }
            else if (pCategory.Item_Category_Name == "Default")
            {
                cmbCatVerify.Show();
                hideLabelsTimer();
            }
            else
            {
                String       proCode          = (txtProductCode.Text).Clone().ToString();
                String       proName          = (txtProductName.Text).Clone().ToString();
                String       proMake          = (txtProductMake.Text).Clone().ToString();
                String       proModel         = (txtProductModel.Text).Clone().ToString();
                String       proDescription   = (txtProductDesc.Text).Clone().ToString();
                String       proPrice         = (txtProductPrc.Text).Clone().ToString();
                String       proQuantity      = (txtPrdQty.Text).Clone().ToString();
                decimal      convProdPrice    = decimal.Parse(proPrice);
                int          convProdQuantity = int.Parse(proQuantity);
                itemCategory psCategory       = ((KeyValuePair <itemCategory, string>)combProCat.SelectedItem).Key;
                Console.WriteLine("pcat ID: " + psCategory.Item_Category_ID);
                products newProduct = new products(-1, proCode, proName, proMake, proModel, proDescription,
                                                   convProdPrice, psCategory, convProdQuantity);

                stockDataManipulations stockDataManipulations = new stockDataManipulations();
                Boolean productInsertionFlag = stockDataManipulations.addNewProduct(newProduct);
                if (productInsertionFlag)
                {
                    MessageBox.Show("Insertion Successfull. Data saved successfully", "Important Note",
                                    MessageBoxButtons.OK);
                    clearForm();
                }
                else
                {
                    MessageBox.Show("Insertion Failed.Check the insert data again", "Important Note",
                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                }
            }
        }