예제 #1
0
        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);
        }
예제 #2
0
        //Create
        public JsonResult CreateProduct(Product_ c)
        {

            TalentEntities db = new TalentEntities();
            db.Product_.Add(c);
            db.SaveChanges();
            return new JsonResult { Data = "Success", JsonRequestBehavior = JsonRequestBehavior.AllowGet };
        }
예제 #3
0
        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 };

        }
예제 #4
0
        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 };

        }
예제 #5
0
파일: New_Product.cs 프로젝트: Ruke45/CRMS
        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 */
        }
예제 #6
0
        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);
        }
예제 #7
0
 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");
     }
 }
예제 #8
0
 public static void AddNote(DoubleLinkedList <Product_> products, Product_ product)
 {
     products.Append(product);
 }
예제 #9
0
 public static void AddNote(LinkedList <Product_> products, Product_ product)
 {
     products.AddLast(product);
 }