Exemplo n.º 1
0
        public bool UpdateItem(int Id, TB_M_Items item)
        {
            Console.Write("Insert your Id : ");
            Id = Convert.ToInt16(Console.ReadLine());
            var get = myContext.TB_M_Items.Find(Id);

            if (get != null)
            {
                Console.Write("Insert Your Name :");
                string Name = Console.ReadLine();
                get.Name = Name;
                myContext.Entry(get).State = EntityState.Modified;
                var result = (myContext.SaveChanges());
                if (result > 0)
                {
                    Console.Write("Update Succes");
                    status = true;
                }
                else
                {
                    Console.Write("Update Failed");
                }
            }
            else
            {
                Console.Write("Data Not Found");
            }
            return(status);
        }
Exemplo n.º 2
0
        public bool InsertItem(TB_M_Items items)
        {
            Console.Write("Insert your name : ");
            String Name = Console.ReadLine();

            Console.Write("Insert Supplier ID :");
            int TB_M_Suppliers_Id = Convert.ToInt16(Console.ReadLine());

            Console.Write("Insert Price :");
            int Price = Convert.ToInt16(Console.ReadLine());

            Console.Write("Insert Stock : ");
            int Stock = Convert.ToInt16(Console.ReadLine());


            items.Name             = Name;
            items.TB_M_Supplier_Id = TB_M_Suppliers_Id;
            items.Price            = Price;
            items.Stock            = Stock;
            myContext.TB_M_Items.Add(items);
            var result = (myContext.SaveChanges());

            if (result > 0)
            {
                status = true;
                Console.Write("Insert Successfully");
            }
            else
            {
                Console.Write("Insert Failed");
            }
            return(status);
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            //SupplierController suppliercontroller = new SupplierController();
            //ISupplier SupplierController = new ControllerSupplier();
            //SupplierController.viewAllData();
            //Console.Read();
            //ControllerSupplier.insertdata();
            //Console.Read();

            IItem      iitem;
            TB_M_Items item = new TB_M_Items();

            Console.WriteLine("======================");
            Console.WriteLine("Action");
            Console.WriteLine("======================");
            Console.WriteLine("1. View Data");
            Console.WriteLine("2. Insert");
            Console.WriteLine("3. Delete");
            Console.WriteLine("4. Upadate");
            Console.WriteLine("======================");
            Console.Write("Input Pilihan : ");

            //int number = Convert.ToInt32(Console.ReadLine());
            //if (number == 1)
            //{
            //    controlleritem.viewAllData();
            //}
            //else if (number == 2)
            //{
            //    iitem = new ControllerSupplier();
            //    iitem.InsertItem(TB_M_Items);
            //}
            //else if (number == 3)
            //{
            //    iitem = new ControllerSupplier();
            //    iitem.DeleteItem(TB_M_Items);
            //}
            //else if (number == 4)
            //{
            //    iitem = new ControllerSupplier();
            //    iitem.UpdateItem(TB_M_Items);
            //}
            //else
            //{
            //    Console.WriteLine("Not Data Found");
            //}
            //Console.Read();
        }