Ejemplo n.º 1
0
        /// <summary>
        /// 获取全部的产品
        /// </summary>
        /// <returns></returns>
        public List <Product_Table> GetProductTableAll()
        {
            List <Product_Table> list = new List <Product_Table>();
            SqlDataReader        dr   = DBHerlper.ExecuteReader(GetSqlString("Select"),
                                                                CommandType.StoredProcedure);

            while (dr.Read())
            {
                Product_Table obj = new Product_Table()
                {
                    E_id         = Convert.ToInt32(dr["E_id"]),
                    HP_id        = Convert.ToInt32(dr["HP_id"]),
                    NP_id        = Convert.ToInt32(dr["NP_id"]),
                    PT_id        = Convert.ToInt32(dr["PT_id"]),
                    P_Company    = dr["P_Company"].ToString(),
                    P_Date       = Convert.ToDateTime(dr["P_Date"]),
                    P_id         = Convert.ToInt32(dr["P_id"]),
                    P_Name       = dr["P_Name"].ToString(),
                    P_No         = dr["P_No"].ToString(),
                    P_Price      = Convert.ToDouble(dr["P_Price"]),
                    P_CoverImage = dr["P_CoverImage"].ToString(),
                    P_Introduce  = dr["P_Introduce"].ToString()
                };
                list.Add(obj);
            }
            dr.Close();
            return(list);
        }
Ejemplo n.º 2
0
        public void AddProduct(int ProductId, int Quntity, float SellingPrice, float Price1, string Price2)
        {
            Product_Table Obj = BussinessObj.Product_tb_search_by_ID(ProductId);

            if (Obj != null)
            {
                total = Quntity * SellingPrice;
                if (dataGridView1.RowCount == 0)
                {
                    RowID = dataGridView1.RowCount + 1;
                    row   = new string[] { (RowID++).ToString(), Obj.Category_Table.Catagory_Name, Obj.Product_Name, ExpirDate, ExpireOrNot, SellingPrice.ToString(), Price1.ToString(), Price2.ToString(), Quantity.Text, total.ToString(), ProductId.ToString() };
                    dataGridView1.Rows.Add(row);
                    if (!ProductNames.Contains(comboBox1.Text))
                    {
                        ProductNames.Add(comboBox1.Text);
                    }
                }
                else
                {
                    if (ProductNames.Contains(comboBox1.Text))
                    {
                        for (int i = 0; i < ProductNames.Capacity; i++)
                        {
                            if (ProductNames[i] == comboBox1.Text)
                            {
                                dataGridView1[5, (i)].Value = SellingPrice.ToString();
                                dataGridView1[6, (i)].Value = Price1.ToString();
                                dataGridView1[7, (i)].Value = Price2.ToString();
                                dataGridView1[8, (i)].Value = (int.Parse(dataGridView1[8, (i)].Value.ToString()) + Quntity).ToString();
                                dataGridView1[9, (i)].Value = (int.Parse(dataGridView1[8, (i)].Value.ToString()) * float.Parse(dataGridView1[5, (i)].Value.ToString())).ToString();
                                break;
                            }
                        }
                    }
                    else
                    {
                        RowID = dataGridView1.RowCount + 1;
                        row   = new string[] { (RowID++).ToString(), Obj.Category_Table.Catagory_Name, Obj.Product_Name, ExpirDate, ExpireOrNot, SellingPrice.ToString(), Price1.ToString(), Price2.ToString(), Quantity.Text, total.ToString(), ProductId.ToString() };
                        dataGridView1.Rows.Add(row);
                        if (!ProductNames.Contains(comboBox1.Text))
                        {
                            ProductNames.Add(comboBox1.Text);
                        }
                    }
                }
            }


            orderTotal = 0;
            for (int r = 0; r < dataGridView1.RowCount; r++)
            {
                orderTotal = orderTotal + float.Parse((dataGridView1[9, r].Value.ToString()));
            }
            textEdit6.Text = orderTotal.ToString();
            if (ValidationClass.ISDigit(Pauid.Text))
            {
                float Paid = float.Parse(Pauid.Text);
                Remin.Text = (orderTotal - Paid).ToString();
            }
        }
Ejemplo n.º 3
0
        public ActionResult order(int id)
        {
            Session["pro_id"] = id;
            List <Location_Table> location = new List <Location_Table>();

            location = db.Location_Table.ToList();
            var loclist = new List <SelectListItem>();

            foreach (var item in location)
            {
                loclist.Add(new SelectListItem
                {
                    Text  = item.LocationName.ToString(),
                    Value = item.LocationId.ToString(),
                });

                ViewBag.location_list = loclist;
            }

            Book          obj = new Book();
            Product_Table pro = db.Product_Table.Where(x => x.ProductId == id).FirstOrDefault();

            obj.ProductName    = pro.ProductName;
            obj.ProductDesc    = pro.ProductDesc;
            obj.ProductPrice   = pro.ProductPrice;
            obj.ProductStock   = pro.ProductStock;
            ViewBag.image_list = db.Image_Table.Where(x => x.Productid == id && x.ImageIsDeleted == false).ToList();
            return(View(obj));
        }
Ejemplo n.º 4
0
 public void check_stock()
 {
     try
     {
         int           flag    = 0;
         List <string> proname = new List <string>();
         string        name    = Session["user"].ToString();
         int           id      = db.User_Table.Where(x => x.UserName == name).Select(x => x.UserId).FirstOrDefault();
         List <int>    nlist   = db.Notify_table.Where(x => x.Userid == id && x.flag == 0).Select(x => x.Productid).ToList();
         foreach (int item in nlist)
         {
             Notify_table  nobj = db.Notify_table.Where(x => x.Userid == id && x.Productid == item).FirstOrDefault();
             Product_Table pobj = db.Product_Table.Where(x => x.ProductId == item).FirstOrDefault();
             if (pobj.ProductStock > 0)
             {
                 flag = 1;
                 proname.Add(pobj.ProductName);
                 //nobj.flag = 1;
                 db.SaveChanges();
             }
         }
         if (flag == 1)
         {
             ViewBag.stock_list = proname;
         }
         else
         {
             ViewBag.stock_list = null;
         }
     }
     catch
     {
         Response.Redirect("~/User/login");
     }
 }
        public ActionResult AddProduct(HttpPostedFileBase file, Product_Table prod)
        {
            string filename  = Path.GetFileName(file.FileName);
            string _filename = DateTime.Now.ToString("yymmssfff") + filename;
            string extension = Path.GetExtension(file.FileName);
            string path      = Path.Combine(Server.MapPath("~/ProductImage/"), _filename);

            prod.Image = "~/ProductImage/" + _filename;
            if (extension.ToLower() == ".jpg" || extension.ToLower() == ".jpeg" || extension.ToLower() == ".png")
            {
                if (file.ContentLength <= 1000000)
                {
                    obj.Product_Table.Add(prod);
                    if (obj.SaveChanges() > 0)
                    {
                        file.SaveAs(path);
                        ViewBag.msg = "Record added ";
                        ModelState.Clear();
                    }
                }
                else
                {
                    ViewBag.msg = "Sizeis In valid  ";
                }
            }
            return(RedirectToAction("ProductList"));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 根据输入的属性名称查询产品信息
        /// </summary>
        /// <param name="con"></param>
        /// <returns></returns>
        public Product_Table GetProductTableByConn(string tyepAttrName, string con)
        {
            Product_Table obj      = null;
            string        attrName = "@" + tyepAttrName;
            SqlDataReader dr       = DBHerlper.ExecuteReader(
                "Select * from Product_Table where " + tyepAttrName + "=" + attrName,
                CommandType.Text, new SqlParameter[] {
                new SqlParameter(attrName, con)
            });

            if (dr.Read())
            {
                obj = new Product_Table()
                {
                    E_id         = Convert.ToInt32(dr["E_id"]),
                    HP_id        = Convert.ToInt32(dr["HP_id"]),
                    NP_id        = Convert.ToInt32(dr["NP_id"]),
                    PT_id        = Convert.ToInt32(dr["PT_id"]),
                    P_Company    = dr["P_Company"].ToString(),
                    P_Date       = Convert.ToDateTime(dr["P_Date"]),
                    P_id         = Convert.ToInt32(dr["P_id"]),
                    P_Name       = dr["P_Name"].ToString(),
                    P_No         = dr["P_No"].ToString(),
                    P_Price      = Convert.ToDouble(dr["P_Price"]),
                    P_CoverImage = dr["P_CoverImage"].ToString(),
                    P_Introduce  = dr["P_Introduce"].ToString()
                };
            }
            dr.Close();
            return(obj);
        }
        public ActionResult DeleteConfirmed(string id)
        {
            Product_Table product_Table = db.Product_Table.Find(id);

            db.Product_Table.Remove(product_Table);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult Delete(Product_Table IdToDelete)
        {
            var d = obj.Product_Table.Where(x => x.id == IdToDelete.id).FirstOrDefault();

            obj.Product_Table.Remove(d);
            obj.SaveChanges();
            return(RedirectToAction("ProductList"));
        }
Ejemplo n.º 9
0
        public ActionResult ImageDisplay(int imageId)
        {
            Product_Table product = db.Product_Table.Find(imageId);

            var imageList = (from a in db.Image_Table
                             where a.Productid == product.ProductId && a.ImageIsDeleted == false
                             select a).ToList();

            ViewBag.ImageList = imageList.ToList();
            return(PartialView("_imageDisplay"));
        }
        public ActionResult Create(Product_Table product_Table, HttpPostedFileBase small_img, HttpPostedFileBase large_img)
        {
            if (ModelState.IsValid)
            {
                string filePath1 = null, filePath2 = null;
                string k = null;
                if (small_img != null)
                {
                    string fileName  = System.IO.Path.GetFileNameWithoutExtension(small_img.FileName);
                    string extension = System.IO.Path.GetExtension(small_img.FileName);
                    filePath1 = "~/Small_Imgs/" + fileName + DateTime.Now.ToString("yyMMddssffff") + extension;
                    small_img.SaveAs(Server.MapPath(filePath1));
                }
                if (large_img != null)
                {
                    string fileName2 = System.IO.Path.GetFileNameWithoutExtension(large_img.FileName);
                    string extension = System.IO.Path.GetExtension(large_img.FileName);
                    filePath2 = "~/Large_Imgs/" + fileName2 + DateTime.Now.ToString("yyMMddssffff") + extension;
                    large_img.SaveAs(Server.MapPath(filePath2));
                }
                else
                {
                    filePath2 = "/Large_Imgs/dont_delete/no_img.png";
                }
                if (product_Table.Long_description == null)
                {
                    k = "----------";
                }
                else
                {
                    k = product_Table.Long_description;
                }
                var product = new Product_Table
                {
                    Id                = DateTime.Now.ToString("yyyyMMddssffffyyMMdd"),
                    Userid            = User.Identity.Name,
                    Name              = product_Table.Name,
                    Category          = product_Table.Category,
                    Price             = product_Table.Price,
                    Quantity          = product_Table.Quantity,
                    Short_description = product_Table.Short_description,
                    Long_description  = k,
                    Small_img         = filePath1,
                    Large_img         = filePath2
                };

                db.Product_Table.Add(product);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(product_Table));
        }
        // GET: Product_Table/Delete/5
        public ActionResult Delete(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Product_Table product_Table = db.Product_Table.Find(id);

            if (product_Table == null)
            {
                return(HttpNotFound());
            }
            return(View(product_Table));
        }
Ejemplo n.º 12
0
        public ActionResult imagedisplay(int id)
        {
            Product_Table product = db.Product_Table.Find(id);

            object[] imagelist = new object[5];
            var      image     = (from a in db.Image_Table where a.Productid == product.ProductId && a.ImageIsDeleted == false select a).ToList();

            ViewBag.imlist = image.ToList();
            TempData["ID"] = id;



            return(PartialView("imagedisplay", ViewBag.imlist));
        }
        public ActionResult Edit(HttpPostedFile file, Product_Table prod)
        {
            if (ModelState.IsValid)
            {
                if (file != null)
                {
                    string filename  = Path.GetFileName(file.FileName);
                    string _filename = DateTime.Now.ToString("yymmssfff") + filename;
                    string extension = Path.GetExtension(file.FileName);
                    string path      = Path.Combine(Server.MapPath("~/ProductImage/"), _filename);
                    prod.Image = "~/ProductImage/" + _filename;
                    if (extension.ToLower() == ".jpg" || extension.ToLower() == ".jpeg" || extension.ToLower() == ".png")
                    {
                        if (file.ContentLength <= 1000000)
                        {
                            obj.Entry(prod).State = EntityState.Modified;
                            string oldImgPath = Request.MapPath(Session["imgPath"].ToString());

                            if (obj.SaveChanges() > 0)
                            {
                                file.SaveAs(path);
                                if (System.IO.File.Exists(oldImgPath))
                                {
                                    System.IO.File.Delete(oldImgPath);
                                }
                                TempData["msg"] = "Record Updated ";
                            }
                        }
                        else
                        {
                            ViewBag.msg = "Sizeis In valid  ";
                        }
                    }
                }
                else
                {
                    prod.Image            = Session["imgPath"].ToString();
                    obj.Entry(prod).State = EntityState.Modified;
                    if (obj.SaveChanges() > 0)
                    {
                        TempData["msg"] = "Data Updated ";
                        return(RedirectToAction("ProductList"));
                    }
                }
            }



            return(View());
        }
Ejemplo n.º 14
0
        public ActionResult purchase_all(Book obj)
        {
            string name = Session["user"].ToString();
            int    usid = db.User_Table.Where(x => x.UserName == name).Select(x => x.UserId).FirstOrDefault();

            Order_Table order = db.Order_Table.Where(x => x.OrderStatus == 0 & x.OrderIsDeleted == false & x.Userid == usid).FirstOrDefault();

            order.OrderDeliveryAddress = obj.OrderDelivryAddress;
            order.TotalAmount          = Convert.ToInt32(TempData["tcart_amt"]);
            order.OrderNotification    = "00";
            order.OrderDeliveryDate    = System.DateTime.Now.AddDays(5);
            order.OrderStatus          = 1;
            db.SaveChanges();
            var odetail = db.OrderDetail_Table.Where(x => x.Orderid == order.OrderId).Select(x => x.OrderDetailId).ToList();

            foreach (var item in odetail)
            {
                int               flag     = 0;
                List <int>        availid1 = TempData["avail1"] as List <int>;
                OrderDetail_Table obj1     = db.OrderDetail_Table.Where(x => x.OrderDetailId == item).FirstOrDefault();
                foreach (var pro in availid1)
                {
                    if (obj1.Productid == pro)
                    {
                        Product_Table pobj  = db.Product_Table.Where(x => x.ProductId == pro).FirstOrDefault();
                        int           stock = Convert.ToInt32(pobj.ProductStock);
                        int           qty   = Convert.ToInt32(obj1.Quantity);
                        pobj.ProductStock = stock - qty;
                        db.SaveChanges();
                        flag = 1;
                    }
                }
                if (flag == 1)
                {
                    int           lid    = Convert.ToInt32(Session["location"]);
                    Service_Table serboj = db.Service_Table.Where(x => x.ServiceProviderid == obj.UserId && x.Locationid == lid).FirstOrDefault();
                    obj1.Serviceid = serboj.ServiceId;
                    db.SaveChanges();
                }
                else
                {
                    db.OrderDetail_Table.Remove(obj1);
                    db.SaveChanges();
                }
            }
            count_cart();
            Session["location"] = null;
            return(RedirectToAction("notification"));
        }
Ejemplo n.º 15
0
        private void SProductBar_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                if (!string.IsNullOrEmpty(SProductBar.Text))
                {
                    Product_Table Obj = BussinessObj.Product_tb_search_by_Barecode(SProductBar.Text);

                    if (Obj != null)
                    {
                        SComProdu.SelectedValue = Obj.Product_ID;
                    }
                }
            }
        }
Ejemplo n.º 16
0
        public ActionResult cart()
        {
            float  total = 0;
            int    c     = 0;
            string name  = Session["user"].ToString();
            List <Buyer_Product> plist   = new List <Buyer_Product>();
            int        uid               = db.User_Table.Where(x => x.UserName == name).Select(x => x.UserId).FirstOrDefault();
            int        oid               = db.Order_Table.Where(x => x.Userid == uid & x.OrderStatus == 0 & x.OrderIsDeleted == false).Select(x => x.OrderId).FirstOrDefault();
            var        pro_id            = db.OrderDetail_Table.Where(x => x.Orderid == oid).Select(x => x.Productid).ToList();
            List <int> avail_product     = new List <int>();
            List <int> not_avail_product = new List <int>();

            foreach (var item1 in pro_id)
            {
                Product_Table pobj = db.Product_Table.Where(x => x.ProductId == item1).FirstOrDefault();
                Buyer_Product bobj = new Buyer_Product();
                bobj.ProductName  = pobj.ProductName;
                bobj.ProductId    = pobj.ProductId;
                bobj.ProductPrice = pobj.ProductPrice;
                bobj.ProductDesc  = pobj.ProductDesc;
                if (pobj.ProductStock > 0)
                {
                    total += (float)pobj.ProductPrice;
                    avail_list.Add(pobj.ProductId);
                    avail_product.Add(pobj.ProductId);
                    c++;
                }
                else
                {
                    not_avail_product.Add(pobj.ProductId);
                }
                Image_Table img = db.Image_Table.Where(x => x.Productid == item1 && x.ImageIsDeleted == false).FirstOrDefault();
                if (img != null)
                {
                    bobj.BinaryImage = img.BinaryImage;
                    plist.Add(bobj);
                }
            }
            TempData["count"]     = c;
            TempData["tcart_amt"] = total;
            ViewBag.avail         = avail_product;
            ViewBag.tcart_amt     = total;
            TempData["avail"]     = avail_product;
            TempData.Keep("avail");
            TempData["avail1"] = avail_product;
            ViewBag.not_avail  = not_avail_product;
            return(View(plist));
        }
        // GET: Product_Table/Details/5
        public ActionResult Details(string id)
        {
            Debug.WriteLine("Id is : " + id);
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Product_Table product_Table = db.Product_Table.Find(id);

            Debug.WriteLine(product_Table.Name);
            if (product_Table == null)
            {
                return(HttpNotFound());
            }
            return(View(product_Table));
        }
Ejemplo n.º 18
0
        public JsonResult Edit(int id, string name, decimal price, string features, int stock)
        {
            Product_Table pt = db.Product_Table.Find(id);



            pt.ProductName  = name;
            pt.ProductPrice = price;
            pt.ProductDesc  = features;
            pt.ProductStock = stock;

            pt.ProductUpdatedBy   = Session["user"].ToString();
            pt.ProductUpdatedDate = DateTime.Now;
            db.SaveChanges();

            return(Json(new { id = id, ProductName = name, ProductPrice = price, ProductDesc = features, ProductStock = stock }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 19
0
        public void del_check_stock()
        {
            string     name  = Session["user"].ToString();
            int        id    = db.User_Table.Where(x => x.UserName == name).Select(x => x.UserId).FirstOrDefault();
            List <int> nlist = db.Notify_table.Where(x => x.Userid == id && x.flag == 0).Select(x => x.Productid).ToList();

            foreach (int item in nlist)
            {
                Notify_table  nobj = db.Notify_table.Where(x => x.Userid == id && x.Productid == item).FirstOrDefault();
                Product_Table pobj = db.Product_Table.Where(x => x.ProductId == item).FirstOrDefault();
                if (pobj.ProductStock > 0)
                {
                    nobj.flag = 1;
                    db.SaveChanges();
                }
            }
        }
Ejemplo n.º 20
0
        private void textEdit7_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                if (!string.IsNullOrEmpty(textEdit7.Text))
                {
                    Product_Table Obj = BussinessObj.Product_tb_search_by_Barecode(textEdit7.Text);

                    if (Obj != null)
                    {
                        ProductName.Text = Obj.Product_Name;
                        ProducDes.Text   = Obj.Description;

                        ComCatagory.SelectedValue = Obj.Catagory_ID;
                        Barcode.Text = Obj.BareCode;
                        if (Obj.Product_Size == "صغرى")
                        {
                            groupControl2.Visible      = false;
                            SproduQue.Text             = "";
                            CombProdSize.SelectedIndex = 0;
                        }
                        else if (Obj.Product_Size == "كبرى")
                        {
                            groupControl2.Visible      = true;
                            CombProdSize.SelectedIndex = 1;
                            SComProdu.SelectedValue    = Obj.SProduct_ID;
                            SproduQue.Text             = Obj.SQuantity;
                        }

                        CombUnit.SelectedValue = Obj.Unite_ID;

                        ProduQue.Text = Obj.AlarmQuantity.ToString();

                        if (Obj.Product_Exist == 1)
                        {
                            checkEdit1.Checked = true;
                        }
                        else if (Obj.Product_Exist == 0)
                        {
                            checkEdit1.Checked = false;
                        }
                    }
                }
            }
        }
Ejemplo n.º 21
0
 /// <summary>
 /// 添加产品
 /// </summary>
 /// <param name="obj">带入参数</param>
 /// <returns></returns>
 public int Insert_ProductTableData(Product_Table obj)
 {
     return(DBHerlper.ExecuteNonQuery(GetSqlString("Insert"),
                                      CommandType.StoredProcedure,
                                      new SqlParameter[] {
         new SqlParameter("@E_id", obj.E_id),
         new SqlParameter("@HP_id", obj.HP_id),
         new SqlParameter("@NP_id", obj.NP_id),
         new SqlParameter("@PT_id", obj.PT_id),
         new SqlParameter("@P_Company", obj.P_Company),
         new SqlParameter("@P_Date", obj.P_Date),
         new SqlParameter("@P_Name", obj.P_Name),
         new SqlParameter("@P_No", obj.P_No),
         new SqlParameter("@P_CoverImage", obj.P_CoverImage),
         new SqlParameter("@P_Introduce", obj.P_Introduce),
         new SqlParameter("@P_Price", obj.P_Price)
     }));
 }
Ejemplo n.º 22
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBox1.SelectedValue != null)
            {
                Product_Table Obj = BussinessObj.Product_tb_search_by_ID(int.Parse(comboBox1.SelectedValue.ToString()));

                if (Obj != null)
                {
                    ProductName.Text          = Obj.Product_Name;
                    ProducDes.Text            = Obj.Description;
                    ComCatagory.SelectedValue = Obj.Catagory_ID;
                    Barcode.Text = Obj.BareCode;
                    if (Obj.Product_Size == "صغرى")
                    {
                        groupControl2.Visible      = false;
                        SproduQue.Text             = "";
                        CombProdSize.SelectedIndex = 0;
                    }
                    else if (Obj.Product_Size == "كبرى")
                    {
                        groupControl2.Visible      = true;
                        CombProdSize.SelectedIndex = 1;
                        SComProdu.SelectedValue    = Obj.SProduct_ID;
                        SproduQue.Text             = Obj.SQuantity;
                    }


                    CombUnit.SelectedValue = Obj.Unite_ID;

                    ProduQue.Text = Obj.AlarmQuantity.ToString();

                    if (Obj.Product_Exist == 1)
                    {
                        checkEdit1.Checked = true;
                    }
                    else if (Obj.Product_Exist == 0)
                    {
                        checkEdit1.Checked = false;
                    }
                }
            }
        }
Ejemplo n.º 23
0
        private void Barcode_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                if (ValidationClass.StringNotEmpty(Barcode.Text))
                {
                    Product_Table Ob = BussinessObj.Product_tb_search_by_Barecode(Barcode.Text);

                    if (ValidationClass.ISDigit(SellingPrice.Text) && ValidationClass.ISDigit(Quantity.Text) && ValidationClass.ISDigit(Pric1.Text))
                    {
                        AddProduct(Ob.Product_ID, int.Parse(Quantity.Text), float.Parse(SellingPrice.Text), float.Parse(Pric1.Text), Price2.Text);
                    }
                    else
                    {
                        XtraMessageBox.Show("يرجى اضافة بيانات الكمية والاسعار قبل محاولة الاضافة");
                    }
                }
                Barcode.Text = "";
            }
        }
Ejemplo n.º 24
0
        public JsonResult DeleteConfirmed(int id)
        {
            Product_Table product = db.Product_Table.Find(id);

            product.ProductUpdatedBy   = Session["user"].ToString();
            product.ProductUpdatedDate = DateTime.Now;
            product.ProductIsDeleted   = true;
            var image = (from a in db.Image_Table where a.Productid == product.ProductId select a).ToList();

            foreach (var im in image)
            {
                im.ImageUpdatedBy   = Session["user"].ToString();
                im.ImageUpdatedDate = DateTime.Now;
                im.ImageIsDeleted   = true;
            }

            db.SaveChanges();
            bool result = true;

            return(Json(new { result }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 25
0
        public ActionResult order(Book obj, string amt)
        {
            string name  = Session["user"].ToString();
            int    pid   = Convert.ToInt32(Session["pro_id"].ToString());
            int    stock = db.Product_Table.Where(x => x.ProductId == pid).Select(x => x.ProductStock).FirstOrDefault();

            if (obj.Quantity <= stock)
            {
                Order_Table       order        = new Order_Table();
                OrderDetail_Table order_detail = new OrderDetail_Table();
                order.TotalAmount          = Convert.ToInt32(amt);
                order.OrderDeliveryAddress = obj.OrderDelivryAddress;
                order.OrderDeliveryDate    = System.DateTime.Now.AddDays(5);
                order.Userid            = db.User_Table.Where(x => x.UserName == name).Select(x => x.UserId).FirstOrDefault();
                order.OrderCreatedBy    = name;
                order.OrderUpdatedBy    = name;
                order.OrderCreatedDate  = System.DateTime.Now;
                order.OrderUpdatedDate  = System.DateTime.Now;
                order.OrderIsDeleted    = false;
                order.OrderStatus       = 1;
                order.OrderNotification = "00";
                db.Order_Table.Add(order);
                db.SaveChanges();
                int oid = order.OrderId;
                order_detail.Orderid   = oid;
                order_detail.Productid = pid;
                int           lid    = Convert.ToInt32(Session["location"]);
                Service_Table serboj = db.Service_Table.Where(x => x.ServiceProviderid == obj.UserId && x.Locationid == lid).FirstOrDefault();
                order_detail.Serviceid = serboj.ServiceId;
                order_detail.Quantity  = obj.Quantity;
                order_detail.Amount    = Convert.ToInt32(amt);
                db.OrderDetail_Table.Add(order_detail);
                db.SaveChanges();
                Product_Table pobj = db.Product_Table.Where(x => x.ProductId == pid).FirstOrDefault();
                pobj.ProductStock = stock - obj.Quantity;
                db.SaveChanges();
            }
            Session["location"] = null;
            return(RedirectToAction("notification"));
        }
Ejemplo n.º 26
0
        public JsonResult ServiceEdit(int ServiceId, string ServiceName, decimal DeliveryCharge, string ServiceDesc, string LocationName, string ProductName)
        {
            Product_Table  product  = new Product_Table();
            Location_Table location = new Location_Table();
            Service_Table  service  = db.Service_Table.Find(ServiceId);

            service.ServiceName    = ServiceName;
            service.DeliveryCharge = DeliveryCharge;
            service.ServiceDesc    = ServiceDesc;
            int locationId = (from l in db.Location_Table where l.LocationName == LocationName select l.LocationId).FirstOrDefault();

            service.Locationid = locationId;
            int productId = (from p in db.Product_Table where p.ProductName == ProductName select p.ProductId).FirstOrDefault();

            service.Productid          = productId;
            service.ServiceUpdatedBy   = Session["user"].ToString();
            service.ServiceUpdatedDate = System.DateTime.Now;
            db.SaveChanges();
            var redirectUrl = new UrlHelper(Request.RequestContext).Action("Manage_Service", "Service");

            return(Json(new { ServiceId = ServiceId, ServiceName = ServiceName, DeliveryCharge = DeliveryCharge, ServiceDesc = ServiceDesc, LocationName = LocationName, ProductName = ProductName, Url = redirectUrl }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 27
0
 private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     textBox1.Text = "";
     textBox4.Text = "0";
     textBox3.Text = "";
     if (comboBox1.SelectedValue != null)
     {
         Product_Table ProductObj = BussinessObj.Product_tb_search_by_ID(int.Parse(comboBox1.SelectedValue.ToString()));
         if (!String.IsNullOrEmpty(ProductObj.Product_Name))
         {
             textBox1.Text    = ProductObj.BareCode;
             textBox1.Enabled = false;
             button2.Visible  = false;
         }
         else
         {
             textBox1.Enabled = true;
             button2.Visible  = true;
         }
         textBox3.Text = ProductObj.Product_Name;
     }
     ////select price from purches
 }
        public ActionResult Edit(Product_Table product_Table, String Small_path, String Large_path, HttpPostedFileBase Small_img, HttpPostedFileBase Large_img)
        {
            String filePath1 = Small_path;

            if (Small_img != null)
            {
                string fileName  = System.IO.Path.GetFileNameWithoutExtension(Small_img.FileName);
                string extension = System.IO.Path.GetExtension(Small_img.FileName);
                filePath1 = "~/Small_Imgs/" + fileName + DateTime.Now.ToString("yyMMddssffff") + extension;
                Small_img.SaveAs(Server.MapPath(filePath1));
            }
            String filePath2 = Large_path;

            if (Large_img != null)
            {
                string fileName2 = System.IO.Path.GetFileNameWithoutExtension(Large_img.FileName);
                string extension = System.IO.Path.GetExtension(Large_img.FileName);
                filePath2 = "~/Large_Imgs/" + fileName2 + DateTime.Now.ToString("yyMMddssffff") + extension;
                Large_img.SaveAs(Server.MapPath(filePath2));
            }
            if (ModelState.IsValid)
            {
                // db.Entry(product_Table).State = EntityState.Modified;
                var product = db.Product_Table.Single(u => u.Id == product_Table.Id);
                product.Name              = product_Table.Name;
                product.Category          = product_Table.Category;
                product.Price             = product_Table.Price;
                product.Quantity          = product_Table.Quantity;
                product.Short_description = product_Table.Short_description;
                product.Long_description  = product_Table.Long_description;
                product.Small_img         = filePath1;
                product.Large_img         = filePath2;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(product_Table));
        }
Ejemplo n.º 29
0
 public void UpdateProduct(Product_Table product_)
 {
     _dataContext.Entry(product_).State = System.Data.Entity.EntityState.Modified;
 }
Ejemplo n.º 30
0
 public ActionResult Update(Product_Table product)
 {
     _productRepository.UpdateProduct(product);
     _productRepository.SaveChanges();
     return(RedirectToAction("Index"));
 }