protected void btnDelete_Click(object sender, EventArgs e) { List <Hi.Model.BD_Distributor> dis = new Hi.BLL.BD_Distributor().GetList("", " Compid=" + CompID + "", ""); foreach (Hi.Model.BD_Distributor model in dis) { new Hi.BLL.BD_Distributor().Delete(model.ID); List <Hi.Model.BD_DisAddr> Daddr = new Hi.BLL.BD_DisAddr().GetList("", " disid='" + model.ID + "'", ""); foreach (Hi.Model.BD_DisAddr mo in Daddr) { new Hi.BLL.BD_DisAddr().Delete(mo.ID); } List <Hi.Model.SYS_Users> user = new Hi.BLL.SYS_Users().GetList("", " disid='" + model.ID + "' and type=5", ""); foreach (Hi.Model.SYS_Users mo in user) { new Hi.BLL.SYS_Users().Delete(mo.ID); } } List <Hi.Model.BD_DisType> Dtype = new Hi.BLL.BD_DisType().GetList("", " Compid=" + CompID + "", ""); foreach (Hi.Model.BD_DisType model in Dtype) { new Hi.BLL.BD_DisType().Delete(model.ID); } }
public void datatbind() { DataTable dt = new Hi.BLL.BD_DisAddr().GetList("addr.[ID],addr.[principal],addr.[phone],addr.[Province],addr.[City],addr.[Area],addr.[Address],addr.[isdefault],dis.phone as disPhone", "BD_DisAddr as addr left join BD_Distributor as dis on addr.DisID=dis.ID", " addr.DisID=" + this.DisID + " and addr.dr=0", "addr.isdefault desc"); if (dt != null && dt.Rows.Count > 0) { this.rpt_addr.DataSource = dt; this.rpt_addr.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (!string.IsNullOrEmpty(treeid)) { Hi.Model.BD_DisAddr type = new Hi.BLL.BD_DisAddr().GetModel(treeid.ToInt(0)); if (type != null) { this.txt_product_class.Value = type.Address; this.hid_product_class.Value = type.ID.ToString(); } } } }
/// <summary> /// 代理商收货地址 /// </summary> /// <param name="DisId">代理商Id</param> public void DisAddr(int DisId) { List <Hi.Model.BD_DisAddr> li = new Hi.BLL.BD_DisAddr().GetList("", " isnull(dr,0)=0 and DisId=" + DisId, ""); if (li != null) { if (li.Count > 0) { foreach (Hi.Model.BD_DisAddr item in li) { Addrli.Add(item); } } } }
protected void A_DLT(object sender, EventArgs e) { HtmlAnchor adefat = sender as HtmlAnchor; string dltID = adefat.Attributes["deleteid"]; if (!string.IsNullOrEmpty(dltID)) { Hi.Model.BD_DisAddr disaddr = new Hi.BLL.BD_DisAddr().GetModel(int.Parse(dltID)); if (disaddr != null) { disaddr.dr = 1; disaddr.ts = DateTime.Now; disaddr.modifyuser = this.UserID; if (new Hi.BLL.BD_DisAddr().Update(disaddr)) { JScript.AlertMethod(this, "删除成功", JScript.IconOption.正确, "function (){ location.replace('" + ("DeliveryList.aspx") + "'); }"); } } } }
protected void Page_Load(object sender, EventArgs e) { DataSet ds = new Hi.BLL.BD_DisAddr().GetModel(this.DisID.ToString()); coutn = (ds.Tables[0].Rows.Count + 1).ToString(); rptdelivery.DataSource = ds; rptdelivery.DataBind(); dis = new Hi.BLL.BD_Distributor().GetModel(this.DisID); if (dis != null) { Principal = dis.Principal; Phone = dis.Phone; ID = dis.ID.ToString(); } string phone = new Hi.BLL.SYS_Users().GetModel(this.UserID).Phone; phones = AESHelper.Encrypt_php(phone); userphone = phone.Substring(0, 3) + "*****" + phone.Substring(phone.Length - 4); if (!string.IsNullOrEmpty(Request["type"]) && Request["type"].ToString() == "add") { Add_Addre(); } }
/// <summary> /// 获取推送类型 /// </summary> /// <returns></returns> public static string GetWXType(string sendType, string userID, string orderID) { string res = string.Empty; decimal num = 0; string orderInfo = string.Empty; string orderOut = String.Empty; Hi.Model.DIS_OrderOut outModel = null; Hi.Model.DIS_OrderReturn returnModel = null; List <Hi.Model.DIS_Logistics> list_log = null; Hi.Model.DIS_Logistics log = null; Hi.BLL.DIS_Logistics bll_log = new Hi.BLL.DIS_Logistics(); Hi.Model.SYS_Users user = new Hi.BLL.SYS_Users().GetModel(int.Parse(userID)); if (user == null || string.IsNullOrEmpty(user.OpenID)) { return(""); } Hi.Model.DIS_Order order = new Hi.BLL.DIS_Order().GetModel(int.Parse(orderID)); if (order == null) { return(""); } List <Hi.Model.DIS_OrderDetail> orderList = new Hi.BLL.DIS_OrderDetail().GetList("", " orderID=" + int.Parse(orderID), ""); if (orderList == null || orderList.Count == 0) { return(""); } foreach (Hi.Model.DIS_OrderDetail detail in orderList) { Hi.Model.BD_GoodsInfo goodsInfo = new Hi.BLL.BD_GoodsInfo().GetModel(detail.GoodsinfoID); if (goodsInfo != null) { Hi.Model.BD_Goods goods = new Hi.BLL.BD_Goods().GetModel(goodsInfo.GoodsID); orderInfo += " " + goods.GoodsName + "*" + detail.GoodsNum; } num += detail.GoodsNum; } Hi.Model.BD_DisAddr addr = new Hi.BLL.BD_DisAddr().GetModel(order.AddrID); if (addr != null) { if (addr.Phone != "") { orderOut += addr.Principal + ":" + addr.Phone + " "; } else { orderOut += addr.Principal + ":" + addr.Tel + " "; } } List <Hi.Model.DIS_OrderOut> orderout = new Hi.BLL.DIS_OrderOut().GetList("", " orderID=" + int.Parse(orderID), ""); if (orderout != null && orderout.Count != 0) { foreach (Hi.Model.DIS_OrderOut detail in orderout) { list_log = bll_log.GetList("", "OrderOutID = " + detail.ID + " and isnull(dr,0) == 0", ""); if (list_log != null && list_log.Count >= 0) { log = list_log[0]; //orderOut += log.ExpressPerson + ":" + log.ExpressTel + " "; } outModel = detail; } } List <Hi.Model.DIS_OrderReturn> returnlist = new Hi.BLL.DIS_OrderReturn().GetList("", " orderID=" + int.Parse(orderID), ""); if (returnlist != null && returnlist.Count != 0) { foreach (Hi.Model.DIS_OrderReturn detail in returnlist) { returnModel = detail; } } //string sqlstr = string.Format("select * from dis_order where receiptno like ('%{0}%') and dr=0", ReceiptNo); switch (sendType) { case "1": //下单通知 StringBuilder strSql = new StringBuilder(); strSql.Append("{\"type\":\"ORDERADD\",\"openid\":\""); strSql.Append(user.OpenID); strSql.Append("\",\"msg\":[{\"title\":\"尊敬的"); strSql.Append(user.TrueName); strSql.Append(",您好\",\"orderno\":\""); strSql.Append(order.ReceiptNo); strSql.Append("\",\"orderamount\":\""); strSql.Append(order.TotalAmount.ToString("N")); strSql.Append("元\",\"extra1\":\"状态:待付款\",\"extra2\":\"数量:"); strSql.Append(num.ToString("0.00")); strSql.Append("\",\"remark\":\""); strSql.Append(order.Remark); strSql.Append("\"}]}"); res = strSql.ToString(); break; case "2": //订单支付通知 StringBuilder str = new StringBuilder(); str.Append("{\"type\":\"ORDERPAY\",\"openid\":\""); str.Append(user.OpenID); str.Append("\",\"msg\":[{\"title\":\"尊敬的"); str.Append(user.TrueName); str.Append(",您好\",\"orderpay\":\""); str.Append(order.TotalAmount.ToString("N")); str.Append("元\",\"orderinfo\":\""); str.Append(orderInfo); str.Append("\",\"receiveinfo\":\""); str.Append(orderOut); str.Append("\",\"orderno\":\""); str.Append(order.ReceiptNo); str.Append("\",\"remark\":\""); str.Append("\"}]}"); res = str.ToString(); break; case "3": //42、签收提醒 StringBuilder SIGN = new StringBuilder(); SIGN.Append("{\"type\":\"SIGN\",\"openid\":\""); SIGN.Append(user.OpenID); SIGN.Append("\",\"msg\":[{\"title\":\"您好,您的订单"); SIGN.Append(order.ReceiptNo); SIGN.Append("已签收\",\"orderno\":\""); SIGN.Append(order.ReceiptNo); SIGN.Append("\",\"qianshouren\":\""); SIGN.Append(outModel.SignUser); SIGN.Append("\",\"qianshoushijian\":\""); SIGN.Append(outModel.SignDate); SIGN.Append("\",\"remark\":\""); SIGN.Append(order.Remark); SIGN.Append("\"}]}"); res = SIGN.ToString(); break; case "4": //退货申请 StringBuilder RETGOODS = new StringBuilder(); RETGOODS.Append("{\"type\":\"RETGOODS\",\"openid\":\""); RETGOODS.Append(user.OpenID); RETGOODS.Append("\",\"msg\":[{\"title\":\"买家申请退货"); RETGOODS.Append("\",\"orderno\":\""); RETGOODS.Append(order.ReceiptNo); RETGOODS.Append("\",\"shangpinxinxi\":\""); RETGOODS.Append(orderInfo); RETGOODS.Append("\",\"orderjine\":\""); RETGOODS.Append(order.TotalAmount.ToString("N")); RETGOODS.Append("元\",\"remark\":\""); RETGOODS.Append(order.Remark); RETGOODS.Append("\"}]}"); res = RETGOODS.ToString(); break; case "41": //代人下单通知 StringBuilder ORDERADD = new StringBuilder(); ORDERADD.Append("{\"type\":\"ORDERADD\",\"openid\":\""); ORDERADD.Append(user.OpenID); ORDERADD.Append("\",\"msg\":[{\"title\":\"尊敬的"); ORDERADD.Append(user.TrueName); ORDERADD.Append(",您好\",\"orderno\":\""); ORDERADD.Append(order.ReceiptNo); ORDERADD.Append("\",\"orderamount\":\""); ORDERADD.Append(order.TotalAmount.ToString("N")); ORDERADD.Append("元\",\"extra1\":\"状态:待付款\",\"extra2\":\"数量:"); ORDERADD.Append(num.ToString()); ORDERADD.Append("\",\"remark\":\""); ORDERADD.Append(order.Remark); ORDERADD.Append("\"}]}"); res = ORDERADD.ToString(); break; case "42": //订单审批 StringBuilder sql = new StringBuilder(); sql.Append("{\"type\":\"ORDERSTATUS\",\"openid\":\""); sql.Append(user.OpenID); sql.Append("\",\"msg\":[{\"title\":\"尊敬的"); sql.Append(user.TrueName); sql.Append(",您好\",\"orderno\":\""); sql.Append(order.ReceiptNo); if (order.OState.ToString() == "-1") { sql.Append("\",\"orderstatus\":\"订单退回\",\"remark\":\""); } else { sql.Append("\",\"orderstatus\":\"待发货、审批通过\",\"remark\":\""); } sql.Append(order.Remark); sql.Append("\"}]}"); res = sql.ToString(); break; case "43": //订单发货 StringBuilder sqlSend = new StringBuilder(); sqlSend.Append("{\"type\":\"ORDERSEND\",\"openid\":\""); sqlSend.Append(user.OpenID); sqlSend.Append("\",\"msg\":[{\"title\":\"尊敬的"); sqlSend.Append(user.TrueName); sqlSend.Append(",您好\",\"orderno\":\""); sqlSend.Append(order.ReceiptNo); sqlSend.Append("\",\"wuliuname\":\""); sqlSend.Append(log.ComPName); sqlSend.Append("\",\"wuliucode\":\""); sqlSend.Append(log.LogisticsNo); sqlSend.Append("\",\"remark\":\""); sqlSend.Append(outModel.Remark); sqlSend.Append("\"}]}"); res = sqlSend.ToString(); break; case "44": //6、退货审核 StringBuilder RETAUDIT = new StringBuilder(); RETAUDIT.Append("{\"type\":\"RETAUDIT\",\"openid\":\""); RETAUDIT.Append(user.OpenID); RETAUDIT.Append("\",\"msg\":[{\"title\":\"您好,您的退货审核"); if (returnModel.ReturnState == -1) { RETAUDIT.Append("已退回"); } else { RETAUDIT.Append("已审核"); } RETAUDIT.Append("\",\"shenhejieguo\":\""); if (returnModel.ReturnState == -1) { RETAUDIT.Append("已退回"); } else { RETAUDIT.Append("已审核"); } RETAUDIT.Append("\",\"shangpinxinxi\":\""); RETAUDIT.Append(orderInfo); RETAUDIT.Append("\",\"tuihuojine\":\""); RETAUDIT.Append(order.PayedAmount.ToString("N")); RETAUDIT.Append("元\",\"shenheshuoming\":\""); RETAUDIT.Append(returnModel.AuditRemark); RETAUDIT.Append("\",\"shenheshijian\":\""); RETAUDIT.Append(returnModel.AuditDate); RETAUDIT.Append("\",\"orderno\":\""); RETAUDIT.Append(order.ReceiptNo); RETAUDIT.Append("\",\"remark\":\""); RETAUDIT.Append("\"}]}"); res = RETAUDIT.ToString(); break; case "45": //5、退款 StringBuilder REFUND = new StringBuilder(); REFUND.Append("{\"type\":\"REFUND\",\"openid\":\""); REFUND.Append(user.OpenID); REFUND.Append("\",\"msg\":[{\"title\":\"您好,您的订单"); REFUND.Append(order.ReceiptNo); REFUND.Append(",已退款。\",\"reason\":\""); REFUND.Append(returnModel.ReturnContent); REFUND.Append("\",\"refund\":\""); REFUND.Append(order.PayedAmount.ToString("N")); REFUND.Append("元\",\"orderno\":\""); REFUND.Append(order.ReceiptNo); REFUND.Append("\",\"remark\":\""); REFUND.Append("\"}]}"); res = REFUND.ToString(); break; } return(res); }
/// <summary> /// 获取收货地址列表 /// </summary> /// <param name="JSon"></param> /// <returns></returns> public ResultAddr GetResellerShippingAddressList(string JSon, string version) { try { #region JSon取值 string userID = string.Empty; string compID = string.Empty; string disID = string.Empty; //当前列表最临界点产品ID:初始-1 JsonData JInfo = JsonMapper.ToObject(JSon); if (JInfo.Count > 0 && JInfo["UserID"].ToString() != "" || (JInfo["CompanyID"].ToString() != "" && JInfo["ResellerID"].ToString() != "")) { userID = JInfo["UserID"].ToString(); compID = JInfo["CompanyID"].ToString(); disID = JInfo["ResellerID"].ToString(); } else { return(new ResultAddr() { Result = "F", Description = "参数异常" }); } Hi.Model.SYS_Users user = new Hi.Model.SYS_Users(); if (version.ToLower() != "android" && version.ToLower() != "ios" && float.Parse(version) >= 6) { if (disID != "") { if (!new Common().IsLegitUser(int.Parse(userID), out user, 0, int.Parse(disID == "" ? "0" : disID))) { return new ResultAddr() { Result = "F", Description = "登录信息异常" } } ; } else { if (!new Common().IsLegitUser(int.Parse(userID), out user, int.Parse(compID), 0)) { return new ResultAddr() { Result = "F", Description = "登录信息异常" } } ; } } else { if (!new Common().IsLegitUser(int.Parse(userID), out user, 0, int.Parse(disID == "" ? "0" : disID))) { return new ResultAddr() { Result = "F", Description = "登录信息异常" } } ; } #endregion List <Hi.Model.BD_DisAddr> addrList = new Hi.BLL.BD_DisAddr().GetList("", " DisID='" + disID + "' and ISNULL(dr,0)=0", ""); if (addrList.Count == 0) { return new ResultAddr() { Result = "F", Description = "地址为空异常" } } ; List <DisAddress> DisAddressList = new List <DisAddress>(); foreach (var addr in addrList) { DisAddress disAdress = new DisAddress(); disAdress.DisAddressID = addr.ID.ToString(); disAdress.Name = addr.Name; disAdress.DisID = disID; disAdress.Principal = addr.Principal; disAdress.Phone = addr.Phone; disAdress.Tel = addr.Tel; disAdress.Province = addr.Province; disAdress.City = addr.City; disAdress.Area = addr.Area; disAdress.Zip = addr.Zip; disAdress.Address = addr.Address; disAdress.Remark = addr.Remark; disAdress.IsDefault = addr.IsDefault.ToString(); DisAddressList.Add(disAdress); } return(new ResultAddr() { Result = "T", Description = "获取成功", DisAddressList = DisAddressList }); } catch (Exception ex) { Common.CatchInfo(ex.Message + ":" + ex.StackTrace, "GetResellerShippingAddressList :" + JSon); return(new ResultAddr() { Result = "F", Description = "参数异常" }); } }
public ResultAddrAdd ResellerAddrAdd(string JSon) { try { #region JSon取值 string userID = string.Empty; string disID = string.Empty; string phoneCodeID = string.Empty; string MessageCode = string.Empty; string Principal = string.Empty; string Phone = string.Empty; string Province = string.Empty; string City = string.Empty; string Area = string.Empty; string Address = string.Empty; JsonData JInfo = JsonMapper.ToObject(JSon); if (JInfo.Count > 0 && JInfo["UserID"].ToString() != "" && JInfo["ResellerID"].ToString() != "" && JInfo["ChangePasswordID"].ToString() != "" && JInfo["MessageCode"].ToString() != "" && JInfo["Phone"].ToString() != "" && JInfo["Principal"].ToString() != "" && JInfo["Province"].ToString() != "" && JInfo["City"].ToString() != "" && JInfo["Area"].ToString() != "" && JInfo["Address"].ToString() != "") { userID = JInfo["UserID"].ToString(); disID = JInfo["ResellerID"].ToString(); phoneCodeID = JInfo["ChangePasswordID"].ToString(); MessageCode = JInfo["MessageCode"].ToString(); Phone = JInfo["Phone"].ToString(); Principal = JInfo["Principal"].ToString(); Province = JInfo["Province"].ToString(); City = JInfo["City"].ToString(); Area = JInfo["Area"].ToString(); Address = JInfo["Address"].ToString(); } else { return(new ResultAddrAdd() { Result = "F", Description = "参数异常" }); } Hi.Model.SYS_Users user = new Hi.Model.SYS_Users(); if (!new Common().IsLegitUser(int.Parse(userID), out user, 0, int.Parse(disID == "" ? "0" : disID))) { return new ResultAddrAdd() { Result = "F", Description = "登录信息异常" } } ; #endregion Hi.Model.SYS_PhoneCode code = new Hi.BLL.SYS_PhoneCode().GetModel(int.Parse(phoneCodeID)); if (code != null) { if (code.ts.AddMinutes(30) < DateTime.Now || code.IsPast == 1) { return new ResultAddrAdd() { Result = "F", Description = "验证码过期" } } ; if (code.UserID.ToString() != userID) { return new ResultAddrAdd() { Result = "F", Description = "非本人操作" } } ; if (code.PhoneCode != MessageCode) { return new ResultAddrAdd() { Result = "F", Description = "验证码错误" } } ; } else { return(new ResultAddrAdd() { Result = "F", Description = "验证码异常" }); } List <Hi.Model.BD_DisAddr> addrList = new Hi.BLL.BD_DisAddr().GetList("", "disid='" + disID + "' and ", ""); if (addrList != null) { if (addrList.Count >= 10) { return new ResultAddrAdd() { Result = "F", Description = "一个经销商收货地址最多为10个" } } ; if (addrList.Select(p => p.Address).Contains(Province + City + Area + Address)) { return new ResultAddrAdd() { Result = "F", Description = "经销商收货地址已经存在" } } ; } Hi.Model.BD_DisAddr addr = new Hi.Model.BD_DisAddr() { IsDefault = 0, Principal = Principal, Phone = Phone, Province = Province, City = City, Area = Area, Address = Province + City + Area + Address, CreateDate = DateTime.Now, CreateUserID = Convert.ToInt32(userID), modifyuser = Convert.ToInt32(userID), dr = 0 }; int count = new Hi.BLL.BD_DisAddr().Add(addr); if (count > 0) { return new ResultAddrAdd() { Result = "T", Description = "新增成功", AddrID = count } } ; else { return(new ResultAddrAdd() { Result = "F", Description = "新增失败" }); } } catch (Exception ex) { Common.CatchInfo(ex.Message + ":" + ex.StackTrace, "ResellerAddrAdd :" + JSon); return(new ResultAddrAdd { Result = "F", Description = "异常" }); } }
public EditResult AddResellerShippingAddressList(string JSon) { string UserID = string.Empty; string disID = string.Empty; string Principal = string.Empty; string Phone = string.Empty; string Province = string.Empty; string City = string.Empty; string Area = string.Empty; string Address = string.Empty; string IsDefault = string.Empty; try { #region JSon取值 JsonData JInfo = JsonMapper.ToObject(JSon); if (JInfo.Count <= 0 || JInfo["UserID"].ToString() == "" || JInfo["ResellerID"].ToString() == "" || JInfo["Province"].ToString() == "" || JInfo["City"].ToString() == "" || JInfo["Area"].ToString() == "" || JInfo["IsDefault"].ToString() == "") { return new EditResult() { Result = "F", Description = "参数异常" } } ; UserID = JInfo["UserID"].ToString(); disID = JInfo["ResellerID"].ToString(); Province = JInfo["Province"].ToString(); City = JInfo["City"].ToString(); Area = JInfo["Area"].ToString(); IsDefault = JInfo["IsDefault"].ToString(); if (JInfo["Principal"].ToString() == "") { return new EditResult() { Result = "F", Description = "联系人不能为空" } } ; if (JInfo["Phone"].ToString() == "") { return new EditResult() { Result = "F", Description = "联系电话不能为空" } } ; if (JInfo["Address"].ToString() == "") { return new EditResult() { Result = "F", Description = "详细地址不能为空" } } ; Principal = JInfo["Principal"].ToString(); Phone = JInfo["Phone"].ToString(); Address = JInfo["Address"].ToString(); #endregion //判断登录信息是否正确 Hi.Model.SYS_Users one = new Hi.Model.SYS_Users(); if (!new Common().IsLegitUser(Int32.Parse(UserID), out one, 0, Int32.Parse(disID == "" ? "0" : disID))) { return(new EditResult() { Result = "F", Description = "登录信息异常" }); } Hi.Model.BD_DisAddr disaddr = new Hi.Model.BD_DisAddr(); disaddr.DisID = Int32.Parse(disID); disaddr.Principal = Principal; disaddr.Phone = Phone; disaddr.Province = Province; disaddr.City = City; disaddr.Area = Area; disaddr.Address = Address; disaddr.IsDefault = IsDefault == "0" ? 0 : 1; disaddr.CreateUserID = one.ID; disaddr.CreateDate = DateTime.Now; disaddr.ts = DateTime.Now; disaddr.dr = 0; disaddr.modifyuser = one.ID; List <Hi.Model.BD_DisAddr> list_addr = null; if (IsDefault != "0") { list_addr = new Hi.BLL.BD_DisAddr().GetList("", "DisID=" + disID + " and isnull(IsDefault,0) =1 and isnull(dr,0) = 0", ""); } SqlConnection conn = new SqlConnection(SqlHelper.LocalSqlServer); conn.Open(); SqlTransaction mytran = conn.BeginTransaction(); try { if (new Hi.BLL.BD_DisAddr().Add(disaddr, mytran) <= 0) { mytran.Rollback(); return(new EditResult() { Result = "F", Description = "新增失败" }); } if (list_addr != null && list_addr.Count > 0) { foreach (Hi.Model.BD_DisAddr addr in list_addr) { addr.IsDefault = 0; if (!new Hi.BLL.BD_DisAddr().Update(addr, mytran)) { mytran.Rollback(); return(new EditResult() { Result = "F", Description = "新增失败" }); } } } } catch (Exception ex) { mytran.Rollback(); conn.Close(); Common.CatchInfo(ex.Message + ":" + ex.StackTrace, "AddResellerShippingAddressList:" + JSon); return(new EditResult() { Result = "F", Description = "新增失败" }); } mytran.Commit(); return(new EditResult() { Result = "T", Description = "新增成功" }); } catch (Exception ex) { Common.CatchInfo(ex.Message + ":" + ex.StackTrace, "AddResellerShippingAddressList:" + JSon); return(new EditResult() { Result = "F", Description = "新增失败" }); } }
public ResultOrderList GetBriefingList(string JSon) { try { string UserID = string.Empty; string CompID = string.Empty; string criticalOrderID = string.Empty; //当前列表最临界点产品ID:初始-1 string getType = string.Empty; //方向 string rows = string.Empty; string sortType = string.Empty; string sort = string.Empty; string datetype = string.Empty; string ordertype = string.Empty; #region//JSon取值 JsonData JInfo = JsonMapper.ToObject(JSon); if (JInfo.Count > 0 && JInfo["UserID"].ToString() != "" && JInfo["CompID"].ToString() != "" && JInfo["CriticalOrderID"].ToString() != "" && JInfo["GetType"].ToString() != "" && JInfo["Rows"].ToString() != "" && JInfo["SortType"].ToString() != "" && JInfo["Sort"].ToString() != "" && JInfo["DateType"].ToString() != "" && JInfo["OrderType"].ToString() != "") { UserID = JInfo["UserID"].ToString(); CompID = JInfo["CompID"].ToString(); criticalOrderID = JInfo["CriticalOrderID"].ToString(); getType = JInfo["GetType"].ToString(); rows = JInfo["Rows"].ToString(); sortType = JInfo["SortType"].ToString(); sort = JInfo["Sort"].ToString(); datetype = JInfo["DateType"].ToString(); ordertype = JInfo["OrderType"].ToString(); } else { return(new ResultOrderList() { Result = "F", Description = "参数异常" }); } #endregion //判断登录信息是否异常 Hi.Model.SYS_Users one = new Hi.Model.SYS_Users(); if (!new Common().IsLegitUser(int.Parse(UserID), out one, int.Parse(CompID == "" ? "0" : CompID))) { return new ResultOrderList() { Result = "F", Description = "登录信息异常" } } ; //判断经销商信息是否异常 Hi.Model.BD_Company comp = new Hi.BLL.BD_Company().GetModel(Convert.ToInt32(CompID)); if (comp == null || comp.dr == 1 || comp.AuditState == 0 || comp.IsEnabled == 0) { return new ResultOrderList() { Result = "F", Description = "核心企业异常" } } ; DateTime date = DateTime.Now; DateTime date_start = new DateTime(); DateTime date_end = date.AddDays(1); //string strdate_start = string.Empty; // string strdate_end = date_end.ToString("yyyy-MM-dd"); string strwhere = ""; switch (datetype) { case "0": date_start = new DateTime(date.Year, date.Month, date.Day, 0, 0, 0); //strdate_start = date_start.ToString("yyyy-MM-dd"); break; case "1": DateTime startWeek = date.AddDays(1 - Convert.ToInt32(date.DayOfWeek.ToString("d"))); date_start = new DateTime(startWeek.Year, startWeek.Month, startWeek.Day, 0, 0, 0); //strdate_start = date_start.ToString("yyyy-MM-dd"); break; case "2": date_start = new DateTime(date.Year, date.Month, 1); //strdate_start = date_start.ToString("yyyy-MM-dd"); break; default: return(new ResultOrderList() { Result = "F", Description = "时间段类型异常" }); break; } switch (ordertype) { case "0": strwhere = " and isnull(dr,0)=0 and Otype!=9 and CompID=" + comp.ID + " and OState in (2,3,4,5,7) and CreateDate>='" + date_start + "' and CreateDate<='" + date_end + "'"; break; case "1": strwhere = " and isnull(dr,0)=0 and CompID=" + comp.ID + " and CreateDate>='" + date_start + "' and CreateDate<='" + date_end + "' and ReturnState =3"; break; case "2": string sql = "SELECT distinct orderID FROM [dbo].[CompCollection_view] where OrderID not in(select ID from Dis_Order where ISNULL(dr,0)=0 and (Otype=9 or OState not in(2,3,4,5,7)) and CompID=" + comp.ID + ") and status!=3 and CompID=" + comp.ID + " and Date>='" + date_start + "' and Date<'" + date_end + "' AND vedf9=1 "; DataTable dt_pay = SqlHelper.Query(SqlHelper.LocalSqlServer, sql).Tables[0]; string where = ""; for (int i = 0; i < dt_pay.Rows.Count; i++) { if (ClsSystem.gnvl(dt_pay.Rows[i]["orderID"], "") != "") { where += ","; where += ClsSystem.gnvl(dt_pay.Rows[i]["orderID"], ""); } } where = where.Substring(1, where.Length - 1); strwhere = " and id in (" + where + ")"; break; default: return(new ResultOrderList() { Result = "F", Description = "订单类型异常" }); break; } if (sortType == "1") //价格排序 { sortType = "CreateDate"; } else if (sortType == "2") //价格排序 { sortType = "TotalAmount"; } else { sortType = "ID"; } string strsql = new Common().PageSqlString(criticalOrderID, "ID", "DIS_Order", sortType, sort, strwhere, getType, rows); if (strsql == "") { return new ResultOrderList() { Result = "F", Description = "基础数据异常" } } ; #region 赋值 List <Order> OrderList = new List <Order>(); DataSet ds = SqlHelper.Query(SqlHelper.LocalSqlServer, strsql); if (ds.Tables.Count == 0) { return new ResultOrderList() { Result = "T", Description = "没有更多数据" } } ; DataTable orderList = ds.Tables[0]; if (orderList != null) { if (orderList.Rows.Count == 0) { return new ResultOrderList() { Result = "T", Description = "没有更多数据" } } ; foreach (DataRow row in orderList.Rows) { Order order = new Order(); Hi.Model.DIS_Order orderModel = new Hi.BLL.DIS_Order().GetModel(int.Parse(row["ID"].ToString())); if (orderModel == null || orderModel.dr == 1) { return new ResultOrderList() { Result = "F", Description = "订单异常" } } ; order.OrderID = orderModel.ID.ToString(); order.CompID = orderModel.CompID.ToString(); order.CompName = comp.CompName; order.State = Common.GetCompOrderType(orderModel.OState, orderModel.PayState, orderModel.Otype, orderModel.ReturnState); string IsEnSend, IsEnPay, IsEnReceive, IsEnReturn, IsEnAudit; Common.GetEspecialType(orderModel.OState.ToString(), orderModel.PayState.ToString(), orderModel.Otype.ToString(), orderModel.ReturnState.ToString(), out IsEnSend, out IsEnPay, out IsEnAudit, out IsEnReceive, out IsEnReturn); order.IsEnSend = IsEnSend; order.IsEnPay = IsEnPay; order.IsEnAudit = IsEnAudit; order.IsEnReceive = IsEnReceive; order.IsEnReturn = IsEnReturn; order.Otype = orderModel.Otype.ToString(); order.AddType = orderModel.AddType.ToString(); order.OState = orderModel.OState.ToString(); order.PayState = orderModel.PayState.ToString(); order.ReturnState = orderModel.ReturnState.ToString(); order.DisID = orderModel.DisID.ToString(); Hi.Model.BD_Distributor dis = new Hi.BLL.BD_Distributor().GetModel(orderModel.DisID); if (dis == null || dis.AuditState == 0 || dis.dr == 1) { return new ResultOrderList() { Result = "F", Description = "经销信息商异常" } } ; order.DisName = dis.DisName; order.DisUserID = orderModel.DisUserID.ToString(); Hi.Model.SYS_Users user = new Hi.BLL.SYS_Users().GetModel(int.Parse(order.DisUserID)); //if (user == null || user.IsEnabled == 0 || user.dr == 1) // return new ResultOrderList() { Result = "F", Description = "经销商用户信息异常" }; //order.DisUserName = orderModel.DisUserName; if (user != null && user.IsEnabled == 1 && user.dr == 0) { order.DisUserName = user.TrueName; } else { order.DisUserName = ""; } order.AddrID = orderModel.AddrID.ToString(); order.ReceiptNo = orderModel.ReceiptNo; if (ClsSystem.gnvl(orderModel.ArriveDate, "") != "0001/1/1 0:00:00" && ClsSystem.gnvl(orderModel.ArriveDate, "") != "") { order.ArriveDate = orderModel.ArriveDate.ToString("yyyy-MM-dd"); } if (!string.IsNullOrEmpty(orderModel.AddrID.ToString())) { Hi.Model.BD_DisAddr addr = new Hi.BLL.BD_DisAddr().GetModel(orderModel.AddrID); if (addr != null) { order.Zip = addr.Zip; } } order.Address = orderModel.Address; order.Contact = orderModel.Principal; order.Phone = orderModel.Phone; order.TotalAmount = orderModel.AuditAmount.ToString("0.00"); order.AuditTotalAmount = orderModel.AuditAmount.ToString("0.00"); order.PayedAmount = orderModel.PayedAmount.ToString("0.00"); order.CreateUserID = orderModel.CreateUserID.ToString(); order.CreateDate = orderModel.CreateDate.ToString("yyyy-MM-dd HH:mm"); order.ReturnMoneyDate = orderModel.ReturnMoneyDate.ToString(); order.ReturnMoneyUser = orderModel.ReturnMoneyUser; order.ReturnMoneyUserId = orderModel.ReturnMoneyUserId.ToString(); List <Hi.Model.DIS_OrderOut> outList = new Hi.BLL.DIS_OrderOut().GetList("", " OrderID='" + orderModel.ID + "' and CompID='" + orderModel.CompID + "' and DisID='" + orderModel.DisID + "' and ISNULL(dr,0)=0", ""); if (outList.Count != 0) { Hi.Model.DIS_OrderOut orderOut = new Hi.Model.DIS_OrderOut(); foreach (Hi.Model.DIS_OrderOut Out in outList) { orderOut = Out; } order.SendID = orderOut.ID.ToString(); order.SendDate = orderOut.SendDate.ToString(); ////order.Express = orderOut.Express; ////order.ExpressNo = orderOut.ExpressNo; ////order.ExpressPerson = orderOut.ExpressPerson; ////order.ExpressTel = orderOut.ExpressTel; ////order.ExpressBao = orderOut.ExpressBao; ////order.PostFee = orderOut.PostFee.ToString("0.00"); order.ActionUser = orderOut.ActionUser; List <Hi.Model.DIS_Logistics> exlist = Common.GetExpress(orderOut.ID.ToString()); if (exlist != null) { order.SendRemark = exlist[0].Context; } order.IsAudit = orderOut.IsAudit.ToString(); order.AuditUserID = orderOut.AuditUserID.ToString(); order.AuditDate = orderOut.AuditDate.ToString(); order.AuditRemark = orderOut.AuditRemark == null ? "" : orderOut.AuditRemark.ToString(); order.SignDate = orderOut.SignDate.ToString(); order.IsSign = orderOut.IsSign.ToString(); order.SignUserId = orderOut.SignUserId.ToString(); order.SignUser = orderOut.SignUser; order.SignRemark = orderOut.SignRemark; } //todo:不知道的排序 //order.SortIndex = orderModel.SortIndex.ToString(); order.IsDel = orderModel.dr.ToString(); //明细 List <OrderDetail> orderDetail = new List <OrderDetail>(); List <Hi.Model.DIS_OrderDetail> detailList = new Hi.BLL.DIS_OrderDetail().GetList("", " OrderID='" + orderModel.ID + "' and DisID='" + orderModel.DisID + "' and ISNULL(dr,0)=0", ""); if (detailList == null) //|| detailList.Count==0 { return new ResultOrderList() { Result = "F", Description = "订单明细异常" } } ; List <Hi.Model.BD_GoodsAttrs> list_attrs = null; foreach (Hi.Model.DIS_OrderDetail detail in detailList) { string SKUName = string.Empty; OrderDetail ordetail = new OrderDetail(); ordetail.SKUID = detail.GoodsinfoID.ToString(); //通过GoodsInfoID找到GoodsID Hi.Model.BD_GoodsInfo goodsInfo = new Hi.BLL.BD_GoodsInfo().GetModel(detail.GoodsinfoID); if (goodsInfo == null) { //if (goodsInfo == null || goodsInfo.IsEnabled == false || goodsInfo.dr == 1) return new ResultOrderList() { Result = "F", Description = "SKU信息异常" } } ; ordetail.ProductID = goodsInfo.GoodsID.ToString(); //通过GoodsID找到GoodsName Hi.Model.BD_Goods goods = new Hi.BLL.BD_Goods().GetModel(goodsInfo.GoodsID); if (goods == null) { //if (goods == null || goods.IsEnabled == 0 | goods.dr == 1) return new ResultOrderList() { Result = "F", Description = "商品异常" } } ; ordetail.ProductName = goods.GoodsName; SKUName += goods.GoodsName; list_attrs = new Hi.BLL.BD_GoodsAttrs().GetList("AttrsName", "GoodsID = " + goodsInfo.GoodsID + " and CompID = " + comp.ID + " and ISNULL(dr,0) = 0", ""); if (list_attrs != null && list_attrs.Count != 0) { foreach (Hi.Model.BD_GoodsAttrs attr in list_attrs) { SKUName += attr.AttrsName; } } ordetail.SKUName = SKUName; //todo:描述是什么 ordetail.ValueInfo = goodsInfo.ValueInfo; ordetail.SalePrice = detail.Price.ToString("0.00"); ordetail.TinkerPrice = detail.AuditAmount.ToString("0.00"); ordetail.Num = detail.GoodsNum.ToString("0.00"); ordetail.Remark = detail.Remark; //ordetail.IsPro = .Trim() == "0" || detail.vdef1.Trim() == "" ? "0" : "1"; //是否是促销商品 //是否是促销商品 ordetail.IsPro = ClsSystem.gnvl(detail.vdef1, "").Trim() == "0" || ClsSystem.gnvl(detail.vdef1, "").Trim() == "" ? "0" : "1"; if (ordetail.IsPro != "0") { ordetail.ProNum = detail.vdef5; if (detail.vdef1 != "" && detail.vdef1.Length > 0) { Hi.Model.BD_Promotion pro = new Hi.BLL.BD_Promotion().GetModel(Convert.ToInt32(detail.vdef1)); if (pro != null) { List <Hi.Model.BD_PromotionDetail> dList = new Hi.BLL.BD_PromotionDetail().GetList( "", " ProID=" + pro.ID + " and GoodInfoID ='" + ordetail.SKUID + "' and dr=0", ""); string info = string.Empty; if (dList != null && dList.Count > 0) { if (pro.Type == 0 && pro.ProType == 1) { info = "赠品"; } else if (pro.Type == 0 && pro.ProType == 2) { info = "商品优惠价" + dList[0].GoodsPrice.ToString("0.00"); } else if (pro.Type == 1 && pro.ProType == 3) { info = "商品数量满" + pro.Discount.ToString("0.00") + "赠" + dList[0].GoodsPrice.ToString("0.00") + dList[0].GoodsUnit; } else if (pro.Type == 1 && pro.ProType == 4) { info = "商品打折" + pro.Discount.ToString("0.00") + "%"; } } ordetail.proInfo = new PromotionInfo() { ProID = detail.vdef1, ProTitle = pro.ProTitle, ProInfos = info, Type = pro.Type.ToString(), ProTpye = pro.ProType.ToString(), Discount = pro.Discount.ToString("0.00"), ProStartTime = pro.ProStartTime.ToString("yy-MM-dd"), ProEndTime = pro.ProEndTime.ToString("yy-MM-dd") }; } } } List <Pic> Pic = new List <Pic>(); if (goods.Pic != "" && goods.Pic != "X") { Pic pic = new Pic(); pic.ProductID = goodsInfo.GoodsID.ToString(); pic.IsDeafult = "1"; pic.PicUrl = ConfigurationManager.AppSettings["ImgViewPath"].ToString().Trim() + "GoodsImg/" + goods.Pic; Pic.Add(pic); } ordetail.ProductPicUrlList = Pic; orderDetail.Add(ordetail); } order.OrderDetailList = orderDetail; OrderList.Add(order); } } else { return(new ResultOrderList() { Result = "F", Description = "没有更多数据" }); } #endregion return(new ResultOrderList() { Result = "T", Description = "获取成功", OrderList = OrderList }); } catch (Exception ex) { Common.CatchInfo(ex.Message + ":" + ex.StackTrace, "GetBriefingList:" + JSon); return(new ResultOrderList() { Result = "F", Description = "参数异常" }); } }
/// <summary> ///核心企业新增经销商 /// </summary> /// <param name="JSon"></param> /// <returns></returns> public ReseltResellerEdit AddReseller(string JSon) { string UserID = string.Empty; string CompID = string.Empty; try { #region//JSon取值 JsonData JInfo = JsonMapper.ToObject(JSon); if (JInfo["UserID"].ToString().Trim() == "" || JInfo["CompID"].ToString().Trim() == "" || JInfo["Reseller"].ToString().Trim() == "") { return new ReseltResellerEdit() { Result = "F", Description = "参数异常" } } ; UserID = JInfo["UserID"].ToString(); CompID = JInfo["CompID"].ToString(); JsonData Reseller = JInfo["Reseller"]; //判断登录信息是否异常 Hi.Model.SYS_Users one = new Hi.Model.SYS_Users(); if (!new Common().IsLegitUser(int.Parse(UserID), out one, Int32.Parse(CompID))) { return(new ReseltResellerEdit() { Result = "F", Description = "登录信息异常" }); } //判断核心企业信息是否异常 Hi.Model.BD_Company comp = new Hi.BLL.BD_Company().GetModel(Int32.Parse(CompID)); if (comp == null || comp.dr == 1 || comp.IsEnabled == 0 || comp.AuditState == 0) { return new ReseltResellerEdit() { Result = "F", Description = "核心企业信息异常" } } ; #endregion #region//判断传入的经销商信息是否正确 string resellername = Common.NoHTML(Reseller["ResellerName"].ToString().Trim()); string resellercode = Common.NoHTML(Reseller["ResellerCode"].ToString().Trim()); string address = Common.NoHTML(Reseller["Address"].ToString().Trim()); if (resellername == "") { return new ReseltResellerEdit() { Result = "F", Description = "请输入经销商名称" } } ; //判断经销商名字是否已存在 if (Common.DisExistsAttribute("DisName", resellername, CompID.ToString())) { return new ReseltResellerEdit() { Result = "F", Description = "经销商名称已经存在" } } ; if (Reseller["ResellerProvince"].ToString().Trim() == "") { return new ReseltResellerEdit() { Result = "F", Description = "请选择经销商地址中的省" } } ; if (Reseller["ResellerCity"].ToString().Trim() == "") { return new ReseltResellerEdit() { Result = "F", Description = "请选择经销商地址中的市" } } ; if (Reseller["ResellerArea"].ToString().Trim() == "") { return new ReseltResellerEdit() { Result = "F", Description = "请选择经销商地址中的区" } } ; if (address == "") { return new ReseltResellerEdit() { Result = "F", Description = "请输入经销商地址中的详细地址" } } ; #endregion #region//判断登录信息的正确信 JsonData account = Reseller["Account"]; string username = Common.NoHTML(account["UserName"].ToString().Trim()); string truename = Common.NoHTML(account["TrueName"].ToString().Trim()); if (account["UserName"].ToString().Trim() == "") { return new ReseltResellerEdit() { Result = "F", Description = "请输入登录账号" } } ; //判断登录账号是否已经存在 if (Common.GetUserExists(username)) { return new ReseltResellerEdit() { Result = "F", Description = "该登录账号已存在" } } ; if (truename == "") { return new ReseltResellerEdit() { Result = "F", Description = "请输入姓名" } } ; if (account["Phone"].ToString().Trim() == "") { return new ReseltResellerEdit() { Result = "F", Description = "请登录信息中的手机号码" } } ; //判断手机号有没被注册过 Regex Phonereg = new Regex("^0?(13[0-9]|15[012356789]|18[0-9]|14[57]|17[7])[0-9]{8}$"); if (!Phonereg.IsMatch(account["Phone"].ToString())) { return new ReseltResellerEdit() { Result = "F", Description = "登录信息中的手机号格式错误" } } ; if (Common.GetUserExists("Phone", account["Phone"].ToString())) { return new ReseltResellerEdit() { Result = "F", Description = "登录信息中的手机号已被注册" } } ; #endregion //创建需要导入的经销商实体 Hi.Model.BD_Distributor disModel = new Hi.Model.BD_Distributor(); disModel.CompID = comp.ID; disModel.DisCode = resellercode; disModel.DisName = resellername; //传入分类ID的话,判断分类ID是否正确 if (Reseller["ResellerClassifyID"].ToString().Trim() != "" && Reseller["ResellerClassifyID"].ToString() != "0") { Hi.Model.BD_DisType distpye = new Hi.BLL.BD_DisType().GetModel(Int32.Parse(Reseller["ResellerClassifyID"].ToString().Trim())); if (distpye == null || distpye.CompID != comp.ID) { return new ReseltResellerEdit() { Result = "F", Description = "经销商分类异常" } } ; if (distpye.dr == 1) { return new ReseltResellerEdit() { Result = "F", Description = "此经销商分类已被删除" } } ; //if (distpye.IsEnabled != 0) // return new ReseltResellerEdit() { Result = "F", Description = "此经销商分类已被禁用" }; disModel.DisTypeID = distpye.ID; } else { disModel.DisTypeID = 0; } //传入区域ID的话,判断区域ID是否正确 if (Reseller["AreaID"].ToString().Trim() != "" && Reseller["AreaID"].ToString() != "0") { Hi.Model.BD_DisArea disarea = new Hi.BLL.BD_DisArea().GetModel(Int32.Parse(Reseller["AreaID"].ToString().Trim())); if (disarea == null || disarea.CompanyID != comp.ID) { return new ReseltResellerEdit() { Result = "F", Description = "经销商区域异常" } } ; if (disarea.dr == 1) { return new ReseltResellerEdit() { Result = "F", Description = "此经销商区域已被删除" } } ; disModel.AreaID = disarea.ID; } else { disModel.AreaID = 0; } disModel.DisLevel = ""; disModel.Province = Reseller["ResellerProvince"].ToString(); disModel.City = Reseller["ResellerCity"].ToString(); disModel.Area = Reseller["ResellerArea"].ToString(); disModel.Address = address; //没输入经销商中的联系人,需要将登录信息的姓名赋值给联系人 string principal = Common.NoHTML(Reseller["Principal"].ToString().Trim()); string phone = Common.NoHTML(Reseller["Phone"].ToString().Trim()); if (principal == "") { disModel.Principal = truename; } else { disModel.Principal = principal; } //没输入联系人手机号,需要将登录信息中的手机号赋值给联系人手机号 if (phone == "") { disModel.Phone = account["Phone"].ToString(); } else { disModel.Phone = phone; } disModel.Leading = ""; disModel.LeadingPhone = ""; disModel.Licence = ""; disModel.Tel = Common.NoHTML(Reseller["Tel"].ToString()); disModel.Zip = Common.NoHTML(Reseller["Zip"].ToString()); disModel.Fax = Common.NoHTML(Reseller["Fax"].ToString()); disModel.Remark = ""; disModel.DisAccount = 0; disModel.IsCheck = 1; disModel.CreditType = 0; disModel.CreditAmount = 0; disModel.Paypwd = Common.md5("123456"); disModel.AuditState = 2; disModel.IsEnabled = 1; disModel.CreateUserID = one.ID; disModel.CreateDate = DateTime.Now; disModel.ts = DateTime.Now; disModel.dr = 0; disModel.modifyuser = one.ID; //开启事务,并将dismodel插入经销商表中 SqlConnection conn = new SqlConnection(SqlHelper.LocalSqlServer); //开启数据库连接 if (conn.State.ToString().ToLower() != "open") { conn.Open(); } //开启事务 SqlTransaction mytran = conn.BeginTransaction(); int DisID = 0; try { //在经销商表中插入一条数据 if ((DisID = new Hi.BLL.BD_Distributor().Add(disModel, mytran)) > 0) { //经销商表插入成功的话继续新增角色 List <Hi.Model.SYS_Role> list_role = new Hi.BLL.SYS_Role().GetList("", "isnull(dr,0)=0 and isenabled=1 and DisID=" + DisID + " and RoleName='企业管理员'", ""); if (list_role == null || list_role.Count == 0) { //新增角色(企业管理员) Hi.Model.SYS_Role role = new Hi.Model.SYS_Role(); role.CompID = comp.ID; role.DisID = DisID; role.RoleName = "企业管理员"; role.IsEnabled = 1; role.SortIndex = "1"; role.CreateDate = DateTime.Now; role.CreateUserID = one.ID; role.ts = DateTime.Now; role.modifyuser = one.ID; role.dr = 0; int Roid = new Hi.BLL.SYS_Role().Add(role, mytran); //新增管理员用户和角色 Hi.Model.SYS_Users user = new Hi.Model.SYS_Users(); user.UserName = username; // user.CompID = CompID; // user.Type = 5; // user.RoleID = Roid; user.TrueName = truename; user.UserPwd = Common.md5("123456"); user.Phone = account["Phone"].ToString(); user.AuditState = 2; user.IsEnabled = 1; user.CreateUserID = one.ID; user.CreateDate = DateTime.Now; user.ts = DateTime.Now; user.modifyuser = one.ID; int AddUserid = new Hi.BLL.SYS_Users().Add(user, mytran); ///用户明细表 Hi.Model.SYS_CompUser CompUser = new Hi.Model.SYS_CompUser(); CompUser.CompID = comp.ID; CompUser.DisID = DisID; CompUser.CreateDate = DateTime.Now; CompUser.CreateUserID = one.ID; CompUser.modifyuser = one.ID; CompUser.CType = 2; CompUser.UType = 5; CompUser.IsEnabled = 1; CompUser.IsAudit = 2; CompUser.RoleID = 0; CompUser.ts = DateTime.Now; CompUser.dr = 0; CompUser.UserID = AddUserid; int compuserid = new Hi.BLL.SYS_CompUser().Add(CompUser, mytran); //新增角色用户 Hi.Model.SYS_RoleUser RoleUser = new Hi.Model.SYS_RoleUser(); RoleUser.FunType = 1; RoleUser.UserID = AddUserid; RoleUser.RoleID = Roid; RoleUser.IsEnabled = true; RoleUser.CreateUser = UserID; RoleUser.CreateDate = DateTime.Now; RoleUser.ts = DateTime.Now; RoleUser.dr = 0; int roleuserid = new Hi.BLL.SYS_RoleUser().Add(RoleUser, mytran); //新增角色权限表 Hi.Model.SYS_RoleSysFun rolesys = null; List <Hi.Model.SYS_SysFun> funList = new Hi.BLL.SYS_SysFun().GetList("", " Type=2", ""); foreach (Hi.Model.SYS_SysFun sys in funList) { rolesys = new Hi.Model.SYS_RoleSysFun(); rolesys.CompID = comp.ID; rolesys.DisID = DisID; rolesys.RoleID = Roid; rolesys.FunCode = sys.FunCode; rolesys.FunName = sys.FunName; rolesys.IsEnabled = 1; rolesys.CreateUserID = one.ID; rolesys.CreateDate = DateTime.Now; rolesys.ts = DateTime.Now; rolesys.modifyuser = one.ID; if (new Hi.BLL.SYS_RoleSysFun().Add(rolesys, mytran) <= 0) { mytran.Rollback(); return(new ReseltResellerEdit() { Result = "F", Description = "新增失败" }); } } //新增收货地址 Hi.Model.BD_DisAddr addr = new Hi.Model.BD_DisAddr(); addr.Province = disModel.Province; addr.City = disModel.City; addr.Area = disModel.Area; addr.DisID = DisID; addr.Principal = disModel.Principal; addr.Phone = disModel.Phone; addr.Address = disModel.Province + disModel.City + disModel.Area + disModel.Address; addr.IsDefault = 1; addr.ts = DateTime.Now; addr.CreateDate = DateTime.Now; addr.CreateUserID = one.ID; addr.modifyuser = one.ID; int addrid = new Hi.BLL.BD_DisAddr().Add(addr, mytran); //判断所有表是否都插入成功了吗 if (Roid <= 0 || AddUserid <= 0 || compuserid <= 0 || roleuserid <= 0 || addrid <= 0) { mytran.Rollback(); return(new ReseltResellerEdit() { Result = "F", Description = "新增失败" }); } } else { mytran.Rollback(); return(new ReseltResellerEdit() { Result = "F", Description = "新增失败" }); } } else { mytran.Rollback(); return(new ReseltResellerEdit() { Result = "F", Description = "新增失败" }); } mytran.Commit(); } catch (Exception ex) { mytran.Rollback(); Common.CatchInfo(ex.Message + ":" + ex.StackTrace, "AddReseller:" + JSon); return(new ReseltResellerEdit() { Result = "F", Description = "新增失败" }); } finally { conn.Close(); mytran.Dispose(); } return(new ReseltResellerEdit() { Result = "T", Description = "新增成功" }); } catch (Exception ex) { Common.CatchInfo(ex.Message + ":" + ex.StackTrace, "AddReseller:" + JSon); return(new ReseltResellerEdit() { Result = "F", Description = "新增失败" }); } }
/// <summary> /// 复制订单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnCopy_Click(object sender, EventArgs e) { decimal TotalAmount = 0; //订单总价 string LogRemark = string.Empty; //日志备注 int Audit = 0; //是否审核 Hi.Model.DIS_Order OrderInfoModel = null; try { OrderInfoModel = OrderBll.GetModel(KeyID); if (OrderInfoModel != null) { String guid = Guid.NewGuid().ToString().Replace("-", ""); OrderInfoModel.GUID = guid; OrderInfoModel.ReceiptNo = SysCode.GetNewCode("销售单"); Audit = OrderInfoType.OrderEnAudit((int)Enums.AddType.网页下单, OrderInfoModel.DisID, OrderInfoModel.Otype); OrderInfoModel.IsAudit = Audit; //收货地址 Hi.Model.BD_DisAddr DisAddr = new Hi.BLL.BD_DisAddr().GetModel(OrderInfoModel.AddrID); if (DisAddr != null) { OrderInfoModel.AddrID = OrderInfoModel.AddrID; OrderInfoModel.Principal = DisAddr.Principal; OrderInfoModel.Phone = DisAddr.Phone; OrderInfoModel.Address = DisAddr.Address; } OrderInfoModel.PayState = (int)Enums.PayState.未支付; OrderInfoModel.OState = (int)Enums.OrderState.未提交; OrderInfoModel.PayedAmount = 0; OrderInfoModel.ReturnState = 0; OrderInfoModel.ArriveDate = DateTime.MinValue; OrderInfoModel.DisUserID = this.UserID; OrderInfoModel.CreateUserID = this.UserID; OrderInfoModel.CreateDate = DateTime.Now; OrderInfoModel.AuditUserID = 0; OrderInfoModel.AuditDate = DateTime.MinValue; OrderInfoModel.AuditRemark = ""; OrderInfoModel.ReturnMoneyDate = DateTime.MinValue; OrderInfoModel.ReturnMoneyUserId = 0; OrderInfoModel.ReturnMoneyUser = ""; OrderInfoModel.ts = DateTime.Now; OrderInfoModel.dr = 0; OrderInfoModel.modifyuser = 0; //订单商品明细 List <Hi.Model.DIS_OrderDetail> l = OrderDetailBll.GetList("", " OrderId=" + KeyID, ""); List <Hi.Model.DIS_OrderDetail> dl = new List <Hi.Model.DIS_OrderDetail>(); foreach (Hi.Model.DIS_OrderDetail item in l) { //获取商品最新价格 decimal Price = SelectGoods.GoodsNewPrice(item.GoodsinfoID, this.DisID, CompID); item.Price = Price; item.AuditAmount = Price; item.sumAmount = Price * item.GoodsNum; TotalAmount += item.sumAmount; item.ts = DateTime.Now; item.dr = 0; item.modifyuser = 0; dl.Add(item); } OrderInfoModel.TotalAmount = TotalAmount; OrderInfoModel.AuditAmount = TotalAmount; //OrderInfoModel.OtherAmount = 0; LogRemark += " 下单总价:" + TotalAmount.ToString("N"); int OrderId = OrderInfoType.TansOrder(OrderInfoModel, dl); if (OrderId > 0) { Utils.AddSysBusinessLog(this.CompID, "Order", OrderId.ToString(), "订单新增", LogRemark); JScript.AlertMethod(this, "复制成功", JScript.IconOption.正确, "function (){ location.replace('" + ("neworder/orderdetail.aspx?KeyID=" + Common.DesEncrypt(OrderId.ToString(), Common.EncryptKey)) + "'); }"); } } } catch (Exception ex) { throw ex; } }
/// <summary> /// 应收应付账款订单列表 /// </summary> /// <param name="JSon"></param> /// <returns></returns> public DIS_Order.ResultOrderList GetDisAccountInfo(string JSon) { try { string strWhere = " and Ostate in (2,4,5) and PayState in (0,1)"; #region JSon取值 string userID = string.Empty; string disID = string.Empty; string criticalOrderID = string.Empty; //当前列表最临界点产品ID:初始-1 string getType = string.Empty; //方向 string rows = string.Empty; string sortType = string.Empty; string sort = string.Empty; string orderType = string.Empty;//单据类型 1:订单 2:账单 JsonData JInfo = JsonMapper.ToObject(JSon); if (JInfo.Count > 0 && JInfo["UserID"].ToString() != "" && JInfo["ResellerID"].ToString() != "" && JInfo["CriticalOrderID"].ToString() != "" && JInfo["GetType"].ToString() != "" && JInfo["Rows"].ToString() != "" && JInfo["SortType"].ToString() != "" && JInfo["Sort"].ToString() != "" && JInfo["orderType"].ToString() != "") { userID = JInfo["UserID"].ToString(); disID = JInfo["ResellerID"].ToString(); strWhere += " and DisID='" + disID + "' and ISNULL(dr,0)=0"; criticalOrderID = JInfo["CriticalOrderID"].ToString(); getType = JInfo["GetType"].ToString(); rows = JInfo["Rows"].ToString(); sortType = JInfo["SortType"].ToString(); sort = JInfo["Sort"].ToString(); orderType = JInfo["orderType"].ToString(); } else { return(new DIS_Order.ResultOrderList() { Result = "F", Description = "参数异常" }); } if (orderType == "1")//订单 { strWhere += " and ISNULL(dr,0)=0 and OState != 0 and Otype!=9"; } else//账单 { strWhere += " and ISNULL(dr,0)=0 and OState != 0 and Otype=9"; } JsonData JMsg = JInfo["Search"]; if (JMsg.Count > 0) { if (JMsg["OrderID"].ToString() != "") { strWhere += " and ReceiptNo like '" + JMsg["OrderID"].ToString() + "%'"; } if (JMsg["BeginDate"].ToString() != "") { strWhere += " and CreateDate >= '" + Convert.ToDateTime(JMsg["BeginDate"].ToString()) + "'"; } if (JMsg["EndDate"].ToString() != "") { strWhere += " and CreateDate < " + Convert.ToDateTime(JInfo["EndDate"].ToString()).AddDays(1) + "'"; } //根据出库单编号 锁定 订单ID if (JMsg["ExpressNo"].ToString() != "") { //strWhere += " and ReceiptNo like '" + JMsg["ExpressNo"].ToString() + "%'"; List <Hi.Model.DIS_OrderOut> orderOut = new Hi.BLL.DIS_OrderOut().GetList("", " ExpressNo like '%" + JMsg["ExpressNo"].ToString() + "%'", ""); if (orderOut.Count == 0) { return new DIS_Order.ResultOrderList() { Result = "F", Description = "参数异常" } } ; strWhere += " and ID in ( 0"; strWhere = orderOut.Aggregate(strWhere, (current, aout) => current + ("," + aout.OrderID)); strWhere += " )"; } } #endregion #region 模拟分页 string tabName = " [dbo].[DIS_Order]"; //表名 string strsql = string.Empty; //搜索sql sortType = "ID"; strsql = new Common().PageSqlString(criticalOrderID, "ID", tabName, sortType, sort, strWhere, getType, rows); if (strsql == "") { return new DIS_Order.ResultOrderList() { Result = "F", Description = "基础数据异常" } } ; #endregion #region 赋值 string SKUName = string.Empty; List <DIS_Order.Order> OrderList = new List <DIS_Order.Order>(); DataSet ds = SqlHelper.Query(SqlHelper.LocalSqlServer, strsql); if (ds.Tables.Count == 0) { return new DIS_Order.ResultOrderList() { Result = "F", Description = "没有更多数据" } } ; DataTable orderList = ds.Tables[0]; if (orderList != null) { if (orderList.Rows.Count == 0) { return new DIS_Order.ResultOrderList() { Result = "F", Description = "没有更多数据" } } ; foreach (DataRow row in orderList.Rows) { DIS_Order.Order order = new DIS_Order.Order(); Hi.Model.DIS_Order orderModel = new Hi.BLL.DIS_Order().GetModel(int.Parse(row["ID"].ToString())); order.OrderID = orderModel.ID.ToString(); order.CompID = orderModel.CompID.ToString(); Hi.Model.BD_Company comp = new Hi.BLL.BD_Company().GetModel(orderModel.CompID); if (comp == null || comp.IsEnabled == 0 || comp.dr == 1) { return new DIS_Order.ResultOrderList() { Result = "F", Description = "企业异常" } } ; order.CompName = comp.CompName; order.State = Common.GetDisOrderType(orderModel.OState, orderModel.PayState, orderModel.Otype, orderModel.ReturnState); order.OState = orderModel.OState.ToString(); order.AddType = orderModel.AddType.ToString(); order.Otype = orderModel.Otype.ToString(); order.PayState = orderModel.PayState.ToString(); order.ReturnState = orderModel.ReturnState.ToString(); order.DisID = orderModel.DisID.ToString(); Hi.Model.BD_Distributor dis = new Hi.BLL.BD_Distributor().GetModel(orderModel.DisID); if (dis == null || dis.IsEnabled == 0 || dis.dr == 1) { return new DIS_Order.ResultOrderList() { Result = "F", Description = "经销信息商异常" } } ; order.DisName = dis.DisName; order.DisUserID = orderModel.DisUserID.ToString(); Hi.Model.SYS_Users user = new Hi.BLL.SYS_Users().GetModel(int.Parse(userID)); if (user == null || user.IsEnabled == 0 || user.dr == 1) { return new DIS_Order.ResultOrderList() { Result = "F", Description = "经销商用户信息异常" } } ; order.DisUserName = user.TrueName; order.AddrID = orderModel.AddrID.ToString(); order.ReceiptNo = orderModel.ReceiptNo; order.ArriveDate = orderModel.ArriveDate.ToString(); if (!string.IsNullOrEmpty(orderModel.AddrID.ToString())) { Hi.Model.BD_DisAddr addr = new Hi.BLL.BD_DisAddr().GetModel(orderModel.AddrID); if (addr != null) { order.Zip = addr.Zip; } } order.Address = orderModel.Address; order.Contact = orderModel.Principal; order.Phone = orderModel.Phone; order.TotalAmount = orderModel.TotalAmount.ToString("0.00"); order.AuditTotalAmount = orderModel.AuditAmount.ToString("0.00"); order.PayedAmount = orderModel.PayedAmount.ToString("0.00"); order.CreateUserID = orderModel.CreateUserID.ToString(); order.CreateDate = orderModel.CreateDate.ToString(); order.ReturnMoneyDate = orderModel.ReturnMoneyDate.ToString(); order.ReturnMoneyUser = orderModel.ReturnMoneyUser.ToString(); order.ReturnMoneyUserId = orderModel.ReturnMoneyUserId.ToString(); List <Hi.Model.DIS_OrderOut> outList = new Hi.BLL.DIS_OrderOut().GetList("", " OrderID='" + orderModel.ID + "' and CompID='" + orderModel.CompID + "' and DisID='" + orderModel.DisID + "' and ISNULL(dr,0)=0", ""); if (outList.Count != 0) { Hi.Model.DIS_OrderOut orderOut = new Hi.Model.DIS_OrderOut(); foreach (Hi.Model.DIS_OrderOut Out in outList) { orderOut = Out; } order.SendID = orderOut.ID.ToString(); order.SendDate = orderOut.SendDate.ToString(); //根据发货单取对应的物流信息 List <Hi.Model.DIS_Logistics> list_log = new Hi.BLL.DIS_Logistics().GetList("", "OrderOutID = " + orderOut.ID + " and isnull(dr,0) = 0", ""); //一个发货单只有一条物流信息,所以list_log里也只有一条数据 Hi.Model.DIS_Logistics model_log = list_log[0]; order.Express = Convert.ToString(model_log.ComPName); order.ExpressNo = Convert.ToString(model_log.LogisticsNo); //order.ExpressPerson = Convert.ToString(orderOut.ExpressPerson); //order.ExpressTel = Convert.ToString(orderOut.ExpressTel); //order.ExpressBao =Convert.ToString(orderOut.ExpressBao); order.PostFee = orderModel.PostFee.ToString("0.00"); order.ActionUser = Convert.ToString(orderOut.ActionUser); order.SendRemark = Convert.ToString(orderOut.Remark); order.IsAudit = Convert.ToString(orderOut.IsAudit); order.AuditUserID = Convert.ToString(orderOut.AuditUserID); order.AuditDate = Convert.ToString(orderOut.AuditDate); order.AuditRemark = orderOut.AuditRemark == null ? "" : orderOut.AuditRemark.ToString(); order.SignDate = Convert.ToString(orderOut.SignDate); order.IsSign = Convert.ToString(orderOut.IsSign); order.SignUserId = Convert.ToString(orderOut.SignUserId); order.SignUser = Convert.ToString(orderOut.SignUser); order.SignRemark = Convert.ToString(orderOut.SignRemark); } order.SendRemark = Convert.ToString(orderModel.Remark); //todo:不知道的排序 //order.SortIndex = orderModel.SortIndex.ToString(); order.IsDel = Convert.ToString(orderModel.dr); //明细 List <DIS_Order.OrderDetail> orderDetail = new List <DIS_Order.OrderDetail>(); List <Hi.Model.DIS_OrderDetail> detailList = new Hi.BLL.DIS_OrderDetail().GetList("", " OrderID='" + orderModel.ID + "' and DisID='" + orderModel.DisID + "' and ISNULL(dr,0)=0", ""); if (detailList == null) //|| detailList.Count==0 没有明细的单 PC可以新建 { return new DIS_Order.ResultOrderList() { Result = "F", Description = "订单明细异常" } } ; List <Hi.Model.BD_GoodsAttrs> list_attrs = null; foreach (Hi.Model.DIS_OrderDetail detail in detailList) { DIS_Order.OrderDetail ordetail = new DIS_Order.OrderDetail(); ordetail.SKUID = detail.GoodsinfoID.ToString(); //通过GoodsInfoID找到GoodsID Hi.Model.BD_GoodsInfo goodsInfo = new Hi.BLL.BD_GoodsInfo().GetModel(detail.GoodsinfoID); if (goodsInfo == null) { //if (goodsInfo == null || goodsInfo.IsEnabled == false || goodsInfo.dr == 1) return new DIS_Order.ResultOrderList() { Result = "F", Description = "SKU信息异常" } } ; ordetail.ProductID = goodsInfo.GoodsID.ToString(); //通过GoodsID找到GoodsName Hi.Model.BD_Goods goods = new Hi.BLL.BD_Goods().GetModel(goodsInfo.GoodsID); if (goods == null) { //if (goods == null || goods.IsEnabled == 0 || goods.dr == 1) return new DIS_Order.ResultOrderList() { Result = "F", Description = "商品异常" } } ; ordetail.ProductName = goods.GoodsName; SKUName += goods.GoodsName; list_attrs = new Hi.BLL.BD_GoodsAttrs().GetList("AttrsName", "GoodsID = " + goodsInfo.GoodsID + " and CompID = " + comp.ID + " and ISNULL(dr,0) = 0", ""); if (list_attrs != null && list_attrs.Count != 0) { foreach (Hi.Model.BD_GoodsAttrs attr in list_attrs) { SKUName += attr.AttrsName; } } ordetail.SKUName = SKUName; //todo:描述是什么 ordetail.ValueInfo = goodsInfo.ValueInfo; ordetail.SalePrice = detail.Price.ToString("0.00"); ordetail.TinkerPrice = detail.AuditAmount.ToString("0.00"); ordetail.Num = detail.GoodsNum.ToString("0.00"); ordetail.Remark = detail.Remark; List <DIS_Order.Pic> Pic = new List <DIS_Order.Pic>(); if (goods.Pic.ToString() != "" && goods.Pic.ToString() != "X") { DIS_Order.Pic pic = new DIS_Order.Pic(); pic.ProductID = goodsInfo.GoodsID.ToString(); pic.IsDeafult = "1"; pic.PicUrl = ConfigurationManager.AppSettings["ImgViewPath"].ToString().Trim() + "GoodsImg/" + goods.Pic; Pic.Add(pic); } ordetail.ProductPicUrlList = Pic; orderDetail.Add(ordetail); } order.OrderDetailList = orderDetail; OrderList.Add(order); } } else { return(new DIS_Order.ResultOrderList() { Result = "F", Description = "没有更多数据" }); } #endregion return(new DIS_Order.ResultOrderList() { Result = "T", Description = "获取成功", OrderList = OrderList }); } catch (Exception ex) { Common.CatchInfo(ex.Message + ":" + ex.StackTrace, "GetDisAccountInfo:" + JSon); return(new DIS_Order.ResultOrderList() { Result = "F", Description = "参数异常" }); } }
protected void btn_Save(object sender, EventArgs e) { Hi.Model.BD_Distributor Dis = new Hi.BLL.BD_Distributor().GetModel(this.DisID); if (Dis != null) { if (Common.DisExistsAttribute("DisName", txtDisName.Value.Trim(), this.CompID.ToString(), this.DisID.ToString())) { JScript.AlertMsgOne(this, "代理商名称已存在!", JScript.IconOption.错误, 2500); return; } Dis.Province = Common.NoHTML(hidProvince.Value.Trim()); Dis.City = Common.NoHTML(hidCity.Value.Trim()); Dis.Area = Common.NoHTML(hidArea.Value.Trim()); Dis.DisName = Common.NoHTML(txtDisName.Value.Trim()); Dis.Licence = Common.NoHTML(txtLicence.Value.Trim()); Dis.Tel = Common.NoHTML(txtTel.Value.Trim()); Dis.Principal = Common.NoHTML(txtname.Value); Dis.Phone = Common.NoHTML(txtnamephone.Value); Dis.Zip = Common.NoHTML(txtZip.Value.Trim()); Dis.Fax = Common.NoHTML(txtFax.Value.Trim()); Dis.Address = Common.NoHTML(txtAddress.Value.Trim()); Dis.Leading = Common.NoHTML(txtLeading.Value.Trim()); Dis.LeadingPhone = Common.NoHTML(txtLeadingPhone.Value.Trim()); if (!string.IsNullOrEmpty(HidFfileName.Value)) { if (Dis.pic == "") { Dis.pic = Common.NoHTML(HidFfileName.Value); } else { Dis.pic += "," + Common.NoHTML(HidFfileName.Value); } } Dis.ts = DateTime.Now; Dis.modifyuser = this.UserID; if (new Hi.BLL.BD_Distributor().Update(Dis)) { List <Hi.Model.SYS_CompUser> user2 = new Hi.BLL.SYS_CompUser().GetList("UserID", " isnull(dr,0)=0 and disId='" + this.DisID + "' and utype=5", ""); if (user2.Count > 0) { Hi.Model.SYS_Users u = new Hi.BLL.SYS_Users().GetModel(user2[0].UserID); if (u != null) { u.ts = DateTime.Now; u.modifyuser = this.UserID; u.TrueName = Common.NoHTML(txtUserTrueName.Value); new Hi.BLL.SYS_Users().Update(u); } } else { Hi.Model.SYS_Users u = new Hi.BLL.SYS_Users().GetModel(this.UserID); if (u != null) { u.ts = DateTime.Now; u.modifyuser = this.UserID; u.TrueName = Common.NoHTML(txtUserTrueName.Value); new Hi.BLL.SYS_Users().Update(u); } } List <Hi.Model.BD_DisAddr> LDaddr = new Hi.BLL.BD_DisAddr().GetList(" top 1 *", " dr=0 and disid=" + this.DisID + "", " createdate asc"); if (LDaddr.Count > 0) { LDaddr[0].Address = Common.NoHTML(txtAddress.Value.Trim()); LDaddr[0].Province = Common.NoHTML(hidProvince.Value.Trim()); LDaddr[0].City = Common.NoHTML(hidCity.Value.Trim()); LDaddr[0].Area = Common.NoHTML(hidArea.Value.Trim()); LDaddr[0].modifyuser = this.UserID; LDaddr[0].ts = DateTime.Now; new Hi.BLL.BD_DisAddr().Update(LDaddr[0]); } Response.Redirect("UserIndex.aspx"); } } }
protected void Page_Load(object sender, EventArgs e) { if ((HttpContext.Current.Session["UserModel"] as LoginModel) != null) { CompID = (HttpContext.Current.Session["UserModel"] as LoginModel).CompID; } object obj2 = Request["action"]; if (obj2 != null) { if (obj2.ToString() == "yanz")//验证是否还存在下级分类 { int id = 0; if (Request["id"] != null) { id = Convert.ToInt32(Request["id"]); } Response.Write(GetMinCategory(id)); Response.End(); } } if (!IsPostBack) { object obj = Request.QueryString["type"]; if (obj != null) { type = obj.ToString(); if (!Util.IsEmpty(type)) { if (Request.QueryString["disId"] != null) { disID = Request.QueryString["disId"]; } else { disID = "0"; } if (type == "1")//商品分类 { IsExepand = Common.RsertFolding(type, CompID); string strwhere = string.Empty; List <Hi.Model.SYS_GType> FindList = new List <Hi.Model.SYS_GType>(); List <Hi.Model.SYS_GType> l = new Hi.BLL.SYS_GType().GetList("id,TypeName,ParentId", "isnull(dr,0)=0 and isenabled=1 ", " id"); if (string.IsNullOrWhiteSpace(Request["val"])) { FindList = l.Where(T => T.ParentId == 0).ToList(); } else { string SearchValue = Request["val"].Replace("'", "''"); List <Hi.Model.SYS_GType> ParentList = new List <Hi.Model.SYS_GType>(); strwhere += " isnull(dr,0)=0 and isenabled=1 and TypeName like '%" + SearchValue + "%'"; FindList = new Hi.BLL.SYS_GType().GetList("id,TypeName,ParentId", strwhere, " id"); foreach (Hi.Model.SYS_GType model in FindList) { //string NewName = model.CategoryName.Replace(SearchValue, "<i style='color:red'>" + SearchValue + "</i>"); string NewName = model.TypeName; var ParentModel = l.Where(T => T.ID == model.ParentId).ToList(); if (ParentModel.Count > 0) { NewName = ParentModel[0].TypeName + " > " + NewName; } model.TypeName = NewName; ParentList.Add(model); } FindList = ParentList; } if (l.Count > 0 && FindList.Count > 0) { BindHTML(l, FindList, type); } } else if (type == "2")//代理商区域 { List <Hi.Model.BD_DisArea> FindList = new List <Hi.Model.BD_DisArea>(); List <Hi.Model.BD_DisArea> ll = new Hi.BLL.BD_DisArea().GetList("id,AreaName,ParentId", "CompanyID=" + this.CompID + " and isnull(dr,0)=0 ", ""); FindList = ll.Where(T => T.ParentID == 0).ToList(); if (ll.Count > 0 && FindList.Count > 0) { BindHTML(ll, FindList, type); } } else if (type == "3")//代理商分类 { List <Hi.Model.BD_DisType> FindList = new List <Hi.Model.BD_DisType>(); List <Hi.Model.BD_DisType> lll = new Hi.BLL.BD_DisType().GetList("id,ParentId,TypeName", "compid=" + this.CompID + " and isnull(dr,0)=0 ", ""); FindList = lll.Where(T => T.ParentId == 0).ToList(); if (lll.Count > 0 && FindList.Count > 0) { BindHTML(lll, FindList, type); } } else if (type == "4")//代理商地址 { List <Hi.Model.BD_DisAddr> llll = new Hi.BLL.BD_DisAddr().GetList("id,Address", "disid=" + disID + " and isnull(dr,0)=0", ""); if (llll.Count > 0) { BindHTML(llll, llll, type); } } else if (type == "5") {//代理商管理员 List <Hi.Model.BD_Distributor> lllll = new Hi.BLL.BD_Distributor().GetList("id,DisName", "compid=" + this.CompID + " and isnull(dr,0)=0", "Id desc"); if (lllll.Count > 0) { BindHTML(lllll, lllll, type); } } else if (type == "6") {//代理商管理员 List <Hi.Model.BD_Distributor> lllll = new Hi.BLL.BD_Distributor().GetList("id,DisName", "compid=" + this.CompID + " and isnull(dr,0)=0 and AuditState=2 and IsEnabled=1", "Id asc"); if (lllll.Count > 0) { BindHTML(lllll, lllll, type); } } } } } }