/// <summary> /// 启用/禁用 /// </summary> /// <param name="accountStatus"></param> /// <returns></returns> public JsonRsp SetStatus(long[] Ids, int status) { if (Ids == null) { return(new JsonRsp { success = false, retmsg = "请选择要操作的数据" }); } MerchantTypeModel model = new MerchantTypeModel(); model.Status = status; model.UpdateId = AdminId; model.UpdateUser = AdminName; model.UpdateIP = Util.GetLocalIP; model.UpdateTime = DateTime.Now; OQL q = OQL.From(model) .Update(model.Status, model.UpdateId, model.UpdateUser, model.UpdateIP, model.UpdateIP) .Where(cmp => cmp.Comparer(model.ID, "IN", Ids)) //为了安全,不带Where条件是不会全部删除数据的 .END; int returnvalue = EntityQuery <MerchantTypeModel> .Instance.ExecuteOql(q); return(new JsonRsp { success = returnvalue > 0, code = returnvalue }); }
/// <summary> /// 删 /// </summary> /// <param name="model"></param> /// <returns></returns> public JsonRsp Remove(MerchantTypeModel model) { int returnvalue = EntityQuery <MerchantTypeModel> .Instance.Delete(model); return(new JsonRsp { success = returnvalue > 0, code = returnvalue }); }
/// <summary> /// 增 /// </summary> /// <param name="model"></param> /// <returns></returns> public JsonRsp Add(MerchantTypeModel model) { int returnvalue = Add <MerchantTypeModel>(model); return(new JsonRsp { success = returnvalue > 0, code = returnvalue }); }
/// <summary> /// 获取管理员列表(全部) /// </summary> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <returns></returns> public List <MerchantTypeModel> GetAllModelList() { MerchantTypeModel model = new MerchantTypeModel(); OQL q = OQL.From(model) .Select() .OrderBy(model.ID, "asc") .END; return(q.ToList <MerchantTypeModel>());//使用OQL扩展 }
/// <summary> /// save /// </summary> /// <param name="model"></param> /// <returns></returns> public JsonRsp Save(MerchantTypeModel model) { if (model.ID == 0) { return(Add(model)); } else { return(Update(model)); } }
/// <summary> /// 增 /// </summary> /// <param name="model"></param> /// <returns></returns> public JsonRsp Add(MerchantTypeModel model) { model.CreateId = AdminId; model.CreateUser = AdminName; model.CreateIP = Util.GetLocalIP(); model.CreateTime = DateTime.Now; int returnvalue = EntityQuery <MerchantTypeModel> .Instance.Insert(model); return(new JsonRsp { success = returnvalue > 0, code = returnvalue }); }
/// <summary> /// save /// </summary> /// <param name="model"></param> /// <returns></returns> public JsonRsp DeleteById(long[] Ids) { //删除 测试数据----------------------------------------------------- MerchantTypeModel user = new MerchantTypeModel(); OQL deleteQ = OQL.From(user) .Delete() .Where(cmp => cmp.Comparer(user.ID, "IN", Ids)) //为了安全,不带Where条件是不会全部删除数据的 .END; int returnvalue = EntityQuery <MerchantTypeModel> .Instance.ExecuteOql(deleteQ); return(new JsonRsp { success = returnvalue > 0, code = returnvalue }); }
/// <summary> /// 获取管理员列表(分页) /// </summary> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <returns></returns> public JsonRsp <MerchantViewModel> GetPageList(int pageIndex, int pageSize) { JsonRsp <MerchantViewModel> rsp = new JsonRsp <MerchantViewModel>(); MerchantModel model = new MerchantModel(); MerchantTypeModel MerchantType = new MerchantTypeModel(); model.TenantId = TenantId; //Select 方法不指定具体要选择的实体类属性,可以推迟到EntityContainer类的MapToList 方法上指定 OQL joinQ = OQL.From(model) .Join(MerchantType).On(model.MerchantTypeId, MerchantType.ID) .Select() .OrderBy(model.Sort, "desc") .END; joinQ.Limit(pageSize, pageIndex, true); PWMIS.DataProvider.Data.AdoHelper db = PWMIS.DataProvider.Adapter.MyDB.GetDBHelper(); EntityContainer ec = new EntityContainer(joinQ, db); rsp.data = (List <MerchantViewModel>)ec.MapToList <MerchantViewModel>(() => new MerchantViewModel() { ID = model.ID, MerchantTypeId = model.MerchantTypeId, MerchantTypeName = MerchantType.MerchantTypeName, MerchantName = model.MerchantName, LinkPhone = model.LinkPhone, LinkName = model.LinkName, LinkMobile = model.LinkMobile, MerchantArea = model.MerchantArea, MerchantAddress = model.MerchantAddress, CreateId = model.CreateId, CreateUser = model.CreateUser, CreateIP = model.CreateIP, CreateTime = model.CreateTime, Sort = model.Sort, Status = model.Status, UpdateBy = model.UpdateUser, UpdateIP = model.UpdateIP, UpdateTime = model.UpdateTime, }); rsp.success = true; rsp.code = 0; rsp.count = joinQ.PageWithAllRecordCount; return(rsp); }
/// <summary> /// 查 根据Id获取详情,如果没有则返回空对象 /// </summary> /// <param name="MerchanterID"></param> /// <returns></returns> public MerchantTypeModel GetModelById(int accountId) { MerchantTypeModel model = new MerchantTypeModel() { ID = accountId }; if (EntityQuery <MerchantTypeModel> .Fill(model)) { return(model); } else { return(null); } }
/// <summary> /// 获取管理员列表(分页) /// </summary> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <returns></returns> public JsonRsp <ProductTypeViewModel> GetPageList(string searchTxt, int pageIndex, int pageSize) { JsonRsp <ProductTypeViewModel> rsp = new JsonRsp <ProductTypeViewModel>(); ProductTypeModel pt = new ProductTypeModel(); MerchantTypeModel mt = new MerchantTypeModel(); OQLCompareFunc <ProductTypeModel> cmpFun = (cmp, u) => { OQLCompare cmpResult = null; //and 条件 cmpResult = cmpResult & cmp.Comparer(pt.ProductTypeName, OQLCompare.CompareType.Like, "%" + searchTxt + "%"); //or cmpResult = cmpResult | cmp.Comparer(pt.TenantId, OQLCompare.CompareType.Equal, TenantId); return(cmpResult); }; //Select 方法不指定具体要选择的实体类属性,可以推迟到EntityContainer类的MapToList 方法上指定 OQL joinQ = OQL.From(pt) .Join(mt).On(pt.MerchantTypeId, mt.ID) .Select(pt.ID, pt.ProductTypeName, mt.MerchantTypeName, pt.Status, pt.CreateTime) .Where(cmpFun) .OrderBy(pt.Sort, "desc") .END; joinQ.Limit(pageSize, pageIndex, true); PWMIS.DataProvider.Data.AdoHelper db = PWMIS.DataProvider.Adapter.MyDB.GetDBHelper(); EntityContainer ec = new EntityContainer(joinQ, db); rsp.data = (List <ProductTypeViewModel>)ec.MapToList <ProductTypeViewModel>(() => new ProductTypeViewModel() { ID = pt.ID, ProductTypeName = pt.ProductTypeName, MerchantTypeId = mt.ID, MerchantTypeName = mt.MerchantTypeName, CreateId = pt.CreateId, CreateUser = pt.CreateUser, CreateIP = pt.CreateIP, CreateTime = pt.CreateTime, Status = pt.Status, }); rsp.success = true; rsp.code = 0; rsp.count = joinQ.PageWithAllRecordCount; return(rsp); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(MerchantTypeModel model) { bool reValue = true; int reCount = 0; StringBuilder strSql = new StringBuilder(); strSql.Append("update MerchantType set "); strSql.Append(" MerchantTypeName = @MerchantTypeName , "); strSql.Append(" MerchantTypeMemo = @MerchantTypeMemo , "); strSql.Append(" MapPng = @MapPng , "); strSql.Append(" OrderNo = @OrderNo "); strSql.Append(" where MerchantTypeId=@MerchantTypeId "); SqlParameter[] parameters = { new SqlParameter("@MerchantTypeId", SqlDbType.Decimal, 9), new SqlParameter("@MerchantTypeName", SqlDbType.NVarChar, 50), new SqlParameter("@MerchantTypeMemo", SqlDbType.NVarChar, 2000), new SqlParameter("@MapPng", SqlDbType.NVarChar, 50), new SqlParameter("@OrderNo", SqlDbType.Int, 4) }; parameters[0].Value = model.MerchantTypeId; parameters[1].Value = model.MerchantTypeName; parameters[2].Value = model.MerchantTypeMemo; parameters[3].Value = model.MapPng; parameters[4].Value = model.OrderNo; try {//异常处理 reCount = this.helper.ExecSqlReInt(strSql.ToString(), parameters); } catch (Exception ex) { this.helper.Close(); throw ex; } if (reCount <= 0) { reValue = false; } return(reValue); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(MerchantTypeModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into MerchantType("); strSql.Append("MerchantTypeName,MerchantTypeMemo,MapPng,OrderNo"); strSql.Append(") values ("); strSql.Append("@MerchantTypeName,@MerchantTypeMemo,@MapPng,@OrderNo"); strSql.Append(") "); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@MerchantTypeName", SqlDbType.NVarChar, 50), new SqlParameter("@MerchantTypeMemo", SqlDbType.NVarChar, 2000), new SqlParameter("@MapPng", SqlDbType.NVarChar, 50), new SqlParameter("@OrderNo", SqlDbType.Int, 4) }; parameters[0].Value = model.MerchantTypeName; parameters[1].Value = model.MerchantTypeMemo; parameters[2].Value = model.MapPng; parameters[3].Value = model.OrderNo; bool result = false; try { helper.ExecSqlReInt(strSql.ToString(), parameters); result = true; } catch (Exception ex) { this.helper.Close(); throw ex; } finally { } return(result); }
/// <summary> /// 获取管理员列表(分页) /// </summary> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <returns></returns> public JsonRsp <MerchantTypeViewModel> GetPageList(int pageIndex, int pageSize) { JsonRsp <MerchantTypeViewModel> rsp = new JsonRsp <MerchantTypeViewModel>(); MerchantTypeModel m = new MerchantTypeModel(); OQL q = OQL.From(m) .Select() .OrderBy(m.ID, "asc") .END; //分页 q.Limit(pageSize, pageIndex, true); //q.PageWithAllRecordCount = allCount; //List<Employee> list= EntityQuery<Employee>.QueryList(q); List <MerchantTypeModel> list = q.ToList <MerchantTypeModel>();//使用OQL扩展 rsp.data = list.ConvertAll <MerchantTypeViewModel>(o => { return(new MerchantTypeViewModel() { ID = o.ID, MerchantTypeName = o.MerchantTypeName, CreateId = o.CreateId, CreateUser = o.CreateUser, CreateIP = o.CreateIP, CreateTime = o.CreateTime, Sort = o.Sort, Status = o.Status, UpdateBy = o.UpdateUser, UpdateIP = o.UpdateIP, UpdateTime = o.UpdateTime, }); } ); rsp.success = true; rsp.code = 0; rsp.count = q.PageWithAllRecordCount; return(rsp); }
public ActionResult Save(MerchantTypeModel model) { return(Json(bll.Save(model), JsonRequestBehavior.AllowGet)); }