private void PopulateCBEditFoodID()
        {
            SQLiteDataReader reader = conn.ViewTable("Food");

            while (reader.Read())
            {
                Console.WriteLine($"{reader["id"].ToString()}, {reader["name"].ToString()}");
                int           id    = int.Parse(reader["id"].ToString());
                string        name  = (string)reader["name"];
                double        price = (double)reader["price"];
                string        desc  = (string)reader["desc"];
                string        image = (string)reader["img"];
                Main_Category main  = (Main_Category)Enum.Parse(typeof(Main_Category), reader["mainctgr"].ToString());
                Sub_Category  sub   = (Sub_Category)Enum.Parse(typeof(Sub_Category), reader["subctgr"].ToString());
                Food          food  = new Food
                {
                    Name        = name,
                    Price       = price,
                    Description = desc,
                    Img         = image,
                    MainCtgr    = main,
                    SubCtgr     = sub
                };

                lFood.Add(food);
                cbEditName.Items.Add(food.Name);
            }
            reader.Close();
        }
 private void bEdit_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         string        name  = cbEditName.Text;
         double        price = double.Parse(tbEditPrice.Text);
         string        desc  = tbEditDesc.Text;
         string        img   = TelemealPath(tbEditImage.Text);
         Main_Category main  = Main_Category.All;
         Sub_Category  sub   = (Sub_Category)Enum.Parse(typeof(Sub_Category), cbEditCategory.Text);
         Food          food  = new Food
         {
             Name        = name,
             Price       = price,
             Description = desc,
             Img         = img,
             MainCtgr    = main,
             SubCtgr     = sub
         };
         conn.UpdateFood(food);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
        // GET: Client
        public ActionResult ClientProducts(Main_Category maincat)

        {
            var query = from c in db.Products
                        where c.category_ID == maincat.category_ID
                        select c;

            return(View(query.ToList()));
        }
Exemple #4
0
        public ActionResult ProductDetailActionIndex(Main_Category model)
        {
            // Product p = db.Products.SingleOrDefault(g => g.category_ID == model.category_ID);
            var query = from c in db.Products
                        where c.category_ID == model.category_ID
                        select c;

            //  List<Product> a = db.Products.ToList();
            return(View(query.ToList()));
        }
Exemple #5
0
        public ActionResult ProductAction(ProductModel myProductModel)
        {
            Main_cat_Data = (Main_Category)Session["CategoryOBj"];
            ActionResult myAction = RedirectToAction("ProductDetailActionIndex", "ProductDetail", Main_cat_Data);
            Product      ProdData = new Product();

            try
            {
                if (SignUpModel.sharedInstance == null || Session["CategoryOBj"] == null)
                {
                    return(myAction);
                }
                Vendor_Data = SignUpModel.sharedInstance;

                ProdData.category_ID      = Main_cat_Data.category_ID;
                ProdData.product_Maker    = myProductModel.Product_Maker;
                ProdData.product_Name     = myProductModel.Product_Name;
                ProdData.vendor_ID        = Vendor_Data.Id;
                ProdData.product_Quantity = myProductModel.Product_Quantity;
                ProdData.product_Type     = Main_cat_Data.cat_Data;
                ProdData.product_Detail   = myProductModel.Product_Details;
                ProdData.is_Active        = true;
                ProdData.Is_Deleted       = false;
                ProdData.created_Date     = Convert.ToString(DateTime.Now);
                ProdData.Update_Date      = null;
                ProdData.Discounted_Prize = myProductModel.Product_Prize;
                ProdData.created_By       = Vendor_Data.Email;
                ProdData.Update_Date      = null;


                #region Save Image on Server


                string FileName  = Path.GetFileNameWithoutExtension(myProductModel.Image_new2.FileName);
                string Extension = Path.GetExtension(myProductModel.Image_new2.FileName);
                FileName       = FileName + DateTime.Now.ToString("yymmssff") + Extension;
                ProdData.image = "~/Pictures/" + FileName;

                FileName = Path.Combine(Server.MapPath("~/Pictures/"), FileName);
                myProductModel.Image_new2.SaveAs(FileName);
                #endregion
                DB.Products.Add(ProdData);
                DB.SaveChanges();
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }

            return(myAction);
        }
Exemple #6
0
        public ActionResult PhonesNTablets()
        {
            ActionResult myaction = RedirectToAction("ProductDetailActionIndex", "ProductDetail");
            string       Item     = "PhonesNTablets";

            try
            {
                Main_Category maincat = db.Main_Category.Single(w => w.cat_Data == Item);
                // var a = db.Main_Category.Where(w => w.Cat_Name.StartsWith(Elect)).ToList();

                if (maincat != null)
                {
                    Session["CategoryOBj"] = maincat;

                    if (SignUpModel.sharedInstance.UserType == null)
                    {
                        myaction = RedirectToAction("ClientProducts", "Client", maincat);
                    }
                    else
                    {
                        if (SignUpModel.sharedInstance.UserType == "Vendor")
                        {
                            myaction = RedirectToAction("ProductDetailActionIndex", "ProductDetail", maincat);
                        }
                        else
                        {
                            myaction = RedirectToAction("ClientProducts", "Client", maincat);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
            return(myaction);
        }
        private void bAddFoodItem_Click(object sender, RoutedEventArgs e)
        {
            Button        b     = sender as Button;
            string        fName = "";
            double        fPrice;
            string        fDesc = "";
            string        fImg  = "";
            Main_Category fMain = Main_Category.All;
            Sub_Category  fSub;

            try
            {
                if ((fName = tbAddName.Text) == "")
                {
                    throw new ArgumentNullException("Missing Name");
                }
                if (tbAddPrice.Text == "")
                {
                    throw new ArgumentNullException("Missing Price");
                }
                fPrice = double.Parse(tbAddPrice.Text);
                fDesc  = tbAddDesc.Text;
                fImg   = TelemealPath(tbAddImage.Text);
                if (cbAddCategory.Text == "")
                {
                    throw new ArgumentNullException("Missing Category");
                }
                fSub = (Sub_Category)Enum.Parse(typeof(Sub_Category), cbAddCategory.Text);

                Food food = new Food
                {
                    Name        = fName,
                    Price       = fPrice,
                    Description = fDesc,
                    Img         = fImg,
                    MainCtgr    = fMain,
                    SubCtgr     = fSub
                };
                conn.InsertFood(food);
                lFood.Add(food);

                tbAddName.Clear();
                tbAddImage.Clear();
                tbAddDesc.Clear();
                tbAddPrice.Clear();
                cbAddCategory.SelectedIndex = -1;

                cbEditName.Items.Add(food.Name);
            }
            catch (ArgumentNullException ex)
            {
                MessageBox.Show(ERROR_CODE_MRF + ex.ParamName);
            }
            catch (FormatException ex)
            {
                MessageBox.Show(ERROR_CODE_IDT);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }