public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; var msg = context.Request["Adminstra"]; if (msg == "0") { LC_AdminisAdater = new SqlDataAdapter(); LC_AdminisTablel = new DataTable(); LC_AdminisString = new StringBuilder(); LC_AdminisAdater = sql.CreateDa("select u.UserName,Phone,RedliningNuber,SUBSTRING(UpdateResirictID,1,16) as Times,DATEDIFF(DAY,cast(SUBSTRING(UpdateResirictID,1,16) as datetime) , GETDATE()) as days from LC_USERS as u join LC_UPDATE_RESTRICT as r on r.UserName=u.UserName and RertrictID='Sell'"); LC_AdminisAdater.Fill(LC_AdminisTablel); LC_AdminisString.Append("<table class='table'>"); LC_AdminisString.Append("<tr>"); LC_AdminisString.Append("<th>用户名</th><th>号码</th><th>收款账号</th><th>申请时间</th><th>成为卖家</th>"); LC_AdminisString.Append("</tr>"); foreach (DataRow item in LC_AdminisTablel.Rows) { LC_AdminisString.Append("<tr><td>" + item[0].ToString() + "</td><td>" + item[1].ToString() + "</td><td>" + item[2].ToString() + "</td><td>" + item[3].ToString() + "</td><td>" + item[4].ToString() + "/天</td><td><a href='#' class='DeleteSell' type='" + item[0].ToString() + "'>删除</a></td></tr>"); } LC_AdminisString.Append("</table>"); context.Response.Write(LC_AdminisString.ToString()); } else if (msg == "1") { var _usernames = context.Request["Deletes"]; sql.RunProc("update LC_USERS set RertrictID='buy' where UserName='******' "); context.Response.Write("DELETE"); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; var LC_category = context.Request["category"]; if (LC_category == "0") //把数据区里分开 { LC_PayStringBuilder = new StringBuilder(); LC_Payadter = new SqlDataAdapter(); LC_Paytable = new DataTable(); try { //用户名 // LC_PayUsername = context.Request.Cookies["name"].Values[0].ToString(); LC_PayUsername = CookiesValues("name", context).ToString(); AddCookiesValie("username", "one", LC_PayUsername, context); } catch { context.Response.Write("请登录!"); } // context.Response.Write("用户名:" + LC_PayUsername); if (!string.IsNullOrEmpty(LC_PayUsername)) { //如果该用户存在收货信息,就直接把地址等信息发给前台 if (!string.IsNullOrEmpty(sql.ReturnValue("select ConsigneeName from LC_CONSIGNEE where UserName='******'"))) { LC_Payadter = new SqlDataAdapter(); LC_Payadter = sql.CreateDa("select ConsigneeAdrees,ConsigneePhone,ConsigneeName,DefultAdrees,ConsigneeID from LC_CONSIGNEE where UserName='******'"); LC_Payadter.Fill(LC_Paytable); foreach (DataRow item in LC_Paytable.Rows) { LC_PayStringBuilder.Append("<tr><td colspan='3' class='col-md-12'><div class='col-md-12'>"); LC_PayStringBuilder.Append("<input type='radio' class='radio input-sm pull-left' name='" + item[4] + "' value='" + item[3] + "' /> "); LC_PayStringBuilder.Append("<div class='col-md-4 text-left LC_paaddress'>" + item[0] + "</div>"); LC_PayStringBuilder.Append("<div class='col-md-2'><label class='LC_payname'>(" + item[2] + "收)</label></div>"); LC_PayStringBuilder.Append("<div class='col-md-2'><label class='LC_payUnmber'>" + item[1] + "</label></div>"); LC_PayStringBuilder.Append("<div class='col-md-1 pull-right tab-content text-center'><a href='javascript:;' class='h6 DeleteAdrees'>删除</a></div>"); LC_PayStringBuilder.Append("</div>"); LC_PayStringBuilder.Append("</td></tr>"); } LC_PayStringBuilder.Append("<tr><td>"); LC_PayStringBuilder.Append("<button id='ButtonLoad' class='btn btn-success btn-xs' data-toggle='modal' data-target='#myModal'><span class='glyphicon glyphicon-plus'></span>添加新地址 </button></td></tr>"); context.Response.Write(LC_PayStringBuilder.ToString() + "*"); } //如果不存在地址的话就,让用户添加 else { LC_PayStringBuilder.Append("<tr><td>"); LC_PayStringBuilder.Append("<button id='ButtonLoad' class='btn btn-success btn-xs' data-toggle='modal' data-target='#myModal'>添加新地址</button></td></tr>"); context.Response.Write(LC_PayStringBuilder.ToString() + "*"); } var msg = context.Request["Pay"]; //商品ID ; /******************** * 如果说msg当中存在‘*’就是加入购物车后购买的,不存在就是立即购买的!!!【会报错】 **********************/ try { //这个是加入【购物车】之后购买的! int indexof = msg.IndexOf('*'); if (msg.IndexOf('*') > -1) { //商品ID string[] LC_msg = msg.Split('*'); //商品数量 string[] unber = context.Request["Payber"].Split('*'); for (int i = 0; i < LC_msg.Length - 1; i++) { ///商品信息 SqlDataAdapter LC_Pro = sql.CreateDa("select ShowImage,CommodityName,SellPrice,CommodityDescribe from LC_COMMODITY where CommodityID='" + LC_msg[i] + "'"); DataTable LCproTable = new DataTable(); LC_Pro.Fill(LCproTable); StringBuilder LC_Prostring = new StringBuilder(); string pric = ""; foreach (DataRow item in LCproTable.Rows) { LC_Prostring.Append("<tr>"); LC_Prostring.Append("<td class='text-center'><img src='" + item[0] + "' class='img-responsive pull-left' width='50' /><span>" + item[3] + "</span></td>"); LC_Prostring.Append("<td class='text-center'>" + item[2] + "</td>"); LC_Prostring.Append("<td class='text-center'>" + unber[i] + "</td>"); pric = item[2].ToString(); } LC_Prostring.Append("<td class='text-center LC_sum'>" + int.Parse(pric.ToString()) * int.Parse(unber[i]) + "</td>"); LC_Prostring.Append("</tr>"); //商品! context.Response.Write(LC_Prostring.ToString()); } } else { // 这个是直接购买的!!! ///商品信息 SqlDataAdapter LC_Pro = sql.CreateDa("select ShowImage,CommodityName,SellPrice,CommodityDescribe from LC_COMMODITY where CommodityID='" + msg + "'"); DataTable LCproTable = new DataTable(); LC_Pro.Fill(LCproTable); StringBuilder LC_Prostring = new StringBuilder(); string unber = context.Request["Payber"]; string pric = ""; foreach (DataRow item in LCproTable.Rows) { LC_Prostring.Append("<tr>"); LC_Prostring.Append("<td><img src='" + item[0] + "' class='img-responsive pull-left' width='50' /><span >" + item[3] + "</span></td>"); LC_Prostring.Append("<td>" + item[2] + "</td>"); LC_Prostring.Append("<td>" + unber + "</td>"); pric = item[2].ToString(); } LC_Prostring.Append("<td class='LC_sum'>" + int.Parse(pric.ToString()) * int.Parse(unber) + "</td>"); LC_Prostring.Append("</tr>"); //商品! context.Response.Write(LC_Prostring.ToString()); } } catch (Exception el) { context.Response.Write("字符截取错误:" + el); } } else { context.Response.Write("请登录!"); } } else if (LC_category == "1") { //收货人地址信息 var LC_Aderss = context.Request["CONSIGNEE"]; LC_PayUsername = CookiesValues("username", context); if (!string.IsNullOrEmpty(LC_Aderss)) { string[] AdreeMsg = LC_Aderss.Split('*'); //收件人ID string LC_ConsigneeID = AdreeMsg[1] + DateTime.Now.ToString(); sql.RunProc("insert into LC_CONSIGNEE values('" + LC_ConsigneeID + "','" + LC_PayUsername + "','" + AdreeMsg[1] + "','" + AdreeMsg[0] + "','" + AdreeMsg[2] + "','" + AdreeMsg[3] + "')"); context.Response.Write("成功!"); } } //支付宝绑定 else if (LC_category == "2") { LC_PayUsername = CookiesValues("username", context); string LC_RedliningNubers = sql.ReturnValue("select RedliningNuber from LC_USERS where UserName='******'"); if (!string.IsNullOrEmpty(LC_RedliningNubers)) { context.Response.Write(LC_RedliningNubers); } else { context.Response.Write("NULL"); } } else if (LC_category == "3")//添加支付宝信息 { LC_PayUsername = CookiesValues("username", context); var LC_buybuy = context.Request["baybay"].Split('*'); sql.RunProc("update LC_USERS set RedliningNuber='" + LC_buybuy[0] + "',RedNuberPasswrod=" + LC_buybuy[1] + " where UserName='******' "); context.Response.Write("修改成功!"); } else if (LC_category == "4") //对比密码,ss返回余额 { LC_PayUsername = CookiesValues("username", context); var LC_Passwrod = context.Request["paypasswrod"].ToString(); string Sqlpasswrod = sql.ReturnValue("select RedNuberPasswrod from LC_USERS where UserName='******' "); if (LC_Passwrod == Sqlpasswrod) { string Balance = sql.ReturnValue("select Balance from LC_USERS where UserName='******' "); context.Response.Write(int.Parse(Balance)); } else { context.Response.Write("Eroor"); } } else if (LC_category == "5") // 减掉支出 { LC_PayUsername = CookiesValues("username", context); var LC_Consume = context.Request["consume"]; sql.RunProc("update LC_USERS set Balance=" + decimal.Parse(LC_Consume) + " where UserName='******' "); context.Response.Write("账户余额修改成功!"); } //修改余额 else if (LC_category == "6") // 减掉支出 { LC_PayUsername = CookiesValues("username", context); var LC_Balance = context.Request["consume"]; sql.RunProc("update LC_USERS set Balance=" + LC_Balance + " where UserName='******' "); context.Response.Write("修改成功!"); } else if (LC_category == "7") { LC_PayUsername = CookiesValues("username", context); // 用户名 //商品ID: var LC_CommID = context.Request["CommID"]; //数量 var LC_ProNuber = context.Request["ProNuber"]; //价格 // var LC_Price = context.Request["Price"]; /***在修改账户余额的时候就应该把账单表的数据添加完成!在卖家的《今日订单中》直接查找这些数据即可点击发货就把该商品id传到我的类淘中显示我要收货 * 如果是卖家该用户的账户余额应该增加相印的金额!!!! * /********应该先找到该商品的商家,然后买家支付多少该商家就盈利多少!!!********/ if (LC_CommID.IndexOf('*') > -1 && LC_ProNuber.IndexOf('*') > -1) { // string[] ArryCommid = LC_CommID.Substring(0, LC_CommID.Length - 1).Split('*'); string[] ArryProNuber = LC_ProNuber.Substring(0, LC_ProNuber.Length - 1).Split('*'); // string[] ArryPrice = LC_Price.Substring(0, LC_Price.Length - 1).Split('*'); Random sj = new Random(); for (int i = 0; i < ArryCommid.Length; i++) { //插入用户的账单! 到时候直接查询权限就可以知道是收入还是支出 //商品价格 int pricrBill = int.Parse(sql.ReturnValue("select SellPrice from LC_COMMODITY where CommodityID='" + ArryCommid[i] + "'")); //图片ID string LC_BillImgs = sql.ReturnValue("select ShowImage from LC_COMMODITY where CommodityID='" + ArryCommid[i] + "'"); //收件人ID string LC_BillConsigneeID = sql.ReturnValue("select ConsigneeID from LC_CONSIGNEE where UserName='******'"); //账单ID规则:时间精确到秒 sql.RunProc("insert into LC_BILL values('" + DateTime.Now.ToString("yyyyMMddhhmmss") + sj.Next(1000).ToString() + "','" + LC_BillImgs + "','" + ArryCommid[i] + "','" + LC_PayUsername + "','" + DateTime.Now.ToString() + "'," + ArryProNuber[i] + "," + pricrBill * int.Parse(ArryProNuber[i]) + ",'" + LC_BillConsigneeID + "','NO')"); } context.Response.Write("多个数据账单表插入成功!"); } else { //单个商品 int pricrBill = int.Parse(sql.ReturnValue("select SellPrice from LC_COMMODITY where CommodityID='" + LC_CommID + "'")); //图片ID string LC_BillImgs = sql.ReturnValue("select ShowImage from LC_COMMODITY where CommodityID='" + LC_CommID + "'"); //收件人ID string LC_BillConsigneeID = sql.ReturnValue("select ConsigneeID from LC_CONSIGNEE where UserName='******'"); //账单ID规则:时间精确到秒 //插入用户的账单! 到时候直接查询权限就可以知道是收入还是支出 sql.RunProc("insert into LC_BILL values('" + DateTime.Now.ToString("yyyyMMddhhmmss") + "','" + LC_BillImgs + "','" + LC_CommID + "','" + LC_PayUsername + "','" + DateTime.Now.ToString() + "'," + LC_ProNuber + "," + pricrBill + ",'" + LC_BillConsigneeID + "','NO')"); context.Response.Write("账单表插入成功!"); //找到该商品对应的用户名 [收件人ID为空] [用过卖家姓名找到该卖家的用户名] // string LC_SeellUsername = sql.ReturnValue("select UserName from LC_COMMODITY where CommodityID='" + ProidOrunber_Arry[0] + "'"); //sql.RunProc("insert into LC_BILL(ShowImage,CommodityID,UserName,PaymentTime,BuyNumber,BuyPrice) values('" + LC_BillImgs + "','" + ProidOrunber_Arry[0] + "','" + LC_SeellUsername + "'," + DateTime.Now.ToString() + "," + int.Parse(ProidOrunber_Arry[1]) + "," + pricrBill + ")"); //修改卖家的账户余额 //sql.RunProc("update LC_USERS set Balance=Balance+" + pricrBill + " where UserName='******' "); //context.Response.Write("卖家的账户余额修改成功!"); } } else if (LC_category == "8") //修改用户的默认地址 { // 先修改原来的默认地址,在添加新的默认地址 string LC_ConsigneenID = sql.ReturnValue("select ConsigneeID from LC_CONSIGNEE where DefultAdrees='1'"); sql.RunProc("update LC_CONSIGNEE set DefultAdrees='0' where ConsigneeID='" + LC_ConsigneenID + "'"); var msg = context.Request["Addressid"]; //新增默认地址 sql.RunProc("update LC_CONSIGNEE set DefultAdrees='1' where ConsigneeID='" + msg + "'"); context.Response.Write("Ture"); } else if (LC_category == "9") //删除用户地址 { var msg = context.Request["Addressid"]; sql.RunProc("delete from LC_CONSIGNEE where ConsigneeID='" + msg + "'"); context.Response.Write("Ture"); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; var msg = context.Request["My"]; if (msg == "0") { //判断是几个商品 StringBuilder MYdelivery = new StringBuilder(); var LC_MyProid = context.Request["myproOne"]; var LC_MyNunber = context.Request["myproTwo"]; //var LC_MyPrice = context.Request["myproThree"]; //&& LC_MyPrice.IndexOf('*') > -1 if (LC_MyProid.IndexOf('*') > -1 && LC_MyNunber.IndexOf('*') > -1) { string[] ArryCommid = LC_MyProid.Split('*'); string[] ArryProNuber = LC_MyNunber.Split('*'); /// string[] ArryPrice = LC_MyPrice.Split('*'); for (int i = 0; i < ArryCommid.Length; i++) { //商品描述 string LC_CommodityDescribe = sql.ReturnValue("select CommodityDescribe from LC_COMMODITY where CommodityID='" + ArryCommid[i] + "' "); //判断是否是已发货 string lc_consignment = sql.ReturnValue("select consignment from LC_BILL where CommodityID='" + ArryCommid[i] + "'"); ///商品信息 SqlDataAdapter LC_Myadpter = sql.CreateDa("select ShowImage,CommodityDescribe,SellPrice from LC_COMMODITY where CommodityID='" + ArryCommid[i] + "'"); DataTable LC_MyTable = new DataTable(); LC_Myadpter.Fill(LC_MyTable); string LC_Prostring = ""; foreach (DataRow item in LC_MyTable.Rows) { LC_Prostring += "<tr>" + "<td><img src='" + item[0].ToString() + "' name='" + lc_consignment + "' class='img-responsive pull-left' width='50' /><span>" + LC_CommodityDescribe + "</span></td>" + "<td>" + item[2].ToString() + "</td>" + "<td>" + ArryProNuber[i] + "</td>" + "<td>" + int.Parse(item[2].ToString()) * int.Parse(ArryProNuber[i]) + "</td>" + "<td><button type='button' id='" + ArryCommid[i] + "' class='" + lc_consignment + " MyDelivery btn btn-default btn-xs'>确认收货</button></td>" + "</tr>"; } context.Response.Write(LC_Prostring); } } //一个商品 else { string lc_consignment = sql.ReturnValue("select consignment from LC_BILL where CommodityID='" + LC_MyProid + "'"); ///商品信息 SqlDataAdapter LC_Myadpter = sql.CreateDa("select ShowImage,CommodityName,CommodityDescribe,SellPrice from LC_COMMODITY where CommodityID='" + LC_MyProid + "'"); DataTable LC_MyTable = new DataTable(); LC_Myadpter.Fill(LC_MyTable); string LC_Prostring = ""; foreach (DataRow item in LC_MyTable.Rows) { LC_Prostring += "<tr>" + "<td><img src='" + item[0].ToString() + "' class='img-responsive pull-left' width='50' /><span>" + item[1].ToString() + "</span></td>" + "<td>" + item[3] + "</td>" + "<td>" + LC_MyNunber + "</td>" + "<td>" + int.Parse(item[3].ToString()) * int.Parse(LC_MyNunber) + "</td>" + ")" + "<td ><button type='button' id='" + LC_MyProid + "' class='" + lc_consignment + " MyDelivery btn btn-default btn-xs'>确认收货</button></td>" + "</tr>"; // LC_Prostring += item[0] + "*" + item[1] + "*" + item[2] + "*" + item[3]; } context.Response.Write(LC_Prostring); //判断是否是已发货 // string lc_consignment = sql.ReturnValue("select consignment from LC_BILL where CommodityID='" + LC_MyProid + "'"); // ///商品信息 // SqlDataAdapter LC_Myadpter = sql.CreateDa("select ShowImage,CommodityName,CommodityDescribe,SellPrice from LC_COMMODITY where CommodityID='" + LC_MyProid + "'"); // DataTable LC_MyTable = new DataTable(); // LC_Myadpter.Fill(LC_MyTable); // string LC_Prostring = ""; // foreach (DataRow item in LC_MyTable.Rows) // { // LC_Prostring += item[0] + "*" + item[1] + "*" + item[2] + "*" + item[3]; // } // context.Response.Write(LC_Prostring + "*" + lc_consignment); } } else if (msg == "1") { try { var LC_MyProid = context.Request["mypro"]; //用户名 //var _username = context.Request.Cookies["name"].Values[0].ToString(); var _username = CookiesValues("name", context); //评价表ID规则: 用户名+随机数 Random sj = new Random(); string ran = sj.Next(100, 999).ToString(); string LC_Evaluteid = ran + _username; //详细表ID规则:用户名+当前时间 string LC_Detailid = _username + DateTime.Now.ToString(); //评价内容 var LC_discuss = context.Request["Mydiscuss"]; sql.RunProc("insert into LC_EVALUATE values('" + LC_Evaluteid + "','" + LC_MyProid + "')"); sql.RunProc("insert into LC_EVALUATE_DETAIL values('" + LC_Detailid + "','" + LC_Evaluteid + "','" + _username + "','" + LC_discuss + "')"); context.Response.Write("true"); } catch { context.Response.Write("请登录!"); } } else if (msg == "2") { string MyTrtd = ""; string LC_BillConsiID = ""; string CommodityID = ""; /****该商品的信息*****/ string LC_CommodityName = sql.ReturnValue("select CommodityName from LC_COMMODITY where CommodityID in(select CommodityID from LC_BILL where consignment='NO')"); /***账单表中的内容****/ SqlDataAdapter LC_billAdpter = new SqlDataAdapter(); LC_billAdpter = sql.CreateDa("select UserName,ShowImage,ConsigneeID,BuyNumber,BuyPrice,CommodityID from LC_BILL where consignment='NO'"); DataTable LC_billDataTable = new DataTable(); LC_billAdpter.Fill(LC_billDataTable); foreach (DataRow item in LC_billDataTable.Rows) { LC_BillConsiID = item[2].ToString(); MyTrtd += "<tr>" + "<td><label>" + item[0] + "</label></td>" + "<td><img src='" + item[1] + "' class='img-responsive pull-left' width='50' /><span>" + LC_CommodityName + "</span></td>" + "<td>" + item[3] + "</td>" + "<td>" + item[4] + "</td>" + ")"; CommodityID = item[5].ToString(); //收件人号码和姓名,地址 SqlDataAdapter LC_consignAdpter = new SqlDataAdapter(); LC_consignAdpter = sql.CreateDa("select ConsigneeName,ConsigneeAdrees,ConsigneePhone from LC_CONSIGNEE where ConsigneeID='" + LC_BillConsiID + "'"); DataTable LC_consignTable = new DataTable(); LC_consignAdpter.Fill(LC_consignTable); foreach (DataRow temp in LC_consignTable.Rows) { MyTrtd += "<td>" + temp[0] + "</td>" + "<td>" + temp[1] + "</td>" + "<td>" + temp[2] + "</td>" + "<td class='" + CommodityID + "'><button type='button' class='btn btn-default Immediately btn-xs'>立即发货</button></td>" + "</tr>"; } } context.Response.Write(MyTrtd.ToString()); } else if (msg == "3") { var LC_setPro = context.Request["UPdateconsignment"]; sql.RunProc("update LC_BILL set consignment='YES' where CommodityID='" + LC_setPro + "'"); context.Response.Write("已经发货........"); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; var intNunmber = context.Request["Number"]; //对比用户名是否重复 if (intNunmber == "2") { var username = context.Request["Variate"]; // context.Response.Write("号码:" + inputPhone); falge = sql.ExistDate("select UserName from LC_USERS where UserName='******' "); if (falge) { context.Response.Write("true"); } else { context.Response.Write("false"); } } if (intNunmber == "1") { //输入完成后就和数据库中的号码比对 var inputPhone = context.Request["Variate"]; // context.Response.Write("号码:" + inputPhone); falge = sql.ExistDate("select Phone from LC_USERS where Phone='" + inputPhone + "' "); if (falge) { context.Response.Write("true"); } else { context.Response.Write("false"); } } else if (intNunmber == "3") { var msg = context.Request["Variate"]; string[] LC_UserMessage = msg.Split('*'); if (LC_UserMessage[0] != "" && LC_UserMessage[1] != "" && LC_UserMessage[2] != "") { context.Response.Write("接受的是:" + msg); //插入用户注册基本信息 try { newpasswrod = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(LC_UserMessage[1], "MD5"); #region +++ //用户ID=精确到毫秒+1000以内的随机数【保证不重复】 DateTime now = DateTime.Now; string Msec = now.ToString(@"fff"); //精确到毫秒 Random sj = new Random(); string UserID = now.ToString() + "/" + Msec + "*" + sj.Next(1000); //context.Response.Write("<script>alert('你的ID是:" + UserID + "','" + Msec + "')</script>"); #endregion context.Response.Write("电话!" + LC_UserMessage[0].ToString()); //插入用户表数据 sql.RunProc("insert into LC_USERS(UserID,Passwrod,UserName,Phone,RertrictID) values('" + UserID + "','" + newpasswrod + "','" + LC_UserMessage[2].ToString() + "','" + LC_UserMessage[0].ToString() + "','" + RertrictID + "')"); context.Response.Write("注册成功!"); //当他注册成功后!就把权限编程表的数据插入 string UpRestrictID = now + "/" + Msec; //权限ID sql.RunProc("insert into LC_UPDATE_RESTRICT(UpdateResirictID,UserName) values('" + UpRestrictID + "','" + LC_UserMessage[2].ToString() + "');"); context.Response.Write("变更表更新成功!"); } catch (Exception el) { context.Response.Write("出入信息时候发生错误:" + el + " "); } } else { context.Response.Write("<script>alert('为空!')</script>"); } } }
public void ProcessRequest(HttpContext context) { SQLDBC sql = new SQLDBC(); //context.Response.Write("用户名是:"+LC_UserName); var Adminstrator = ""; //管理员界面操作数据库[] Adminstrator = context.Request["Adminstra"]; var LC_Shoping = context.Request["Shopping"]; //判断权限 if (LC_Shoping == "0") { // var _usernaem = context.Request.Cookies["name"].Values[0]; var _usernaem = CookiesValues("name", context); string LC_RertrictIDs = sql.ReturnValue("select RestrictID from Vi_RESTRICT where UserName='******'"); if (LC_RertrictIDs == "buy") { context.Response.Write("buy"); } else if (LC_RertrictIDs == "sell") { context.Response.Write("sell"); } else if (LC_RertrictIDs == "management") { context.Response.Write("management"); } else { context.Response.Write("admin"); } } var LC_Repulse = context.Request["Refuse"]; // 管理员同意后台操作! if (!string.IsNullOrEmpty(LC_Repulse)) { var LC_AdminUserName = context.Request["Variate"]; //是否允许该用户名成为卖家 if (LC_Repulse == "YES") { //context.Response.Write("接受成功!该用户名是:" + LC_AdminUserName); sql.RunProc("update LC_UPDATE_RESTRICT set ApplyResult=1 where UserName='******' "); //context.Response.Write("您已经是卖家了!"); string BuyPro = CookiesValues("Sell", context); if (!string.IsNullOrEmpty(BuyPro)) { sql.RunProc("update LC_USERS set RedliningNuber='" + BuyPro[0] + "', RedNuberPasswrod='" + BuyPro[1] + "' where UserID='" + BuyPro[0] + "'"); context.Response.Write("支付数据保存成功!"); } } if (LC_Repulse == "NO") { sql.RunProc("update LC_UPDATE_RESTRICT set ApplyResult=2 where UserName='******' "); context.Response.Write("申请失败!"); } } else { // context.Response.Write("你正在提交申请成为卖家!"); if (Adminstrator != "0") //申请成为卖家页面 { try { var LC_UserName = context.Request["Variate"]; // 申明一个信号,表示已经提交申请成为卖家,同时把该用户的支付信息添加到用户表中 if (LC_UserName != "亲,请登陆") { string[] BuyPro = LC_UserName.Split('*'); //存入支付账号和密码到COOkies中 AddCookiesValie("Sell", "keys", BuyPro[1] + "*" + BuyPro[2], context); //该申请的用户只能是买家 string sell = sql.ReturnValue("select RertrictID from LC_USERS where UserName='******'"); if (sell == "buy") { HttpCookie ShopCookie = new HttpCookie("Upshop"); ShopCookie.Value = "arrhy"; context.Response.AppendCookie(ShopCookie); context.Response.Write("数据保存成功!"); } else { context.Response.Write("您已经是卖家了!不能重复提交您的信息哦!"); return; } } else { context.Response.Write("请登录!"); } } catch { }; } } }
public void ProcessRequest(HttpContext context) { var LC_Shoping = context.Request["Shopping"]; var _usernaem = ""; try { // _usernaem = context.Request.Cookies["name"].Values[0].ToString(); _usernaem = CookiesValues("name", context); AddCookiesValie("shopping", "keys", _usernaem, context); } catch { context.Response.Write("请登录!"); } if (LC_Shoping == "1") { var LC_Shop = context.Request["PurShopp"]; if (!string.IsNullOrEmpty(LC_Shop.ToString())) { string[] LC_ShopProid = LC_Shop.Split('*'); int sumPrice = int.Parse(LC_ShopProid[1]) * int.Parse(LC_ShopProid[2]); //总价格 AddCookiesValie("shopPirce", "keys", sumPrice.ToString(), context); try { //如果有尺码这些的话,直接在后面给条件就好 string LC_ShowProNunber = sql.ReturnValue("select CommodityID from LC_SHOPPING_CART where CommodityID='" + LC_ShopProid[0] + "' "); if (!string.IsNullOrEmpty(LC_ShowProNunber)) { sql.RunProc("update LC_SHOPPING_CART set AddNumber=AddNumber+" + int.Parse(LC_ShopProid[1]) + " where CommodityID='" + LC_ShopProid[0] + "'"); } else { sql.RunProc("insert into LC_SHOPPING_CART values('" + _usernaem + DateTime.Now.ToString() + "','" + _usernaem + "','" + LC_ShopProid[0] + "','" + DateTime.Now.ToString() + "','" + LC_ShopProid[1] + "'," + LC_ShopProid[2] + ")"); } } catch (Exception el) { context.Response.Write("购物车数据添加失败!" + el); } // context.Response.Write("购物车表插入成功!"); } } else if (LC_Shoping == "2") { _usernaem = CookiesValues("shopping", context).ToString(); string LC_Detailimgs = ""; //购物车表 LC_ShoppString = new StringBuilder(); LC_ShoppAdater = new SqlDataAdapter(); LC_ShoppTable = new DataTable(); LC_ShoppAdater = sql.CreateDa("SELECT CommodityID,AddNumber,Price,ShoppingID FROM LC_SHOPPING_CART WHERE UserName='******';"); LC_ShoppAdater.Fill(LC_ShoppTable); foreach (DataRow item in LC_ShoppTable.Rows) { //商品表 LC_Commoddater = new SqlDataAdapter(); LC_CommodTable = new DataTable(); LC_commString = new StringBuilder(); LC_Commoddater = sql.CreateDa("SELECT ShowImage,CommodityDescribe FROM LC_COMMODITY WHERE CommodityID='" + item[0] + "';"); LC_Commoddater.Fill(LC_CommodTable); int sumPrice = int.Parse(CookiesValues("shopPirce", context)); string Showimgs = ""; string Describe = ""; foreach (DataRow itemConmm in LC_CommodTable.Rows) { Showimgs = itemConmm[0].ToString(); Describe = itemConmm[1].ToString(); } LC_ShoppString.Append("<tr>"); LC_ShoppString.Append("<td class='text-center'>"); LC_ShoppString.Append("<input type='checkbox' class='input-sm input-group' value='" + item[0] + "' /></td>"); LC_ShoppString.Append("<td>"); LC_ShoppString.Append("<img src='" + Showimgs + "' class='img-responsive' width='50' /></td>"); LC_ShoppString.Append("<td>" + Describe + "</td>"); LC_ShoppString.Append("<td class='" + item[0] + "'>" + item[2] + "</td>"); LC_ShoppString.Append("<td class='text-center'>"); LC_ShoppString.Append("<div class='col-md-5 '>"); LC_ShoppString.Append("<button class='btn btn-default PurSubtract btn-sm pull-left' ><strong>-</strong></button>"); LC_ShoppString.Append("<input class='col-md-3 Number input-group text-center input-sm pull-left' value='" + item[1] + "' />"); LC_ShoppString.Append("<button class='btn PurPuls btn-default btn-sm' ><strong>+</strong></button>"); LC_ShoppString.Append("</div>"); LC_ShoppString.Append("</td>"); LC_ShoppString.Append("<td><b class='h4' style='color:red;'>" + int.Parse(item[1].ToString()) * int.Parse(item[2].ToString()) + "</b></td>"); LC_ShoppString.Append("<td><a href='#' class='Delete' delete='" + item[3] + "'>删除</a></td>"); LC_ShoppString.Append("</tr>"); } context.Response.Write(LC_ShoppString.ToString()); } //删除 else if (LC_Shoping == "3") { var LC_DeletePro = context.Request["deleteProid"]; sql.RunProc("delete from LC_SHOPPING_CART where ShoppingID='" + LC_DeletePro + "' "); context.Response.Write("Yes"); } }
private string _username; //用户名 public void ProcessRequest(HttpContext context) { //一般程序都是从头开始执行!!变量的存储会在程序重新运行的时候清空!!!!! context.Response.ContentType = "text/plain"; //_username = context.Request.Cookies["name"].Values[0].ToString(); _username = CookiesValues("name", context).ToString(); if (_username == "0") { context.Response.Write("请登录!"); } ///详细图片ID string DetailImageID = (int)(char)_username[0] + DateTime.Now.ToShortDateString(); // 详细图片ID命名规则: 扩展名前的字符! AddCookiesValie("LC_Detail", "deteailID", DetailImageID, context); //判断属性该个人用户的文件是否存在 if (Directory.Exists(context.Server.MapPath("~/App_Image/SellerProImage/" + _username + "")) == false) { //如果不存在就创建file文件夹 Directory.CreateDirectory(context.Server.MapPath("~/App_Image/SellerProImage/" + _username + "")); //Directory.Delete(Server.MapPath("~/upimg/hufu"), true);//删除文件夹以及文件夹中的子目录,文件 } else { string json = "成功!"; try { HttpRequest request = System.Web.HttpContext.Current.Request; HttpFileCollection FileCollect = request.Files; HttpPostedFile file; try { file = context.Request.Files["shows"]; file = context.Request.Files["shows"]; string imgPath = "App_Image/SellerProImage/" + _username + "/" + file.FileName; file.SaveAs(context.Server.MapPath("~/") + imgPath); //展示图 string ShowImage = "../" + imgPath; AddCookiesValie("LC_Show", "imgss", ShowImage, context); } catch { file = context.Request.Files["model_file"]; string imgPath = "App_Image/SellerProImage/" + _username + "/" + file.FileName; file.SaveAs(context.Server.MapPath("~/") + imgPath); /** * 优化提示:在本处找不到一个可以储存长字符的全局变量如果可以的话直接把所有的详细图片的ID存放在其中! * 就不必直接插入数据库这样不易于修改! **/ //解读详细id LC_DetailImageID = CookiesValues("LC_Detail", context).ToString(); sql.RunProc("insert into LC_IMAGE values('" + LC_DetailImageID + "','../App_Image/SellerProImage/" + _username + "/" + file.FileName + "')"); } } catch (Exception ex) { //失败时返回的参数必须加 error键 json = "{\"error\":\"" + ex.Message + "\"}"; } } var qufen = context.Request["Distinguish"]; if (qufen == "0") { /*商品分类*/ var msg = context.Request["filenames"]; /// context.Response.Write("分类是:"+msg+" "); //怎么用一个sql查询找到该用户选择的类别???????????????????? try { LC_Sonadter = sql.CreateDa("select CommodityCategory from LC_COMMODITY_CATEGORY where MinuteID='" + msg + "'"); LC_Sontable = new DataTable(); LC_Sonadter.Fill(LC_Sontable); foreach (DataRow item in LC_Sontable.Rows) { context.Response.Write(item[0].ToString() + "*"); } string commodity = sql.ReturnValue("select CommodityCategory from LC_COMMODITY_CATEGORY where CategoryID='" + msg + "' "); if (!string.IsNullOrEmpty(commodity)) { //商品类别 AddCookiesValie("LC_Commodity", "commdo", commodity, context); } else { context.Response.Write("请选择商品类别!!"); } } catch (Exception el) { context.Response.Write(el); } } else if (qufen == "1") { #region var Pro = context.Request["uploadPRO"]; string[] information = Pro.Split('*'); //商品类别 LC_CommodityCategory = CookiesValues("LC_Commodity", context).ToString(); //详细图ID LC_DetailImageID = CookiesValues("LC_Detail", context).ToString(); //展示图 LC_ShowImage = CookiesValues("LC_Show", context).ToString(); //卖家姓名 LC_MerchantName = information[5].ToString(); try { //商品ID规则:该用户的用户名的前两个字的ULCD编码 +当前时间精确到毫秒 string LC_NowTime = DateTime.Now.ToString("yyyyMMddhhmmss"); if (_username.ToString().Length > 2) { for (int i = 0; i < 2; i++) { char chars = (char)_username.ToString()[i]; int names = (int)chars; LC_NowTime = names.ToString() + LC_NowTime; } } LC_CommodityID = LC_NowTime; } catch { context.Response.Write("请登录!"); } //商品名 LC_CommodityName = information[0].ToString(); try { //成本价&销售价 LC_CostPrice = decimal.Parse(information[2]); LC_SellPrice = decimal.Parse(information[3]); } catch { context.Response.Write("价格数据转化失败!"); } //库存 LC_Repertory = information[1].ToString(); //商品描述 LC_CommodityDescribe = information[4].ToString(); //上架时间 LC_UploadingTime = DateTime.Parse(information[7]); //商品状态 LC_CommodityState = "上架"; #endregion /********************** 添加数据到表************************/ // context.Response.Write("商品ID: " + LC_CommodityID + "卖家姓名 " + LC_MerchantName + "商品名 " + LC_CommodityName + // "商品类别 " + LC_CommodityCategory + "展示图 " + LC_ShowImage + "详细图ID " + LC_DetailImageID + "成本价 " + LC_CostPrice // + " 销售价 " + LC_SellPrice + "库存 " + LC_Repertory + "商品描述 " + LC_CommodityDescribe + "上架时间 " + LC_UploadingTime); try { //商品表 sql.RunProc("insert into LC_COMMODITY values('" + LC_CommodityID + "','" + LC_MerchantName + "','" + LC_CommodityName + "','" + LC_CommodityCategory + "','" + LC_ShowImage + "','" + LC_DetailImageID + "'," + LC_CostPrice + "," + LC_SellPrice + ",'" + LC_Repertory + "','" + LC_CommodityDescribe + "','" + LC_UploadingTime + "','" + LC_CommodityState + "')"); // context.Response.Write("商品表插入成功!"); //商品表添加成功后才可以添加图片表! //try //{ // //图片表 // //string[] LC_sonImagPath = information[8].Split('_'); // //for (int i = 0; i < LC_sonImagPath.Length; i++) // //{ // // if (!string.IsNullOrEmpty(LC_sonImagPath[i])) // // { // // //sql.RunProc("insert into LC_IMAGE values('" + LC_DetailImageID + "','../App_Image/SellerProImage/" + _username + "/" + LC_sonImagPath[i].ToString() + "')"); // // } // //} // //context.Response.Write("详细图片插入成功!"); //} //catch (Exception el) //{ // context.Response.Write("添加数据到图片表错误: " + el); //} } catch (Exception el) { context.Response.Write("添加数据到商品表错误: " + el); } context.Response.Write("SucceesImage"); } }