public ActionResult Edit(string id) { #region 检查参数 string currentPage = string.IsNullOrWhiteSpace(Request["CurrentPage"]) ? "1" : Request["CurrentPage"]; string backUrl = "/Home/Commodity/Index?backType=1&CurrentPage=" + currentPage; ViewBag.backUrl = backUrl; if (string.IsNullOrWhiteSpace(id)) { return Redirect(backUrl); } #endregion #region 获取商品信息 CommodityModel commodity = CommodityModel.SingleOrDefault(id); if (null == commodity) { return Redirect(backUrl); } CommodityViewModel model = new CommodityViewModel(commodity); return View(model); #endregion }
public string Edit(CommodityViewModel model) { #if DEBUG SysConfig.CurrentUser = UserModel.SingleOrDefault(3); #endif if (ModelState.IsValid) { CommodityModel commodity = CommodityModel.SingleOrDefault(model.Id); commodity.ChName = model.ChName; //中文名称 commodity.EnName = model.EnName; //英文名称 commodity.ProductCode = model.ProductCode; //商品货号 commodity.Type = model.Type; //商品类别 commodity.Unit = model.Unit; //商品单位 commodity.TariffRate = model.TariffRate; //关税率 commodity.VatRate = model.VatRate; //增值税率 commodity.RefundRate = model.RefundRate; //退税率 commodity.CustomsNo = model.CustomsNo; //海关编码 commodity.Remark = model.Remark; //备注 commodity.ModifyMan = SysConfig.CurrentUser.Id; //修改人 commodity.ModifyTime = DateTime.Now; //修改时间 int result = commodity.Update(); if (result > 0) { //记录操作日志 CommonMethod.Log(SysConfig.CurrentUser.Id, "Update", "Sys_Commodity"); return "1"; } } return "0"; }
public string Add(CommodityViewModel model) { #if DEBUG SysConfig.CurrentUser = UserModel.SingleOrDefault("3"); #endif if (ModelState.IsValid) { CommodityModel commodity = new CommodityModel(); commodity.No = CommonMethod.GetLatestSerialNo(SysConfig.SerialNo.CommodityNo); //商品编号 commodity.ChName = model.ChName; //中文名称 commodity.EnName = model.EnName; //英文名称 commodity.ProductCode = model.ProductCode; //商品货号 commodity.Type = model.Type; //商品类别 commodity.Unit = model.Unit; //商品单位 commodity.TariffRate = model.TariffRate; //关税率 commodity.VatRate = model.VatRate; //增值税率 commodity.RefundRate = model.RefundRate; //退税率 commodity.CustomsNo = model.CustomsNo; //海关编码 commodity.Remark = model.Remark; //备注 commodity.BelongsMan = CommonMethod.GetBelongsMan( //业务员 SysConfig.CurrentUser.Departmentid.ToString()); commodity.BelongsDepartment = CommonMethod.GetBelongsDepartment( //业务部门 SysConfig.CurrentUser.Departmentid.ToString()); commodity.ApprovalStatus = "4"; //默认生效 commodity.DelFlag = 0; //有效状态 commodity.CreateMan = SysConfig.CurrentUser.Id; //制单人 commodity.CreateTime = DateTime.Now; //制单时间 int result = commodity.Insert().ToInt(); if (result > 0) { //更新商品最大序列号 CommonMethod.UpdateSerialNo(SysConfig.SerialNo.CommodityNo); //记录操作日志 CommonMethod.Log(SysConfig.CurrentUser.Id, "Insert", "Sys_Commodity"); CommonMethod.Log(SysConfig.CurrentUser.Id, "Update", "Sys_SerialNo"); return "1"; } } return "0"; }