public static void UpdateNote(LinkedList <Product_> products, LinkedList <Log.Log_> logs) { Console.WriteLine("Укажите номер записи, которую хотите обновить"); int number = SetNumber(0, (uint)products.Count() - 1); var updateProduct = new Product_(); int cnt = 0; foreach (var product in products) { if (number == cnt) { updateProduct = product; } cnt++; } logs.AddLast(new Log.Log_(DateTime.Now, Log.Action.UPDATE, updateProduct.Name)); Console.Write("Введите наименование товара:"); string Name = (Console.ReadLine()); Console.WriteLine("Укажите его тип (Оргтехника - O, Канцтовары - K)"); var type = SetProductType(); Console.WriteLine("Укажите цену за 1шт (грн)"); var price = SetPrice(0, Decimal.MaxValue); Console.WriteLine("Укажите количество"); var amount = (uint)SetNumber(0, UInt32.MaxValue); var updateNote = products.Find(updateProduct); products.AddAfter(updateNote, new Product_(Name, type, price, amount)); products.Remove(updateProduct); }
//Create public JsonResult CreateProduct(Product_ c) { TalentEntities db = new TalentEntities(); db.Product_.Add(c); db.SaveChanges(); return new JsonResult { Data = "Success", JsonRequestBehavior = JsonRequestBehavior.AllowGet }; }
public JsonResult Edit(Product_ p) { TalentEntities db = new TalentEntities(); var Prod = db.Product_.Where(x => x.Id == p.Id).SingleOrDefault(); Prod.Name = p.Name; Prod.Price = p.Price; db.SaveChanges(); return new JsonResult { Data = "Success", JsonRequestBehavior = JsonRequestBehavior.AllowGet }; }
public JsonResult GetEdit(int id) { TalentEntities db = new TalentEntities(); Product_ Prod= db.Product_.Where(x => x.Id == id).SingleOrDefault(); string value = JsonConvert.SerializeObject(Prod, Formatting.Indented, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }); return new JsonResult { Data = value, JsonRequestBehavior = JsonRequestBehavior.AllowGet }; }
private void btnSaveNewProduct_Click(object sender, EventArgs e) { if (txtPO.Text == "") { MessageBox.Show("Insert Product Owner"); return; } if (txtPN.Text == "") { MessageBox.Show("Insert Name of the Product"); return; } if (txtPDUra.Text == "") { MessageBox.Show("Insert Product Duration"); return; } if (txtPM.Text == "") { MessageBox.Show("Insert Product Methodology"); return; } if (txtPD.Text == "") { MessageBox.Show("Insert Product Description"); return; } Product_ NP = new Product_(); /* New Product Class Object */ /* Add Textbox values to the NP(Product object value holders ) */ NP.ProductOwner = txtPO.Text; NP.NameofProduct = txtPN.Text; NP.AnalysisID = cbAID.SelectedValue.ToString(); NP.ProductStatus = cbPS.SelectedValue.ToString(); NP.ProductDuration = txtPDUra.Text; NP.ProductLifeCycle = txtPM.Text; NP.Description = txtPD.Text; int result = NP.addNew_Product(); /* Call the Proudct Add Class form NP Object*/ if (result != 0) { MessageBox.Show("Success"); } else { MessageBox.Show("Error"); } /* if the product add was success show message box success */ }
public static void DeleteNote(LinkedList <Product_> products, LinkedList <Log.Log_> logs) { Console.WriteLine("Укажите номер записи, которую хотите удалить"); int number = SetNumber(0, (uint)products.Count() - 1); int cnt = 0; var deleteProduct = new Product_(); foreach (var product in products) { if (number == cnt) { deleteProduct = product; } cnt++; } logs.AddLast(new Log.Log_(DateTime.Now, Log.Action.DELETE, deleteProduct.Name)); products.Remove(deleteProduct); }
public static void ReadInfo(DoubleLinkedList <Product_> products, string path) { try { using (StreamReader sr = new StreamReader(path)) { while (sr.Peek() != -1) { string[] data = sr.ReadLine().Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); if (data.Length == 4) { var product = new Product_(data[0], GetProductType(data[1][0]), Convert.ToDecimal(data[2]), Convert.ToUInt32(data[3])); AddNote(products, product); } } } } catch { Console.WriteLine("Файл не обнаружен...\n"); } }
public static void AddNote(DoubleLinkedList <Product_> products, Product_ product) { products.Append(product); }
public static void AddNote(LinkedList <Product_> products, Product_ product) { products.AddLast(product); }