public ProductModel Details(int id) { { try { Product_Information product_Information = Data.Product_Information.Find(id); Image PI = Data.Image.Find(id); Product_Stock PS = Data.Product_Stock.Find(id); Category C = Data.Category.Single(x => x.Id == product_Information.Category_id); ProductModel p = new ProductModel(); p.product_id = id; p.Product_name = product_Information.Product_name; p.Unit = product_Information.Unit; p.price_per_unit = product_Information.Price_per_unit; p.tag = product_Information.Tag; p.Image = PI.Image1; p.stock = PS.Stock_unit; p.catagory = C.Parent_id.Value; return(p); } catch { throw; } } return(null); }
public string PostDelete(int id) { try { Product_Information product_Information = Data.Product_Information.Find(id); Category C = Data.Category.Single(x => x.Parent_id == product_Information.Category_id); Data.Category.Remove(C); Image PI = Data.Image.Find(id); Data.Image.Remove(PI); Product_Stock PS = Data.Product_Stock.Find(id); Data.Product_Stock.Remove(PS); Data.Product_Information.Remove(product_Information); Data.SaveChanges(); return("Index"); } catch { throw; } }
public async Task <object> Edite(Product_Stock product_Stock) { bool isValid = await _product_StockService.ModifyProduct_Stock(product_Stock); _notification.SetNotificationMessage(isValid, Title, product_Stock.UID); return(_notification); }
public string Create(ProductModel product_Information) { try { Product_Information P = new Product_Information(); P.Product_name = product_Information.Product_name; P.Unit = product_Information.Unit; P.Price_per_unit = product_Information.price_per_unit; P.Tag = product_Information.tag; P.Special_Offer = 0; P.Category_id = product_Information.catagory; Data.Product_Information.Add(P); Data.SaveChanges(); Image image = new Image { ID = P.Product_id, Image1 = product_Information.Image }; Data.Image.Add(image); Data.SaveChanges(); Product_Stock PS = new Product_Stock { Product_id = P.Product_id, Stock_unit = product_Information.stock, Product_Name = product_Information.Product_name }; Data.Product_Stock.Add(PS); Data.SaveChanges(); Category C = new Category(); C.Id = product_Information.product_id; C.Name = product_Information.Product_name; C.Parent_id = product_Information.catagory; Data.Category.Add(C); Data.SaveChanges(); return("Index"); } catch { throw; } }
public string PostEdit(ProductModel product_Information) { try { Product_Information P = Data.Product_Information.Find(product_Information.product_id); Image PI = Data.Image.Find(product_Information.product_id); Product_Stock PS = Data.Product_Stock.Find(product_Information.product_id); Category C = Data.Category.Single(x => x.Name == product_Information.Product_name); P.Product_name = product_Information.Product_name; P.Unit = product_Information.Unit; P.Price_per_unit = product_Information.price_per_unit; P.Tag = product_Information.tag; P.Special_Offer = 0; P.Category_id = product_Information.catagory; Data.Entry(P).State = EntityState.Modified; PI.Image1 = product_Information.Image; Data.Entry(PI).State = EntityState.Modified; PS.Product_Name = product_Information.Product_name; PS.Stock_unit = product_Information.stock; Data.Entry(PS).State = EntityState.Modified; C.Name = product_Information.Product_name; C.Parent_id = product_Information.catagory; Data.Entry(C).State = EntityState.Modified; Data.SaveChanges(); return("Index"); } catch { throw; } }
private void SaveButton_Click(object sender, EventArgs e) { int IntTest; Double DoubleTest; Boolean Fail = true; while (Fail) { _Product.Product_Name = Product_Name.Text; if (Int32.TryParse(Product_ID.Text, out IntTest)) { _Product.ProductId = Int32.Parse(Product_ID.Text); } else { MessageBox.Show("Not an acceptible ID"); Fail = false; break; } if (Int32.TryParse(Product_Stock.Text, out IntTest)) { _Product.Stock_Level = Int32.Parse(Product_Stock.Text); } else { MessageBox.Show("Not an acceptible stock level"); Fail = false; break; } if (Double.TryParse(Product_Price.Text, out DoubleTest)) { _Product.Price = Double.Parse(Product_Price.Text); } else { MessageBox.Show("Not an acceptible price"); Fail = false; break; } _PHPRepo.EditProductRecord(_Product); Product_ID.Clear(); Product_Name.Clear(); Product_Stock.Clear(); Product_Price.Clear(); Product_Name.Enabled = false; Product_Stock.Enabled = false; Product_Price.Enabled = false; StockList.Items.Clear(); List <Product> _NewList = _PHPRepo.GetProducts(); foreach (Product p in _NewList) { string[] row = { p.ProductId.ToString(), p.Product_Name.ToString(), p.Price.ToString(), p.Stock_Level.ToString() }; var listViewItem = new ListViewItem(row); StockList.Items.Add(listViewItem); } ; Fail = false; break; } }
public string Submit(string Customer_id, string UserName) { try { List <Customer_Order> submitionList = Data.Customer_Order.Where(x => x.Purches_id == Customer_id && x.Order_Status == 1).ToList(); int Total = 0; System.Random rand = new System.Random((int)System.DateTime.Now.Ticks); int random = rand.Next(1, 100000000); string Path = @"D:\Repositories\HatBazar\Email_Document\Customer_Order\" + random + ".txt"; //Pass the filepath and filename to the StreamWriter Constructor //StreamWriter sw = new StreamWriter(@"D:\Repositories\HatBazar\Email_Document\Admin_Email\Document.txt"); StreamWriter sw = new StreamWriter(Path); //Write a line of text sw.WriteLine(System.IO.File.ReadAllText(@"D:\Repositories\HatBazar\Email_Document\Customer_Order\Order1.txt")); sw.WriteLine("Date :" + DateTime.Now); //*************************************************** foreach (var i in submitionList) { if (i.Unit_name == "PACKAGE") { int packageid = (i.Product_id).Value; List <Package_With_Product> Item = Data.Package_With_Product.Where(x => x.Package_Id == packageid).ToList(); foreach (var product in Item) { Product_Stock CO = Data.Product_Stock.Single(Z => Z.Product_id == product.Product_Id); int J = Int32.Parse(CO.Stock_unit); J = J - product.Unit_Number; CO.Stock_unit = J.ToString(); Data.Entry(CO).State = EntityState.Modified; bool Check = Data.Order_For_Shop.Any(x => x.Product_Name == (product.Product_Name)); if (Check == true) { Order_For_Shop order = Data.Order_For_Shop.Single(Z => Z.Product_Name == product.Product_Name); order.Unit_Number = product.Unit_Number + (order.Unit_Number); var price = Data.Product_Information.Single(x => x.Product_id == order.Product_Id); order.Total_Price = (order.Unit_Number) * (price.Price_per_unit); Data.Entry(order).State = EntityState.Modified; Product_SellingDate psd = new Product_SellingDate(); psd.Product_Id = order.Product_Id; psd.Product_Name = order.Product_Name; psd.Unit_Number = product.Unit_Number; psd.Unit_Name = order.Unit_Name; psd.Price = i.Price * product.Unit_Number; psd.Selected = 0; var dateTimeNow = DateTime.Now; // Return 00/00/0000 00:00:00 psd.Date = dateTimeNow.ToShortDateString(); Data.Product_SellingDate.Add(psd); Data.SaveChanges(); } else { Order_For_Shop OF = new Order_For_Shop(); OF.Product_Name = product.Product_Name; OF.Unit_Name = product.Unit_Name; OF.Unit_Number = product.Unit_Number; var price = Data.Product_Information.Single(x => x.Product_id == OF.Product_Id); OF.Total_Price = price.Price_per_unit; Data.Order_For_Shop.Add(OF); Product_SellingDate psd = new Product_SellingDate(); psd.Product_Id = OF.Product_Id; psd.Product_Name = product.Product_Name; psd.Unit_Number = product.Unit_Number; psd.Unit_Name = product.Unit_Name; psd.Price = i.Price * product.Unit_Number; psd.Selected = 0; var dateTimeNow = DateTime.Now; // Return 00/00/0000 00:00:00 psd.Date = dateTimeNow.ToShortDateString(); Data.Product_SellingDate.Add(psd); Data.SaveChanges(); } } } else { Product_Stock CO = Data.Product_Stock.Single(Z => Z.Product_id == (i.Product_id).Value); int J = Int32.Parse(CO.Stock_unit); J = J - (i.Unit_number).Value; CO.Stock_unit = J.ToString(); Data.Entry(CO).State = EntityState.Modified; bool Check = Data.Order_For_Shop.Any(x => x.Product_Name == (i.Product_Name)); if (Check == true) { Order_For_Shop order = Data.Order_For_Shop.Single(Z => Z.Product_Name == i.Product_Name); order.Unit_Number = (i.Unit_number).Value + (order.Unit_Number); var price = Data.Product_Information.Single(x => x.Product_name == order.Product_Name); // var price = Data.Product_Information.Single(x => x.Product_id == order.Product_Id); order.Total_Price = (order.Unit_Number) * (price.Price_per_unit); Data.Entry(order).State = EntityState.Modified; Product_SellingDate psd = new Product_SellingDate(); psd.Product_Id = order.Product_Id; psd.Product_Id = order.Product_Id; psd.Product_Name = order.Product_Name; psd.Unit_Number = i.Unit_number; psd.Unit_Name = order.Unit_Name; psd.Price = price.Price_per_unit * i.Unit_number; psd.Selected = 0; var dateTimeNow = DateTime.Now; // Return 00/00/0000 00:00:00 psd.Date = dateTimeNow.ToShortDateString(); Data.Product_SellingDate.Add(psd); Data.SaveChanges(); } else { Order_For_Shop OF = new Order_For_Shop(); //OF.Product_Id = (i.Product_id).Value; OF.Product_Name = i.Product_Name; OF.Unit_Name = i.Unit_name; OF.Unit_Number = (i.Unit_number).Value; Data.Order_For_Shop.Add(OF); Product_SellingDate psd = new Product_SellingDate(); psd.Product_Id = (i.Product_id).Value; psd.Product_Name = i.Product_Name; psd.Unit_Number = i.Unit_number; psd.Unit_Name = i.Unit_name; psd.Price = i.Price * i.Unit_number; psd.Selected = 0; var dateTimeNow = DateTime.Now; // Return 00/00/0000 00:00:00 psd.Date = dateTimeNow.ToShortDateString(); Data.Product_SellingDate.Add(psd); Data.SaveChanges(); } } i.Order_Status = 0; var date = DateTime.Now; i.Date = date.ToShortDateString(); Data.Entry(i).State = EntityState.Modified; //*********************************** try { string Information = "Product Name :" + i.Product_Name + "Unit :" + i.Unit_number + "" + i.Unit_name + "Price:" + (i.Unit_number * i.Price); sw.WriteLine(Information); Total = Total + (i.Unit_number * i.Price).Value; } catch { return("Path Missing to save Email."); } //*********************************** } Order_with_Date OD = new Order_with_Date(); var date2 = DateTime.Now; OD.Date = date2.ToShortDateString(); OD.User_Name = UserName; OD.Total_Price = Total; Data.Order_with_Date.Add(OD); Data.SaveChanges(); sw.WriteLine("Total : " + Total); sw.WriteLine(System.IO.File.ReadAllText(@"D:\Repositories\HatBazar\Email_Document\Customer_Order\Order2.txt")); sw.Close(); IEmail_Service email = new Email_ServiceClass(); int ia = Int32.Parse(Customer_id); Customer_Information Info = Data.Customer_Information.Single(x => x.Customer_id == ia); Email_Service_Model obj = new Email_Service_Model(); obj.ToEmail = Info.Email; obj.EmailSubject = "Hat Bazar"; obj.EMailBody = System.IO.File.ReadAllText(Path); return(email.SendEmail(obj)); } catch { return("Submission Failure"); } }