Пример #1
0
        //Update data Item//

        public bool Update(int Id, TB_M_Item item)
        {
            string Name;
            int    Stock, Price;

            Console.Write("Insert your Id:");
            Id = Convert.ToInt16(Console.ReadLine());
            var get = ItemContext.TB_M_Item.Find(Id);

            //var get2 = context.suppliers.singleordefault(x => x.id == id);
            if (get != null)
            {
                Console.Write("Insert new Name:");
                Name = Console.ReadLine();
                Console.Write("Insert Item Price :");
                Stock = Convert.ToInt32(Console.ReadLine());
                Console.Write("Insert Stock :");
                Price     = Convert.ToInt32(Console.ReadLine());
                get.Name  = Name;
                get.Stock = Stock;
                get.Price = Price;
                ItemContext.Entry(get).State = EntityState.Modified;
                var        result = ItemContext.SaveChanges();
                validation valid  = new validation();
                return(valid.validate(result));
            }
            else
            {
                Console.Write("No Data Found");
                status = false;
            }
            return(status);
        }
Пример #2
0
        //Insert Data Item//

        public bool insert(TB_M_Item item)
        {
            string Name;
            int    Supplier_id, Price, Stock;

            Console.Write("Insert Name :          ");
            Name = Console.ReadLine();
            Console.Write("Insert Supplier ID :   ");
            Supplier_id = Convert.ToInt16(Console.ReadLine());
            Console.Write("Insert Price :         ");
            Price = Convert.ToInt32(Console.ReadLine());
            Console.Write("Insert Stock :         ");
            Stock = Convert.ToInt16(Console.ReadLine());

            TB_M_Item items = new TB_M_Item();

            item.Name        = Name;
            item.Supplier_id = Supplier_id;
            item.Price       = Price;
            item.Stock       = Stock;
            ItemContext.TB_M_Item.Add(item);
            var        result = ItemContext.SaveChanges();
            validation valid  = new validation();

            return(valid.validate(result));
        }