/// <summary> /// 用于管理试卷下题目 /// </summary> public PageSetting SelByIDS(int cpage, int psize, string ids, int qtype = 99, string fields = "*") { ids = StrHelper.PureIDSForDB(ids); if (string.IsNullOrEmpty(ids)) { return(null); } if (!SafeSC.CheckIDS(ids)) { return(null); } fields += ",IsRight=0,Remark=''"; //string sql = "SELECT " + fields + ",IsRight=0,Remark='' FROM " + strTableName + " WHERE p_id IN(" + ids + ") "; string where = " p_id IN(" + ids + ")"; if (qtype != 99)//过滤大题 { where += " AND p_Type=" + qtype; } else { where += " AND P_Type!=10"; } PageSetting setting = PageSetting.Single(cpage, psize, strTableName, PK, where, "p_type", null, fields); DBCenter.SelPage(setting); return(setting); }
public bool DelByids(string ids) { if (SafeSC.CheckIDS(ids)) { string sql = "Delete From " + TbName + " Where ID IN (" + ids + ")"; return(SqlHelper.ExecuteNonQuery(CommandType.Text, sql) > 0); } return(false); }
public DataTable SelByIDS(string ids) { if (!SafeSC.CheckIDS(ids)) { return(new DataTable()); } string sql = "SELECT * FROM " + strTableName + " WHERE k_id IN (" + ids + ")"; return(SqlHelper.ExecuteTable(sql)); }
public string GetNamesByIDS(string ids) { if (!SafeSC.CheckIDS(ids)) { return(""); } string sql = "SELECT * FROM " + strTableName + " WHERE k_id IN (" + ids + ")"; DataTable dt = SqlHelper.ExecuteTable(sql); string names = ""; for (int i = 0; i < dt.Rows.Count; i++) { names += dt.Rows[i]["k_name"].ToString() + ","; } return(names.Trim(',')); }
public PageSetting SelByIDS_SPage(int cpage, int psize, string ids, int qtype = 0) { ids = StrHelper.PureIDSForDB(ids); if (string.IsNullOrEmpty(ids) || !SafeSC.CheckIDS(ids)) { return(null); } string where = "p_id IN (" + ids + ")"; if (qtype > 0) { where += " AND p_Type=" + qtype; } PageSetting setting = PageSetting.Single(cpage, psize, strTableName, PK, where, "p_type"); DBCenter.SelPage(setting); return(setting); }
public DataTable SelByIDS(string ids, int qtype = 99, string fields = "*") { ids = StrHelper.PureIDSForDB(ids); if (string.IsNullOrEmpty(ids) || SafeSC.CheckIDS(ids)) { return(null); } SafeSC.CheckIDSEx(ids); string sql = "SELECT " + fields + ",IsRight=0,Remark='' FROM " + strTableName + " WHERE p_id IN(" + ids + ") "; if (qtype != 99)//过滤大题 { sql += " AND p_Type=" + qtype; } else { sql += " AND P_Type!=10"; } sql += " ORDER BY p_type"; return(SqlHelper.ExecuteTable(CommandType.Text, sql)); }
public PageSetting SelForOrderList(Filter_Order filter) { string where = "OrderType!=" + (int)M_OrderList.OrderEnum.Hide; string whereCount = " WHERE OrderType!=" + (int)M_OrderList.OrderEnum.Hide; List <SqlParameter> sp = new List <SqlParameter>(); //是否包含回收站订单 if (filter.aside != -100) { where += " AND Aside=" + filter.aside; } #region 用户中心快速筛选 switch (filter.fast) { case "all": //全部(不含回收站) where += " AND Aside=0"; break; case "unpaid": //待付款==状态为未付款的 where += " AND PaymentStatus=" + (int)M_OrderList.PayEnum.NoPay; break; case "prepay": //已预付款(尚未支付尾款的订单) where += " AND Aside=0 AND Delivery=1 AND IsCount=0"; break; case "paid": //已支付(只支付了预付款的不在此列) where += " AND Aside=0 AND ((PaymentStatus=" + (int)M_OrderList.PayEnum.HasPayed + " AND Delivery=0) OR (Delivery=1 AND IsCount=1 AND Settle=1)) "; break; case "needpay": //需付款 where += " AND Aside=0 AND PaymentStatus=0"; break; case "receive": //需确认收货 where += " AND Aside=0 AND StateLogistics=1"; break; case "comment": //已付款未评价 //where += " AND (OrderStatus=" + (int)M_OrderList.StatusEnum.OrderFinish + " AND StateLogistics=" + (int)M_OrderList.ExpEnum.HasReceived + ")"; //where += " AND (SELECT COUNT(*) FROM ZL_CartPro WHERE Orderlistid=ID AND (AddStatus IS NULL OR AddStatus=''))>0";//AddStatus中会有退货记录,所以筛选为必须为空 //break; case "finish": //客户已付款收货 ||客户已完成退货 { where += string.Format(" AND ({0} OR {1})", "(OrderStatus=" + (int)M_OrderList.StatusEnum.OrderFinish + " AND StateLogistics=" + (int)M_OrderList.ExpEnum.HasReceived + ")", "(PaymentStatus=" + (int)M_OrderList.PayEnum.Refunded + ")"); } break; case "issure": where += " AND IsSure=0 "; break; case "recycle": //订单回收站 where = "OrderType!=" + (int)M_OrderList.OrderEnum.Hide + " AND Aside=1"; break; } #endregion #region 后台快速筛选 switch (filter.addon) { case "unpaid": //待付款==状态为未付款的 where += " AND PaymentStatus=" + (int)M_OrderList.PayEnum.NoPay; break; case "prepay": //已预付款(尚未支付尾款的订单) where += " AND Delivery=1 AND IsCount=0"; break; case "paid": where += " AND ((PaymentStatus=" + (int)M_OrderList.PayEnum.HasPayed + " AND Delivery=0) OR (Delivery=1 AND IsCount=1 AND Settle=1)) "; //where += " AND PaymentStatus=" + (int)M_OrderList.PayEnum.HasPayed; break; case "unexp": //待发货==已付款+未发货 where += " AND PaymentStatus=" + (int)M_OrderList.PayEnum.HasPayed + " AND StateLogistics=" + (int)M_OrderList.ExpEnum.NoSend; break; case "exped": //已发货==大于未发货状态的订单 where += " AND StateLogistics>" + (int)M_OrderList.ExpEnum.NoSend; break; case "finished": //where += " AND OrderStatus=" + (int)M_OrderList.StatusEnum.OrderFinish + " AND StateLogistics=" + (int)M_OrderList.ExpEnum.HasReceived; //后期移除,暂时支持预付 where += " AND (OrderStatus=" + (int)M_OrderList.StatusEnum.OrderFinish + " AND StateLogistics=" + (int)M_OrderList.ExpEnum.HasReceived + ")"; break; case "unrefund": where += " AND PaymentStatus=" + (int)M_OrderList.PayEnum.RequestRefund; break; case "refunded": where += " AND PaymentStatus=" + (int)M_OrderList.PayEnum.Refunded; break; case "recycle": //订单回收站==已关闭 where = " Aside=1 "; break; case "all": //全部(不含回收站) default: break; } #endregion //店铺类型 switch (filter.storeType) { case "all": break; case "store": where += " AND StoreID>0"; whereCount += " AND StoreID>0"; break; case "shop": where += " AND StoreID=0 "; whereCount += " AND StoreID=0"; break; default: if (DataConvert.CLng(filter.storeType) > 0) { where += " AND StoreID=" + DataConvert.CLng(filter.storeType) + " "; whereCount += " AND StoreID=" + DataConvert.CLng(filter.storeType) + " "; } break; } if (filter.isSure != -100) { where += " AND IsSure=" + filter.isSure; } //订单类型,未指定则抽出常规订单 if (string.IsNullOrEmpty(filter.orderType)) { where += " AND OrderType IN (0,1,4)"; whereCount += " AND OrderType IN (0,1,4)"; } else if (filter.orderType.Equals("-100") || filter.orderType.Equals("-1")) { } else { SafeSC.CheckIDSEx(filter.orderType); where += " AND OrderType IN (" + filter.orderType + ")"; whereCount += " AND OrderType IN (" + filter.orderType + ")"; } //商品名,订单号,用户名,手机号,用户ids if (!string.IsNullOrEmpty(filter.proname)) { where += " AND ProName LIKE @proname"; sp.Add(new SqlParameter("proname", "%" + filter.proname + "%")); } if (!string.IsNullOrEmpty(filter.orderno)) { where += " AND OrderNo LIKE @orderno"; sp.Add(new SqlParameter("orderno", "%" + filter.orderno + "%")); } if (!string.IsNullOrEmpty(filter.reuser)) { where += " AND (Rename LIKE @reuser OR Receiver LIKE @reuser)"; sp.Add(new SqlParameter("reuser", "%" + filter.reuser + "%")); } if (!string.IsNullOrEmpty(filter.mobile)) { where += " AND MobileNum LIKE @mobile"; sp.Add(new SqlParameter("mobile", "%" + filter.mobile + "%")); } if (!string.IsNullOrEmpty(filter.uids) && SafeSC.CheckIDS(filter.uids)) { where += " AND UserID IN (" + filter.uids + ")"; } //下单日期 if (!string.IsNullOrEmpty(filter.stime)) { DateTime result = DateTime.Now; if (DateTime.TryParse(filter.stime, out result)) { where += " AND AddTime>=@stime"; sp.Add(new SqlParameter("stime", result.ToString("yyyy/MM/dd 00:00:00"))); } } if (!string.IsNullOrEmpty(filter.etime)) { DateTime result = DateTime.Now; if (DateTime.TryParse(filter.etime, out result)) { where += " AND AddTime<=@etime"; sp.Add(new SqlParameter("etime", result.ToString("yyyy/MM/dd 23:59:59"))); } } //发货时间 if (!string.IsNullOrEmpty(filter.expstime) || !string.IsNullOrEmpty(filter.expetime)) { where += " AND ExpSTime IS NOT NULL "; } if (!string.IsNullOrEmpty(filter.expstime))//按发货日期筛选 { DateTime result = DateTime.Now; if (DateTime.TryParse(filter.expstime, out result)) { where += " AND ExpSTime>=@expstime"; sp.Add(new SqlParameter("expstime", result.ToString("yyyy/MM/dd 00:00:00"))); } } if (!string.IsNullOrEmpty(filter.expetime)) { DateTime result = DateTime.Now; if (DateTime.TryParse(filter.expetime, out result)) { where += " AND ExpSTime<=@expetime"; sp.Add(new SqlParameter("expetime", result.ToString("yyyy/MM/dd 23:59:59"))); } } //搜索,支持指定条件 if (!string.IsNullOrEmpty(filter.skey)) { sp.Add(new SqlParameter("skey", "%" + filter.skey + "%")); switch (filter.stype) { case "exp": where += " AND ExpressDelivery LIKE @skey"; break; case "oid": where += " AND ID= " + DataConvert.CLng(filter.skey); break; } } if (!String.IsNullOrEmpty(filter.oids)) { SafeSC.CheckIDSEx(filter.oids); where += " AND ID IN (" + filter.oids + ")"; } if (filter.payType != -100) { where += " AND PayType=" + filter.payType; } ////商品信息 //string mtbname = "(SELECT *,LinPrice,Thumbnails,GuessXML,ProCode FROM ZL_CartPro A LEFT JOIN ZL_Commodities B ON ProID=ID)"; ////订单与用户信息 //string stbname = "(SELECT *,ParentUserID,HoneyName,ZL_Order_Exp.CDate AS ExpSTime FROM ZL_OrderInfo A LEFT JOIN ZL_User B ON UserID=UserID LEFT JOIN ZL_Order_Exp ON ExpressNum=ZL_Order_Exp.ID)"; //string fields = "ID AS CartID,PClass,ProID,ProName,Shijia,Pronum,AddStatus,AllMoney,StoreID,Thumbnails,GuessXML"//ZL_CartPro // + ",Freight,ID,OrderNo,AddUser,AddTime,OrderStatus,PaymentStatus,OrdersAmount,StateLogistics,Aside,Delivery,Service_charge"//ZL_OrderInfo // + ",OrderType,OrderMessage,Receivablesamount,ExpressNum,PaymentNo" //ZL_OrderInfo // + ",Shengfen,Jiedao,ZipCode,MobileNum,Phone,Email,Receiver,Rename,ExpressDelivery"//地址信息 ZL_OrderInfo // + ",UserID,ParentUserID,HoneyName"//User // + ",ExpSTime";//ZL_Order_Exp //PageSetting setting=PageSetting.Double(filter.cpage,filter.psize,mtbname,stbname,"ID","OrderListID=ID",where,"ID DESC",sp,fields); //return DBCenter.JoinQuery(fields, mtbname, stbname, "OrderListID=ID", where, "ID DESC", sp.ToArray()); string view = "ZL_CartProView"; //只取订单的ID PageSetting setting = PageSetting.Single(filter.cpage, filter.psize, view, "ID", where, " GROUP BY ID ORDER BY ID DESC", sp, "ID"); DBCenter.SelPage(setting); string ids = ""; foreach (DataRow dr in setting.dt.Rows) { ids += dr["id"] + ","; } ids = ids.TrimEnd(','); setting.itemCount = DataConvert.CLng(DBCenter.Count("(SELECT ID FROM ZL_CartProView WHERE " + where + " GROUP BY ID) A", "", sp)); setting.pageCount = SqlBase.GetPageCount(setting.itemCount, setting.psize); //根据订单ID取出购物车中的数据,需要进行名称等筛选 if (!string.IsNullOrEmpty(ids)) { sp.Clear(); string cartWhere = "ID IN (" + ids + ") "; if (!string.IsNullOrEmpty(filter.proname)) { cartWhere += " AND ProName LIKE @proname"; sp.Add(new SqlParameter("proname", "%" + filter.proname + "%")); } setting.dt = DBCenter.Sel(view, cartWhere, "ID DESC", sp); } if (filter.needCount) { string tbname = view; filter.countMod = new OrderCount(); string sql = "SELECT COUNT(ID) AS [all]"; sql += ",(SELECT COUNT(ID) FROM " + tbname + whereCount + " AND Aside=0 AND PaymentStatus=" + (int)M_OrderList.PayEnum.HasPayed + " AND StateLogistics=" + (int)M_OrderList.ExpEnum.NoSend + ") unexp"; sql += ",(SELECT COUNT(ID) FROM " + tbname + whereCount + " AND Aside=0 AND PaymentStatus=" + (int)M_OrderList.PayEnum.NoPay + ") unpaid"; sql += ",(SELECT COUNT(ID) FROM " + tbname + whereCount + " AND Aside=0 AND Delivery=1 AND IsCount=0) prepay"; sql += ",(SELECT COUNT(ID) FROM " + tbname + whereCount + " AND ((PaymentStatus=1 AND Delivery=0) OR (Delivery=1 AND IsCount=1 AND Settle=1))) paid"; sql += ",(SELECT COUNT(ID) FROM " + tbname + whereCount + " AND Aside=0 AND StateLogistics>" + (int)M_OrderList.ExpEnum.NoSend + ") exped"; sql += ",(SELECT COUNT(ID) FROM " + tbname + whereCount + " AND Aside=0 AND OrderStatus=" + (int)M_OrderList.StatusEnum.OrderFinish + " AND StateLogistics=" + (int)M_OrderList.ExpEnum.HasReceived + ") finished"; sql += ",(SELECT COUNT(ID) FROM " + tbname + whereCount + " AND Aside=0 AND PaymentStatus=" + (int)M_OrderList.PayEnum.RequestRefund + ") unrefund"; sql += ",(SELECT COUNT(ID) FROM " + tbname + whereCount + " AND Aside=0 AND PaymentStatus=" + (int)M_OrderList.PayEnum.Refunded + ") refunded"; sql += ",(SELECT COUNT(ID) FROM " + tbname + whereCount + " AND Aside=1) recycle"; sql += " FROM " + tbname + whereCount + " AND Aside=0"; DataTable dt = DBCenter.ExecuteTable(sql); filter.countMod.all = DataConvert.CLng(dt.Rows[0]["all"]); filter.countMod.unexp = DataConvert.CLng(dt.Rows[0]["unexp"]); filter.countMod.unpaid = DataConvert.CLng(dt.Rows[0]["unpaid"]); filter.countMod.prepay = DataConvert.CLng(dt.Rows[0]["prepay"]); filter.countMod.paid = DataConvert.CLng(dt.Rows[0]["paid"]); filter.countMod.exped = DataConvert.CLng(dt.Rows[0]["exped"]); filter.countMod.finished = DataConvert.CLng(dt.Rows[0]["finished"]); filter.countMod.unrefund = DataConvert.CLng(dt.Rows[0]["unrefund"]); filter.countMod.refunded = DataConvert.CLng(dt.Rows[0]["refunded"]); filter.countMod.recycle = DataConvert.CLng(dt.Rows[0]["recycle"]); } return(setting); }
/// <summary> /// 后台使用订单筛选 /// </summary> public DataTable SelForOrderList(string orderType, string filter, string proname, string orderno, string reuser, string mobile, string uids, string skeyType, string skey, string stime, string etime, string expstime, string expetime) { List <SqlParameter> sp = new List <SqlParameter>(); //商品信息 string mtbname = "(SELECT A.*,B.LinPrice,B.Thumbnails,B.GuessXML,B.ProCode FROM " + TbName + " A LEFT JOIN " + new M_Product().TbName + " B ON A.ProID=B.ID)"; //订单与用户信息 string stbname = "(SELECT A.*,B.ParentUserID,B.HoneyName,ZL_Order_Exp.CDate AS ExpSTime" + " FROM ZL_OrderInfo A LEFT JOIN ZL_User B ON A.UserID=B.UserID LEFT JOIN ZL_Order_Exp ON A.ExpressNum=ZL_Order_Exp.ID)"; string where = " B.Aside=0 "; string order = "A.ID DESC"; string fields = "A.ID AS CartID,A.ProID,A.ProName,A.Shijia,A.Pronum,A.AddStatus,A.AllMoney,A.StoreID,A.Thumbnails,A.GuessXML,B.Freight"; //ZL_Cart fields += ",B.ID,B.OrderNo,B.AddUser,B.AddTime,B.OrderStatus,B.PaymentStatus,B.OrdersAmount,B.StateLogistics,B.Aside,B.Delivery,B.Service_charge"; //ZL_OrderInfo fields += ",B.OrderType,B.OrderMessage,B.Receivablesamount,B.ExpressNum"; fields += ",B.Shengfen,B.Jiedao,B.ZipCode,B.MobileNum,B.Phone,B.Email,B.Receiver,B.Rename,B.ExpressDelivery"; //地址信息 ZL_OrderInfo fields += ",B.UserID,B.ParentUserID,B.HoneyName"; //User fields += ",B.ExpSTime"; switch (filter) //筛选 { case "unexp": //待发货==已付款+未发货 where += " AND B.PaymentStatus=" + (int)M_OrderList.PayEnum.HasPayed + " AND B.StateLogistics=" + (int)M_OrderList.ExpEnum.NoSend; break; case "unpaid": //待付款==状态为未付款的 where += " AND B.PaymentStatus=" + (int)M_OrderList.PayEnum.NoPay; break; case "exped": //已发货==大于未发货状态的订单 where += " AND B.StateLogistics>" + (int)M_OrderList.ExpEnum.NoSend; break; case "finished": where += " AND B.OrderStatus=" + (int)M_OrderList.StatusEnum.OrderFinish; break; case "unrefund": where += " AND B.PaymentStatus=" + (int)M_OrderList.PayEnum.RequestRefund; break; case "refunded": where += " AND B.PaymentStatus=" + (int)M_OrderList.PayEnum.Refunded; break; case "recycle": //订单回收站==已关闭 where = " B.Aside=1 "; break; case "all": //全部(不含回收站) default: break; } //未指定类型,则抽出常规订单 if (string.IsNullOrEmpty(orderType)) { where += " AND B.OrderType=0"; } else if (orderType.Equals("-1")) { } else { SafeSC.CheckIDSEx(orderType); where += " AND B.Ordertype IN (" + orderType + ")"; } if (!string.IsNullOrEmpty(proname)) { where += " AND A.ProName LIKE @proname"; sp.Add(new SqlParameter("proname", "%" + proname + "%")); } if (!string.IsNullOrEmpty(orderno)) { where += " AND B.OrderNo LIKE @orderno"; sp.Add(new SqlParameter("orderno", "%" + orderno + "%")); } if (!string.IsNullOrEmpty(reuser)) { where += " AND B.ReUser LIKE @reuser"; sp.Add(new SqlParameter("reuser", "%" + reuser + "%")); } if (!string.IsNullOrEmpty(mobile)) { where += " AND B.Mobile LIKE @mobile"; sp.Add(new SqlParameter("mobile", "%" + mobile + "%")); } if (!string.IsNullOrEmpty(uids) && SafeSC.CheckIDS(uids)) { where += " AND UserID IN (" + uids + ")"; } if (!string.IsNullOrEmpty(stime))//支持下单日期筛选 { DateTime result = DateTime.Now; if (DateTime.TryParse(stime, out result)) { where += " AND B.AddTime>=@stime"; sp.Add(new SqlParameter("stime", result.ToString("yyyy/MM/dd 00:00:00"))); } } if (!string.IsNullOrEmpty(etime)) { DateTime result = DateTime.Now; if (DateTime.TryParse(etime, out result)) { where += " AND B.AddTime<=@etime"; sp.Add(new SqlParameter("etime", result.ToString("yyyy/MM/dd 23:59:59"))); } } if (!string.IsNullOrEmpty(expstime) || !string.IsNullOrEmpty(expetime)) { where += " AND B.ExpSTime IS NOT NULL "; } if (!string.IsNullOrEmpty(expstime))//按发货日期筛选 { DateTime result = DateTime.Now; if (DateTime.TryParse(expstime, out result)) { where += " AND B.ExpSTime>=@expstime"; sp.Add(new SqlParameter("expstime", result.ToString("yyyy/MM/dd 00:00:00"))); } } if (!string.IsNullOrEmpty(expetime)) { DateTime result = DateTime.Now; if (DateTime.TryParse(expetime, out result)) { where += " AND B.ExpSTime<=@expetime"; sp.Add(new SqlParameter("expetime", result.ToString("yyyy/MM/dd 23:59:59"))); } } //唯一性条件搜索 if (!string.IsNullOrEmpty(skey)) { sp.Add(new SqlParameter("skey", "%" + skey + "%")); switch (skeyType) { case "exp": where += " AND B.ExpressDelivery LIKE @skey"; break; case "oid": where += " AND A.ID= " + DataConvert.CLng(skey); break; } } return(DBCenter.JoinQuery(fields, mtbname, stbname, "A.OrderListID=B.ID", where, order, sp.ToArray())); }