/// <summary> /// 删除操作 /// </summary> /// <param name="oldValue">要删除的值</param> /// <returns>影响记录条数</returns> public int Delete(ModelView.SysCompanyView oldValue) { Model.TableModel.Sys_company model = View2Model(oldValue); List <Model.TableModel.Sys_company> modelList = new List <Model.TableModel.Sys_company>(); modelList.Add(model); return(DbEngine.QueryInt <Model.TableModel.Sys_company>("Delete", modelList)); }
/// <summary> /// 数据插入 /// </summary> /// <param name="newValue">新插入的值</param> /// <returns>影响记录条数</returns> public int Insert(ModelView.SysCompanyView newValue) { Model.TableModel.Sys_company model = View2Model(newValue); List <Model.TableModel.Sys_company> modelList = new List <Model.TableModel.Sys_company>(); modelList.Add(model); return(DbEngine.QueryInt <Model.TableModel.Sys_company>("Insert", modelList)); }
/// <summary> /// 删除操作 /// </summary> /// <param name="oldValues">要删除的多个值</param> /// <returns>影响记录条数</returns> public int Delete(List <ModelView.SysCompanyView> oldValues) { List <Model.TableModel.Sys_company> modelList = new List <Model.TableModel.Sys_company>(); foreach (ModelView.SysCompanyView item in oldValues) { Model.TableModel.Sys_company model = View2Model(item); modelList.Add(model); } return(DbEngine.QueryInt <Model.TableModel.Sys_company>("Delete", modelList)); }
/// <summary> /// 实体类转视图类 /// </summary> /// <param name="model">实体类</param> /// <returns>视图类</returns> private ModelView.SysCompanyView Model2View(Model.TableModel.Sys_company model) { ModelView.SysCompanyView view = new ModelView.SysCompanyView(); view.id = model.id; view.status_name = model.status_name; view.status_no = model.status_no; view.company_no = model.company_no; view.company_name = model.company_name; view.company_py = model.company_py; view.company_type = model.company_type; view.group_no = model.group_no; view.group_name = model.group_name; return(view); }
/// <summary> /// 视图类转实体类 /// </summary> /// <param name="view">视图类</param> /// <returns>实体类</returns> private Model.TableModel.Sys_company View2Model(ModelView.SysCompanyView view) { Model.TableModel.Sys_company model = new Model.TableModel.Sys_company(); if (string.IsNullOrEmpty(view.id)) { model.id = Common.Md5Operate.CreateGuidId(); } else { model.id = view.id; } GlobalDataCtrl globalDataCtrl = new GlobalDataCtrl(); model.company_no = string.IsNullOrEmpty(view.company_no) ? globalDataCtrl.GetNextNoByTblName("sys_company") : view.company_no; model.company_name = view.company_name; model.status_name = view.status_name; model.status_no = string.IsNullOrEmpty(view.status_no) ? "310" : view.status_no; model.group_no = string.IsNullOrEmpty(view.group_no) ? "dfs" : view.group_no; model.group_name = view.group_name; model.company_py = view.company_py; model.company_type = view.company_type; return(model); }