Exemplo n.º 1
0
        public ActionResult SubmitHardwareType(HardwareTypeListModel model)
        {
            HttpSessionStateBase session = HttpContext.Session;
            try
            {

                Tbl_HardwareType tu = new Tbl_HardwareType();
                tu.Description = model.Description;
                tu.HardwareName = model.HardwareName;
                tu.HardwarePrice = model.HardwarePrice;
                tu.Hardware_ID = model.Hardware_ID;
                tu.Products_ID = model.Products_ID;
                tu.WarrantyPeriod = model.WarrantyPeriod;
                tu.LastUpdateUser_ID = Convert.ToInt32(session["UserID"]);
                tu.LastUpdateDate = DateTime.Now.ToString("yyyy-MM-dd");
                tu.LastUpdateTime = DateTime.Now.ToString("HH:mm");

                if (_hardwareService.AddNewHardwareType(tu))
                {
                    var gridModel = new DataSourceResult
                    {
                        ExtraData = new HardwareTypeListModel
                        {
                            Message = Message.OperationSuccessful,
                            MessageColor = "green"
                        },
                        Total = 1
                    };
                    return Json(gridModel);
                }
                else
                {
                    var gridModel = new DataSourceResult
                    {
                        ExtraData = new HardwareTypeListModel
                        {
                            Message = Message.OperationUnsuccessful,
                            MessageColor = "red"
                        },
                        Total = 1
                    };
                    return Json(gridModel);
                }

            }
            catch (Exception ex)
            {
                var gridModel = new DataSourceResult
                {
                    ExtraData = new HardwareTypeListModel
                    {
                        Message = Message.OperationUnsuccessful,
                        MessageColor = "red"
                    },
                    Total = 1
                };
                return Json(gridModel);
            }
            //return "";
        }
Exemplo n.º 2
0
 public ActionResult HardwareType()
 {
     HttpSessionStateBase session = HttpContext.Session;
     HardwareTypeListModel model = new HardwareTypeListModel();
     model.Product = GetProductDropDown();
     //model.TroubleShooting = _tsh.GetTroubleShootingList();
     //if (session["Customer_ID"] != null)
     //{
     //    model.CustomerName = _customerService.GetCustomerById(Convert.ToInt32(session["Customer_ID"])).CustomerName;
     //    session.Remove("Customer_ID");
     //}
     return View(model);
 }
Exemplo n.º 3
0
        public virtual ActionResult HardwareTypeList(DataSourceRequest command, HardwareTypeListModel model)
        {
            if (model.Hardware_ID == 0 && string.IsNullOrEmpty(model.Description) && string.IsNullOrEmpty(model.HardwareName) && model.HardwarePrice == 0 && model.Products_ID == 0 && string.IsNullOrEmpty(model.WarrantyPeriod))
            {
                var hardwareItems = _hardwareService.GetAllHardwareTypes();
                var gridModel = new DataSourceResult
                {

                    Data = hardwareItems.Select(x => new HardwareTypeModel
                    {
                         Product = _productService.GetProductById(x.Products_ID).ProductsName,
                         HardwareName = x.HardwareName,
                          HardwarePrice = x.HardwarePrice,
                           Hardware_ID = x.Hardware_ID,
                            Products_ID = x.Products_ID,
                             Description = x.Description,
                             WarrantyPeriod = x.WarrantyPeriod
                    }),
                    Total = hardwareItems.Count()
                };

                return Json(gridModel);
            }
            else
            {
                var hardwareItems = _hardwareService.SearchHardwareType(model.Description,model.HardwareName,model.HardwarePrice,model.Products_ID,model.WarrantyPeriod);
                var gridModel = new DataSourceResult
                {

                    Data = hardwareItems.Select(x => new HardwareTypeModel
                    {
                        Product = _productService.GetProductById(x.Products_ID).ProductsName,
                        HardwareName = x.HardwareName,
                        HardwarePrice = x.HardwarePrice,
                        Hardware_ID = x.Hardware_ID,
                        Products_ID = x.Products_ID,
                        Description = x.Description,
                        WarrantyPeriod = x.WarrantyPeriod
                    }),
                    Total = hardwareItems.Count()
                };

                return Json(gridModel);
            }
        }