예제 #1
0
        public List <ItemViewVM> GetItemView(ViewReportVM viewReport)
        {
            SqlConnection connection = new SqlConnection(connectionString);
            string        query      = @"SELECT * FROM Reports WHERE Id = " + viewReport.MemberId + " AND OrderDate = '" + viewReport.OrderDate.Date.ToString("d") + "';";
            SqlCommand    command    = new SqlCommand(query, connection);

            connection.Open();
            SqlDataReader     reader   = command.ExecuteReader();
            List <ItemViewVM> itemList = new List <ItemViewVM>();

            while (reader.Read())
            {
                ItemViewVM item = new ItemViewVM();

                item.ItemName   = reader["Name"].ToString();
                item.Quantity   = (decimal)reader["Quantity"];
                item.TotalPrice = (decimal)reader["Total"];

                itemList.Add(item);
            }

            reader.Close();
            connection.Close();
            return(itemList);
        }
        public ActionResult AddOrEditItem(int id = 0)
        {
            ViewBag.Locations = UoW.Locations.GetAll();
            ViewBag.GroupID   = new SelectList(UoW.Groups.GetAll(), "GpID", "Name");
            ViewBag.Products  = UoW.Products.GetAll();
            ViewBag.Unit      = new SelectList(UoW.Units.GetAll(), "Notation", "Notation");
            // InventoryItem item = new InventoryItem();
            ItemViewVM itemVM = new ItemViewVM();

            // itemVM.Locations = UoW.Locations.GetAll();
            itemVM.Item     = new InventoryItem();
            itemVM.Products = UoW.Products.GetAll();
            if (itemVM.Item.ItemID != 0)
            {
                itemVM.Item = UoW.Stocks.Get(id);
            }
            return(View(itemVM));
        }