예제 #1
0
        public ActionResult Edit(int id)
        {
            var vm = new StockEditViewModel();

            vm.Stock = DBService.GetEntity <St_good>(id);
            vm.PCats = StockService.GetStockCats();
            return(View(vm));
        }
        public StockEditPage()
        {
            InitializeComponent();

            var item = new ProductModel();

            viewModel      = new StockEditViewModel(item);
            BindingContext = viewModel;
        }
예제 #3
0
        public UIElement GetEditView()
        {
            StockEditViewModel viewModel = new StockEditViewModel(factory, listViewModel);
            StockEditView      view      = new StockEditView(viewModel);

            viewModel.StockSaveRequest   += (s, e) => OnSave(e.Data);
            viewModel.StockDeleteRequest += (s, e) => OnDelete(e.Data, viewModel);

            return(view);
        }
예제 #4
0
        public ActionResult EditPOST(int id, StockEditViewModel model)
        {
            if (ModelState.IsValid)
            {
                var good = DBService.GetEntity <St_good>(id);
                good.Name  = model.name;
                good.CatId = model.catid;
                if (model.catid > 0)
                {
                    var ccat = DBService.GetEntity <St_cat>(model.catid);
                    if (ccat != null && ccat.Id > 0)
                    {
                        good.CatPath = ccat.Path;
                    }
                }
                good.Status = model.verifyed;
                if (string.IsNullOrEmpty(good.SerialNum))
                {
                    good.SerialNum = "WK" + DateTime.Now.ToString("yyMMdd") + good.Id;
                }
                good.Recommended  = model.recommended == 1;
                good.IsBrandGoods = model.branded == 1;

                if (good.Recommended == true && model.RecommendPic != null && model.RecommendPic.ContentLength > 0)
                {
                    try
                    {
                        DateTime now      = DateTime.Now;
                        string   vpath    = "/Site/Goods/" + now.ToString("yyyyMMdd") + "/";
                        string   realpath = Server.MapPath(vpath);
                        if (!Directory.Exists(realpath))
                        {
                            Directory.CreateDirectory(realpath);
                        }
                        string filename = model.RecommendPic.FileName;
                        if (System.IO.File.Exists(realpath + filename))
                        {
                            filename = now.Ticks.ToString() + "_" + filename;
                        }
                        model.RecommendPic.SaveAs(realpath + filename);
                        good.RecommendPic = vpath + filename;
                    }
                    catch
                    {
                    }
                }

                DBService.UpdateEntity <St_good>(good);
                return(RedirectToAction("Index"));
            }
            return(View(model));
        }
예제 #5
0
 private void OnDelete(StockEditDTO stockEditDTO, StockEditViewModel viewModel)
 {
     using (IStockController controller = factory.CreateStockController())
     {
         ControllerMessage controllerMessage = controller.Delete(stockEditDTO.OldStockNo);
         if (controllerMessage.IsSuccess)
         {
             Notify();
             viewModel.Clear();
         }
         else
         {
             MessageBox.Show(controllerMessage.Message);
         }
     }
 }
예제 #6
0
 public StockEditView(StockEditViewModel viewModel)
 {
     InitializeComponent();
     this.DataContext = viewModel;
 }
 public StockEditPage(StockEditViewModel viewModel)
 {
     InitializeComponent();
     BindingContext = this.viewModel = viewModel;
 }