/// <summary> /// 数据更新 /// </summary> /// <param name="newValue">更新后对象</param> /// <returns>影响记录条数</returns> public int Update(ModelView.MpoPlanView newValue) { Model.TableModel.Mpo_plan model = View2Model(newValue); List <Model.TableModel.Mpo_plan> modelList = new List <Model.TableModel.Mpo_plan>(); modelList.Add(model); return(DbEngine.QueryInt <Model.TableModel.Mpo_plan>("update", modelList)); }
/// <summary> /// 实体类转视图类 /// </summary> /// <param name="model">实体类</param> /// <returns>视图类</returns> private ModelView.MpoPlanView Model2View(Model.TableModel.Mpo_plan model) { ModelView.MpoPlanView view = new ModelView.MpoPlanView(); view.id = model.id; view.plan_date = model.plan_date.HasValue ? ((DateTime)model.plan_date).Date.ToString("yyyy-MM-dd") : string.Empty; view.plan_date_value = model.plan_date.HasValue ? ((DateTime)model.plan_date).Date.ToString("yyyy-MM-dd") : DateTime.Now.Date.ToString("M/d/yyyy"); view.plan_qty = model.plan_qty.HasValue ? decimal.Round((decimal)model.plan_qty).ToString(): string.Empty; return(view); }
/// <summary> /// 更新操作 /// </summary> /// <param name="listNewValue">更新后的视图模板类的集合</param> /// <returns>影响记录条数</returns> public int Update(List <ModelView.MpoPlanView> listNewValue) { List <Model.TableModel.Mpo_plan> modelList = new List <Model.TableModel.Mpo_plan>(); foreach (ModelView.MpoPlanView item in listNewValue) { Model.TableModel.Mpo_plan model = View2Model(item); modelList.Add(model); } return(DbEngine.QueryInt <Model.TableModel.Mpo_plan>("update", modelList)); }
/// <summary> /// 删除操作 /// </summary> /// <param name="oldValues">要删除的多个值</param> /// <returns>影响记录条数</returns> public int Delete(List <ModelView.MpoPlanView> oldValues) { List <Model.TableModel.Mpo_plan> modelList = new List <Model.TableModel.Mpo_plan>(); foreach (ModelView.MpoPlanView item in oldValues) { Model.TableModel.Mpo_plan model = View2Model(item); modelList.Add(model); } return(DbEngine.QueryInt <Model.TableModel.Mpo_plan>("Delete", modelList)); }
/// <summary> /// 视图类转实体类 /// </summary> /// <param name="view">视图类</param> /// <returns>实体类</returns> private Model.TableModel.Mpo_plan View2Model(ModelView.MpoPlanView view) { Model.TableModel.Mpo_plan model = new Model.TableModel.Mpo_plan(); if (string.IsNullOrEmpty(view.id)) { model.id = Common.Md5Operate.CreateGuidId(); } else { model.id = view.id; } DateTime dt = DateTime.Now.Date; model.plan_date = string.IsNullOrEmpty(view.plan_date) ? DateTime.Now.Date : DateTime.TryParse(view.plan_date, out dt) ? dt.Date : DateTime.Now.Date; decimal tmpDec = 0; model.plan_qty = string.IsNullOrEmpty(view.plan_qty) ? 0 : (decimal.TryParse(view.plan_qty, out tmpDec) ? tmpDec : 0); return(model); }