protected string QueryCondition() { string strMemShopID = this.sltShop.Value; StringBuilder strSql = new StringBuilder(); strSql.Append(" 1=1 "); if (strMemShopID != "") { strSql.AppendFormat("and MemShopID={0}", int.Parse(strMemShopID)); } string strProvince = this.SysArea1.sltProvince.Value; string strCity = (base.Request["SysArea1$sltCity"] != null) ? base.Request["SysArea1$sltCity"].ToString() : ""; string strCounty = (base.Request["SysArea1$sltCounty"] != null) ? base.Request["SysArea1$sltCounty"].ToString() : ""; string strVillage = (base.Request["SysArea1$sltVillage"] != null) ? base.Request["SysArea1$sltVillage"].ToString() : ""; if (strProvince != "") { strSql.AppendFormat(" and MemProvince='{0}'", strProvince); } if (strCity != "" || strProvince != "") { this.SysArea1.sltCity.Items.Clear(); PubFunction.BindSysArea(this.SysArea1.sltCity, int.Parse(strProvince)); this.SysArea1.sltCity.Value = strCity; if (strCity != "") { strSql.AppendFormat(" and MemCity='{0}'", strCity); } } if (strCounty != "" || strCity != "") { this.SysArea1.sltCounty.Items.Clear(); PubFunction.BindSysArea(this.SysArea1.sltCounty, int.Parse(strCity)); this.SysArea1.sltCounty.Value = strCounty; if (strCounty != "") { strSql.AppendFormat(" and MemCounty='{0}'", strCounty); } } if (strVillage != "" || strCounty != "") { this.SysArea1.sltVillage.Items.Clear(); PubFunction.BindSysArea(this.SysArea1.sltVillage, int.Parse(strCounty)); this.SysArea1.sltVillage.Value = strVillage; if (strVillage != "") { strSql.AppendFormat(" and MemVillage='{0}'", strVillage); } } this.MoneyID = int.Parse(base.Request.QueryString["MoneyID"]); strSql.AppendFormat(" and MoneyID={0}", this.MoneyID); return(strSql.ToString()); }
private List <string> QueryCondition() { List <string> condition = new List <string>(); condition.Add("Mem.MemShopID = SysShop.ShopID and Mem.MemLevelID = MemLevel.LevelID and Mem.MemUserID = SysUser.UserID "); condition.Add("Mem.MemShopID =SysShopMemLevel.ShopID and SysShopMemLevel.MemLevelID=MemLevel.LevelID "); condition.Add(" MemID >0 AND EXISTS(SELECT 1 FROM dbo.Mem wa WHERE wa.MemRecommendID=dbo.Mem.MemID AND wa.MemRecommendID>0)"); condition.Add(PubFunction.GetShopAuthority(this._UserShopID, "MemShopID", " 1=1 ")); string strQueryMem = this.txtQueryMem.Value; string strMemLevelID = this.sltMemLevelID.Value; string strMemShopID = this.sltShop.Value; string strMemPastTime = this.sltMemPastTime.Value; string strMemCustom = this.sltCustomField.Value; string strCustomField = (!string.IsNullOrEmpty(base.Request["txtCustomField"])) ? base.Request["txtCustomField"].ToString() : ""; string strMemState = this.sltMemState.Value; string strMemUserID = this.sltMemUserID.Value; string strMemStartTime = this.txtMemStartTime.Value; string strMemEndTime = this.txtMemEndTime.Value; string strMemBirthday = this.sltMemBirthday.Value; string strMemConsume = this.sltMemConsume.Value; string strPointSymbols = this.sltMemPoint.Value; string strPoint = (this.txtMemPoint.Value.Trim() != "") ? this.txtMemPoint.Value.Trim() : "0"; string strMoneySymbols = this.sltMemMoney.Value; string strMemMoney = (this.txtMemMoney.Value.Trim() != "") ? this.txtMemMoney.Value.Trim() : "0"; string strConsumeMoneySymbols = this.sltConsumeMoney.Value; string strConsumeMoney = (this.txtConsumeMoney.Value.Trim() != "") ? this.txtConsumeMoney.Value.Trim() : "0"; string strProvince = this.SysArea1.sltProvince.Value; string strCity = (base.Request["SysArea1$sltCity"] != null) ? base.Request["SysArea1$sltCity"].ToString() : ""; string strCounty = (base.Request["SysArea1$sltCounty"] != null) ? base.Request["SysArea1$sltCounty"].ToString() : ""; string strVillage = (base.Request["SysArea1$sltVillage"] != null) ? base.Request["SysArea1$sltVillage"].ToString() : ""; string strRecommend = this.txtMemRecommendCard.Value; if (strQueryMem != "") { condition.Add(string.Format(" (MemCard ='{0}' or MemCardNumber='{0}' or MemName like '%{0}%' or MemMobile='{0}')", strQueryMem)); } if (strMemLevelID != "") { condition.Add(string.Format(" Mem.MemLevelID={0}", strMemLevelID)); } if (strMemShopID != "") { condition.Add(string.Format(" MemShopID={0}", strMemShopID)); } if (strMemPastTime != "") { if (strMemPastTime == "0") { condition.Add(string.Format("MemPastTime<'{0}'", DateTime.Now.ToShortDateString())); } else if (strMemPastTime == "1") { condition.Add(string.Format("MemPastTime BETWEEN '{0}' AND '{1}'", DateTime.Now.AddDays(1.0).ToShortDateString(), DateTime.Now.AddDays(7.0).ToShortDateString())); } else if (strMemPastTime == "2") { condition.Add(string.Format("MemPastTime BETWEEN '{0}' AND '{1}'", DateTime.Now.AddDays(1.0).ToShortDateString(), DateTime.Now.AddDays(30.0).ToShortDateString())); } } if (strMemConsume != "") { condition.Add("MemConsumeLastTime>'1901-01-01'"); if (strMemConsume == "0") { condition.Add("MemConsumeLastTime<DATEADD(M,-3,GETDATE())"); } else if (strMemConsume == "1") { condition.Add("MemConsumeLastTime<DATEADD(M,-6,GETDATE())"); } else if (strMemConsume == "2") { condition.Add("MemConsumeLastTime<DATEADD(Y,-1,GETDATE())"); } } if (strMemBirthday != "") { condition.Add("MemBirthday>'1900-01-02'"); string text = strMemBirthday; if (text != null) { if (!(text == "0")) { if (!(text == "1")) { if (text == "2") { condition.Add(string.Format("MONTH(MemBirthday)={0}", DateTime.Now.Month)); } } else { condition.Add(string.Format("DATEDIFF(WEEK,'{0}-'+CONVERT(VARCHAR(5),GETDATE(),110),GETDATE())=0", DateTime.Now.Year)); } } else { condition.Add(string.Format("MONTH(MemBirthday)={0} AND DAY(MemBirthday)={1}", DateTime.Now.Month, DateTime.Now.Day)); } } } if (strMemCustom != "" && strCustomField != "") { condition.Add(string.Format(" {0} like '%{1}%'", strMemCustom, strCustomField)); } if (strMemState != "") { condition.Add(string.Format("MemState={0} ", int.Parse(strMemState))); } if (strMemUserID != "") { condition.Add(string.Format("MemUserID={0} ", int.Parse(strMemUserID))); } if (strMemStartTime != "") { condition.Add(string.Format("MemCreateTime>='{0}' ", strMemStartTime)); } if (strMemEndTime != "") { condition.Add(string.Format("MemCreateTime<'{0}'", DateTime.Now.AddDays(1.0).ToShortDateString())); } if (int.Parse(strPoint) != 0) { condition.Add(string.Format("MemPoint {1} {0} ", strPoint, strPointSymbols)); } if (decimal.Parse(strMemMoney) != 0m) { condition.Add(string.Format("MemMoney {1} {0} ", strMemMoney, strMoneySymbols)); } if (decimal.Parse(strConsumeMoney) != 0m) { condition.Add(string.Format("MemConsumeMoney {1} {0} ", strConsumeMoney, strConsumeMoneySymbols)); } if (strProvince != "") { condition.Add(string.Format("MemProvince='{0}'", strProvince)); } if (strCity != "" || strProvince != "") { this.SysArea1.sltCity.Items.Clear(); PubFunction.BindSysArea(this.SysArea1.sltCity, int.Parse(strProvince)); this.SysArea1.sltCity.Value = strCity; if (strCity != "") { condition.Add(string.Format("MemCity='{0}'", strCity)); } } if (strCounty != "" || strCity != "") { this.SysArea1.sltCounty.Items.Clear(); PubFunction.BindSysArea(this.SysArea1.sltCounty, int.Parse(strCity)); this.SysArea1.sltCounty.Value = strCounty; if (strCounty != "") { condition.Add(string.Format("MemCounty='{0}'", strCounty)); } } if (strVillage != "" || strCounty != "") { this.SysArea1.sltVillage.Items.Clear(); PubFunction.BindSysArea(this.SysArea1.sltVillage, int.Parse(strCounty)); this.SysArea1.sltVillage.Value = strVillage; if (strVillage != "") { condition.Add(string.Format("MemVillage='{0}'", strVillage)); } } if (strRecommend != "") { Chain.Model.Mem memModel = new Chain.BLL.Mem().GetModelByMemCard(strRecommend); if (memModel != null) { condition.Add(string.Format("MemRecommendID={0}", memModel.MemID)); } else { condition.Add("1=2"); } } this.BindCustomSelect(this.sltCustomField, strMemCustom, strCustomField, this._UserShopID); return(condition); }
protected void GetMemToEdit(int memID) { Chain.Model.Mem modelMem = new Chain.Model.Mem(); Chain.BLL.Mem bllMem = new Chain.BLL.Mem(); modelMem = bllMem.GetModel(memID); DataTable dtMem = bllMem.GetItemAll(memID).Tables[0]; this.txtMemID.Value = modelMem.MemID.ToString(); this.txtMemCard.Value = modelMem.MemCard; this.txtMemCard.Attributes.Add("readonly", "true"); this.txtMemName.Value = modelMem.MemName; this.txtCardNumber.Value = modelMem.MemCardNumber; if (modelMem.MemSex) { this.sltMemSex.SelectedIndex = 0; } else { this.sltMemSex.SelectedIndex = 1; } this.txtMemIdentityCard.Value = modelMem.MemIdentityCard; string strMemBirthday = modelMem.MemBirthday.ToString(); if (strMemBirthday.IndexOf("1900") == -1 && strMemBirthday.IndexOf("0001") == -1) { this.txtMemBirthday.Value = modelMem.MemBirthday.ToShortDateString(); } else { this.txtMemBirthday.Value = ""; } if (modelMem.MemPoint.ToString() != "") { this.txtMemPoint.Value = modelMem.MemPoint.ToString(); } else { this.txtMemPoint.Value = "0"; } this.sltShop.Items.Add(new ListItem(new Chain.BLL.SysShop().GetModel(modelMem.MemShopID).ShopName, modelMem.MemShopID.ToString())); if (modelMem.MemMoney.ToString() != "") { this.txtMemMoney.Value = Math.Round(modelMem.MemMoney, 2).ToString(); } else { this.txtMemMoney.Value = "0"; } this.txtMemMobile.Value = modelMem.MemMobile; this.txtMemEmail.Value = modelMem.MemEmail; this.txtMemAddress.Value = modelMem.MemAddress; this.sltMemState.Value = modelMem.MemState.ToString(); this.sltMemLevelID.Value = modelMem.MemLevelID.ToString(); this.sltShop.Value = modelMem.MemShopID.ToString(); this.sltShop.Attributes.Add("disabled", "disabled"); this.txtMemRecommendID.Value = modelMem.MemRecommendID.ToString(); if (modelMem.MemRecommendID != 0) { Chain.Model.Mem modelRecommendMem = new Chain.Model.Mem(); modelRecommendMem = bllMem.GetModel(modelMem.MemRecommendID); this.txtMemRecommendCard.Value = modelRecommendMem.MemCard; } this.txtMemCreateTime.Value = modelMem.MemCreateTime.ToShortDateString(); string strMemPastTime = modelMem.MemPastTime.ToString(); if (strMemPastTime.IndexOf("2900") == -1 && strMemPastTime.IndexOf("0001") == -1) { this.txtMemPastTime.Value = modelMem.MemPastTime.ToShortDateString(); this.chkMemIsPast.Checked = false; } else { this.txtMemPastTime.Value = ""; this.chkMemIsPast.Checked = true; } if (modelMem.MemPhoto != "") { this.imgMemPhoto.Src = base.GetWebRoot() + modelMem.MemPhoto; this.txtMemPhoto.Value = modelMem.MemPhoto; } else { this.imgMemPhoto.Src = "../images/member/nophoto.gif"; this.txtMemPhoto.Value = ""; } this.txtMemRemark.Value = StringPlus.HtmlDecode(modelMem.MemRemark); this.sltMemUserID.Value = modelMem.MemUserID.ToString(); this.txtTelephone.Value = modelMem.MemTelePhone; if (modelMem.MemQRCode != "") { this.trTitle.Visible = true; this.trQrCode.Visible = true; this.imgQRCode.Src = modelMem.MemQRCode; } else { this.trTitle.Visible = false; this.trQrCode.Visible = false; } if (modelMem.MemProvince != "") { this.ucSysArea.sltProvince.Items.Clear(); PubFunction.BindSysArea(this.ucSysArea.sltProvince, 0); this.ucSysArea.sltProvince.Value = modelMem.MemProvince; } if (modelMem.MemCity != "" && modelMem.MemCity != null && modelMem.MemProvince != "" && modelMem.MemProvince != null) { this.ucSysArea.sltCity.Items.Clear(); PubFunction.BindSysArea(this.ucSysArea.sltCity, int.Parse(modelMem.MemProvince)); this.ucSysArea.sltCity.Value = modelMem.MemCity; } if (modelMem.MemCounty != "" && modelMem.MemCounty != null && modelMem.MemCity != "" && modelMem.MemCity != null) { this.ucSysArea.sltCounty.Items.Clear(); PubFunction.BindSysArea(this.ucSysArea.sltCounty, int.Parse(modelMem.MemCity)); this.ucSysArea.sltCounty.Value = modelMem.MemCounty; } if (modelMem.MemVillage != "" && modelMem.MemVillage != null && modelMem.MemCounty != "" && modelMem.MemCounty != null) { this.ucSysArea.sltVillage.Items.Clear(); PubFunction.BindSysArea(this.ucSysArea.sltVillage, int.Parse(modelMem.MemCounty)); this.ucSysArea.sltVillage.Value = modelMem.MemVillage; } PubFunction.BindEditCustomFields(this.tbCustomField, "Mem", dtMem.Rows[0]); }
protected string QueryCondition() { int intMemWeiXinCard = Convert.ToInt32(this.selMemWeiXinCard.Value); int intMemAttention = Convert.ToInt32(this.selMemAttention.Value); string strQueryMem = this.txtQueryMem.Value; string strMemLevelID = this.sltMemLevelID.Value; string strMemShopID = this.sltShop.Value; string strMemPastTime = this.sltMemPastTime.Value; string strMemCustom = this.sltCustomField.Value; string strCustomField = (!string.IsNullOrEmpty(base.Request["txtCustomField"])) ? base.Request["txtCustomField"].ToString() : ""; string strMemState = this.sltMemState.Value; string strMemUserID = this.sltMemUserID.Value; string strMemStartTime = this.txtMemStartTime.Value; string strMemEndTime = this.txtMemEndTime.Value; string strMemBirthday = this.sltMemBirthday.Value; string strMemConsume = this.sltMemConsume.Value; string strPointSymbols = this.sltMemPoint.Value; string strPoint = (this.txtMemPoint.Value.Trim() != "") ? this.txtMemPoint.Value.Trim() : "0"; string strMoneySymbols = this.sltMemMoney.Value; string strMemMoney = (this.txtMemMoney.Value.Trim() != "") ? this.txtMemMoney.Value.Trim() : "0"; string strConsumeMoneySymbols = this.sltConsumeMoney.Value; string strConsumeMoney = (this.txtConsumeMoney.Value.Trim() != "") ? this.txtConsumeMoney.Value.Trim() : "0"; string strProvince = this.SysArea1.sltProvince.Value; string strCity = (base.Request["SysArea1$sltCity"] != null) ? base.Request["SysArea1$sltCity"].ToString() : ""; string strCounty = (base.Request["SysArea1$sltCounty"] != null) ? base.Request["SysArea1$sltCounty"].ToString() : ""; string strVillage = (base.Request["SysArea1$sltVillage"] != null) ? base.Request["SysArea1$sltVillage"].ToString() : ""; string strRecommend = this.txtMemRecommendCard.Value; StringBuilder strSql = new StringBuilder(); strSql.Append(" MemID >0 "); if (intMemWeiXinCard == 1) { strSql.AppendFormat("and Mem.MemWeiXinCard is not null and Mem.MemWeiXinCard!=''", new object[0]); } if (intMemWeiXinCard == 2) { strSql.AppendFormat("and (Mem.MemWeiXinCard is null or Mem.MemWeiXinCard='')", new object[0]); } if (intMemAttention != 0) { strSql.AppendFormat("and Mem.MemAttention={0}", intMemAttention); } if (strQueryMem != "") { Chain.BLL.SubMem bllSubMem = new Chain.BLL.SubMem(); DataTable dtSubMem = bllSubMem.GetList(" SubCardNumber='" + strQueryMem + "' and IsUsed ='true' ").Tables[0]; if (dtSubMem != null) { if (dtSubMem.Rows.Count > 0) { strQueryMem = dtSubMem.Rows[0]["MemCard"].ToString(); } } strSql.AppendFormat("and (MemCard ='{0}' or MemCardNumber='{0}' or MemName like '%{0}%' or MemMobile='{0}')", strQueryMem); } if (strMemLevelID != "") { strSql.AppendFormat("and Mem.MemLevelID={0}", int.Parse(strMemLevelID)); } if (strMemShopID != "") { strSql.AppendFormat("and MemShopID={0}", int.Parse(strMemShopID)); } if (strMemPastTime != "") { if (strMemPastTime == "0") { strSql.AppendFormat(" and getdate()>MemPastTime ", new object[0]); } else if (strMemPastTime == "1") { strSql.AppendFormat(" and datediff(day,getdate(),MemPastTime)<=7 and datediff(day,getdate(),MemPastTime)>0", new object[0]); } else if (strMemPastTime == "2") { strSql.AppendFormat(" and datediff(day,getdate(),MemPastTime)<=30 and datediff(day,getdate(),MemPastTime)>0 ", new object[0]); } } if (strMemConsume != "") { if (strMemConsume == "0") { strSql.AppendFormat(" and datediff(day,MemConsumeLastTime,getdate())>91 ", new object[0]); } else if (strMemConsume == "1") { strSql.AppendFormat(" and datediff(day,MemConsumeLastTime,getdate())>182 ", new object[0]); } else if (strMemConsume == "2") { strSql.AppendFormat(" and datediff(day,MemConsumeLastTime,getdate())>365 ", new object[0]); } } if (strMemBirthday != "") { string text = strMemBirthday; if (text != null) { if (!(text == "0")) { if (!(text == "1")) { if (text == "2") { string strMonth = DateTime.Now.ToString("MM/yy").Substring(0, 2); strSql.AppendFormat(" and convert(varchar(2),MemBirthday,107)={0} ", strMonth); } } else { string timeNow = DateTime.Now.ToShortDateString().Substring(0, 1); strSql.AppendFormat(" and datediff(week,(convert(varchar(5),getdate(),120)+convert(varchar(5),MemBirthday,110)),getdate())=0 ", new object[0]); } } else { strSql.AppendFormat(" and month(MemBirthday)=month(getdate()) and day(MemBirthday)-day(getdate())=0 ", new object[0]); } } } if (strMemCustom != "" && strCustomField != "") { strSql.AppendFormat(" and {0} like '%{1}%'", strMemCustom, strCustomField); } if (strMemState != "") { strSql.AppendFormat(" and MemState={0} ", int.Parse(strMemState)); } if (strMemUserID != "") { strSql.AppendFormat(" and MemUserID={0} ", int.Parse(strMemUserID)); } if (strMemStartTime != "") { strSql.AppendFormat(" and MemCreateTime>='{0}' ", strMemStartTime); } if (strMemEndTime != "") { strMemEndTime = Convert.ToDateTime(strMemEndTime).AddDays(1.0).ToString(); strSql.AppendFormat(" and MemCreateTime<'{0}' ", strMemEndTime); } if (int.Parse(strPoint) != 0) { strSql.AppendFormat(" and MemPoint" + strPointSymbols + "{0} ", int.Parse(strPoint)); } if (decimal.Parse(strMemMoney) != 0m) { strSql.AppendFormat(" and MemMoney" + strMoneySymbols + "{0} ", decimal.Parse(strMemMoney)); } if (decimal.Parse(strConsumeMoney) != 0m) { strSql.AppendFormat(" and MemConsumeMoney" + strConsumeMoneySymbols + "{0} ", decimal.Parse(strConsumeMoney)); } if (strProvince != "") { strSql.AppendFormat(" and MemProvince='{0}'", strProvince); } if (strCity != "" || strProvince != "") { this.SysArea1.sltCity.Items.Clear(); PubFunction.BindSysArea(this.SysArea1.sltCity, int.Parse(strProvince)); this.SysArea1.sltCity.Value = strCity; if (strCity != "") { strSql.AppendFormat(" and MemCity='{0}'", strCity); } } if (strCounty != "" || strCity != "") { this.SysArea1.sltCounty.Items.Clear(); PubFunction.BindSysArea(this.SysArea1.sltCounty, int.Parse(strCity)); this.SysArea1.sltCounty.Value = strCounty; if (strCounty != "") { strSql.AppendFormat(" and MemCounty='{0}'", strCounty); } } if (strVillage != "" || strCounty != "") { this.SysArea1.sltVillage.Items.Clear(); PubFunction.BindSysArea(this.SysArea1.sltVillage, int.Parse(strCounty)); this.SysArea1.sltVillage.Value = strVillage; if (strVillage != "") { strSql.AppendFormat(" and MemVillage='{0}'", strVillage); } } if (strRecommend != "") { Chain.Model.Mem memModel = new Chain.BLL.Mem().GetModelByMemCard(strRecommend); if (memModel != null) { strSql.AppendFormat(" and MemRecommendID=" + memModel.MemID, new object[0]); } else { strSql.Append(" and 1=2 "); } } this.BindCustomSelect(this.sltCustomField, strMemCustom, strCustomField, this._UserShopID); this.Session["QuerySql"] = strSql.ToString(); return(strSql.ToString()); }