using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; public partial class Clearing : System.Web.UI.Page { public static string totle_fee; string OID; public static string UserID; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Bind(); } } protected void Bind() { string UserName; try { System.Data.DataTable dt = (DataTable)Session["member"]; UserName = dt.Rows[0].ToString(); } catch { Response.Redirect("default.aspx"); } UserID = Request.QueryString["p"].ToString(); string sqlstr = "SELECT * FROM v3_pay_the_bill WHERE cID = '" + Request.QueryString["p"].ToString() + "' and IsEnd =0"; DataSet ds = new common().ExcuteReader(sqlstr); if (ds.Tables[0].Rows.Count > 0) { totle_fee = ds.Tables[0].Rows[0]["aggregate_amount"].ToString(); this.Repeater1.DataSource = ds; this.Repeater1.DataBind(); } else { Response.Redirect("list.aspx"); } } protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "del") { string sqlstr = "delete from v3_pay_the_bill where id ='" + e.CommandArgument.ToString() + "'"; if (new common().ExcuteNoneQuery(sqlstr, null)) { Bind(); } else { Methods1.Methods1.Alert(this, "删除失败"); } } } protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { if (Session["member"] != null) { DataTable dt = (DataTable)Session["member"]; UserID = dt.Rows[0]["cid"].ToString(); } OID = "D" + DateTime.Now.ToString("yyMMdd") + Convert.ToString(new Random().Next(0, 10000)).PadLeft(8, '0'); Session["dingdan"] = OID; string sqlstr = "INSERT INTO v3_order(cid,oid,oname,tel,code,mail,address)values ('" + UserID + "','" + OID + "','" + this.txtName.Text.Trim().Replace("'", "‘") + "','" + this.txtPhone.Text.Trim().Replace("'", "‘") + "','" + this.txtPostCode.Text.Trim().Replace("'", "‘") + "','" + this.txtEmail.Text.Trim().Replace("'", "‘") + "','" + this.txtadd.Text.Trim().Replace("'", "‘") + "')"; bool result = new common().ExcuteNoneQuery(sqlstr, null); string SelectPid = " select car.pid as pid, car.amount as [count] from v3_shoppingcar as car where cid = '" + UserID + "'"; DataSet ds = new common().ExcuteReader(SelectPid); bool b = false; foreach (System.Data.DataRow row in ds.Tables[0].Rows) { string InsertItem = " insert into v3_order_Item (cid,pID,OID,amount,IsEnd,EndTime,addtime) values('" + UserID + "','" + row[0].ToString() + "','" + Session["dingdan"].ToString() + " ','" + row[1].ToString() + "',0,0,'" + DateTime.Now.ToString() + "')"; b = new common().ExcuteNoneQuery(InsertItem, null); } if (result && b) { string DelCar = "delete from v3_shoppingcar where cid ='" + UserID + "'"; bool Del = new common().ExcuteNoneQuery(DelCar, null); string DelCle = "update v3_pay_the_bill set Isend =1 where cid = '" + UserID + "'"; bool Cle = new common().ExcuteNoneQuery(DelCle, null); if (Del && Cle) { Response.Redirect("DingDan.aspx?Cid=" + UserID + "&OrderId=" + OID + "&fee=" + totle_fee); } } } }