using System; using System.Collections.Generic; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Globalization; namespace Mtxfw.VipSite { public partial class Admin_Member_zbjy_add : Mtxfw.Utility.MemberBase { public Mtxfw.DAL.user_Goods daoGoods = new Mtxfw.DAL.user_Goods(); Mtxfw.DAL.user_info daoUser = new Mtxfw.DAL.user_info(); DAL.user_Results daoResults = new DAL.user_Results(); DAL.P_Product daoProduct = new DAL.P_Product(); DAL.P_Guige daoGuige = new DAL.P_Guige(); Mtxfw.DAL.order_info daoorder = new Mtxfw.DAL.order_info(); Mtxfw.DAL.order_product_info daoorderproduct = new Mtxfw.DAL.order_product_info(); public Mtxfw.Utility.Config config = new Mtxfw.Utility.Config(""); public String strTitle = "",strBody = ""; public int gtype = 0; protected override void OnLoad(EventArgs e) { base.OnLoad(e); string hostname = Request.Url.Host; if (!IsPostBack) { if (Session["IFPassword"] == null) { Response.Redirect("/Member_IFPassword.aspx?Url=/Admin_Member_zbjy_add.aspx"); } if (IFStores != 1) { Mtxfw.Utility.Tools.Message("您没有权限!", "/gl.aspx"); } if (MemberJS.IndexOf("发货管理") == -1) { Mtxfw.Utility.Tools.Message("您没有权限!", "/gl.aspx"); } Data_Bind(); } Btn_Insert.Click += delegate(object s, EventArgs ex) { Text_UserName.Text = Text_UserName.Text.Trim(); if (Text_UserName.Text != "") { bool b = true; Double minprice = 1000.00, maxprice = 0; int viewId = 0; string strId = daoProduct.Getzd("P_ID", "utype='5' And IFDelete=0 Order by P_HITED desc").ToString(); if (strId != "") { viewId = Convert.ToInt32(strId); } if (b) { DataSet ds = daoUser.GetList1("id,uLevel14,SJRememberID", "UserName='" + Text_UserName.Text + "'"); if (ds.Tables[0].Rows.Count > 0) { int MemberId = Convert.ToInt32(ds.Tables[0].Rows[0]["id"]); int uLevel14 = Convert.ToInt32(ds.Tables[0].Rows[0]["uLevel14"]); int SJRememberID = Convert.ToInt32(ds.Tables[0].Rows[0]["SJRememberID"]); int addressId = 0; int peitype = 0; string contact = ""; string tel = ""; string province = ""; string city = ""; string county = ""; string address = ""; if (b) { if (uLevel14 == 0) { b = false; ClientScript.RegisterStartupScript(this.GetType(), "", ""); } } if (b) { Mtxfw.Model.P_Product pmodel = daoProduct.GetModel(viewId); if (pmodel != null) { string guige = "", color = ""; Mtxfw.Model.P_Guige gmodel = daoGuige.GetModelByProductId(pmodel.P_ID); if (gmodel != null) { minprice = gmodel.G_JG*2; guige = gmodel.G_ID.ToString(); DateTime dt = DateTime.Now; string mindt = dt.ToString("yyyy-MM-dd") + " 00:00:00"; string maxdt = dt.AddDays(1).ToString("yyyy-MM-dd") + " 00:00:00"; if (b) { string OID = dt.ToString("yyMMddHHmmssffff", DateTimeFormatInfo.InvariantInfo); Double Totalprice = gmodel.G_JG * 2; Double zyunfei = 0.00, zzl = Convert.ToDouble(gmodel.G_ZL.ToString("f2")); int Totalnum = 2; Model.order_info Modelorder = new Model.order_info(); Modelorder.pid = viewId; Modelorder.poid = 0; Modelorder.addressid = addressId; Modelorder.orderid = OID; Modelorder.Contactname = contact; Modelorder.Contacttel = tel; Modelorder.Province = province; Modelorder.City = city; Modelorder.County = county; Modelorder.Address = address; Modelorder.Zipcode = ""; Modelorder.Guests = ""; Modelorder.Totalprice = Totalprice; Modelorder.Totalprice0 = 0; Modelorder.Totalprice1 = zyunfei; Modelorder.Totalprice2 = 0; Modelorder.Totalprice3 = 0; Modelorder.Totalprice4 = 0; Modelorder.Totalprice5 = 0; Modelorder.Totalnum = Totalnum; Modelorder.O_Submit = "1"; Modelorder.O_yhj = ""; Modelorder.UserID = MemberId; Modelorder.MemberId = pmodel.P_UserID; Modelorder.selcolor = ""; Modelorder.guige = ""; Modelorder.utype = "5"; Modelorder.ttype = 5; Modelorder.peitype = peitype; Modelorder.gtype = gtype; int OrderID = daoorder.Add(Modelorder); daoorder.UpdateqyState(0, "1", dt, OrderID); daoorder.UpdateIFDelete(1, dt.ToString(), OrderID); int ZKC = 0; bool IFKC = true; string strcolors = gmodel.G_Color; string[] acolors = gmodel.G_Color.Split(','); for (int jj = 0; jj < acolors.Length; jj++) { if (acolors[jj] != "") { var ac = acolors[jj].Split('|'); if (ac.Length > 1) { if (ac[1] != "") { int intNum = Convert.ToInt32(ac[1]); if (ac[0] == color) { intNum = (intNum - Totalnum); if (intNum < 0) { intNum = 0; } strcolors = strcolors.Replace(ac[0] + "|" + ac[1], ac[0] + "|" + intNum); } ZKC += intNum; IFKC = false; } } } } gmodel.G_Color = strcolors; if (IFKC) { gmodel.G_KC = gmodel.G_KC - Totalnum; } else { gmodel.G_KC = ZKC; } new DAL.P_Guige().Update(gmodel); Model.order_product_info opmodel = new Model.order_product_info(); opmodel.pid = viewId; opmodel.orderid = OrderID; opmodel.selcolor = color; opmodel.guige = guige.ToString(); opmodel.DJprice = Totalprice; opmodel.Totalprice = Totalprice * Totalnum; opmodel.Totalnum = Totalnum; opmodel.UserID = MemberId; opmodel.SubmitTime = dt; opmodel.utype = "0"; opmodel.gtype = gtype; daoorderproduct.Add(opmodel); Mtxfw.Model.user_Results ModelResults = new Mtxfw.Model.user_Results(); ModelResults.b0 = minprice; ModelResults.b1 = maxprice; ModelResults.b2 = 1;//预约类型 ModelResults.b3 = 0;//是否已过犹豫期0否1是 ModelResults.b4 = 2;//买单匹配次数 匹配一次减1 ModelResults.b5 = 0;//是否已自动匹配0否1是 ModelResults.b6 = 0;//转卖积分 ModelResults.b7 = 0;//是否已转售或已领取产品 0否1已转售2已领取产品 ModelResults.b8 = 0;//0买进1卖出 ModelResults.b9 = 0;//b8=卖出时0正常卖出1转售中 ModelResults.b10 = 0;//0未结算1已结算 ModelResults.b11 = 0;//是否已举报0否1是 ModelResults.b12 = 0;//是否充许自动匹配0否1是 ModelResults.b13 = 0;//是否冻结0否1是 ModelResults.b14 = 0;//是否已匹配删除0否1是 ModelResults.b15 = 0; ModelResults.b16 = 0;//匹配待审核状态0否1是 ModelResults.b17 = viewId; ModelResults.b18 = OrderID;//盲盒订单ID ModelResults.conent = "预约"; ModelResults.Totalmoney = 0; ModelResults.MemberId = MemberId; ModelResults.UserId = 0; ModelResults.Sended = (SJRememberID == 0 ? MemberId : SJRememberID); ModelResults.ListNumber = ""; ModelResults.Managers = ""; ModelResults.Seef = 0; ModelResults.utype = "12"; ModelResults.addtime = dt; ModelResults.seeftime = dt; Int64 ResultId = daoResults.Add(ModelResults); Model.User_CZ_log logmodel = new Model.User_CZ_log(); logmodel.MemberId = Card; logmodel.AddTime = DateTime.Now; logmodel.IP = Mtxfw.Utility.Common.GetIP; logmodel.Body = "添加买进订单,用户名:" + Text_UserName.Text + ",金额:" + minprice; logmodel.UType = 1; new DAL.User_CZ_log().Add(logmodel); ClientScript.RegisterStartupScript(this.GetType(), "", ""); } } } } } else { ClientScript.RegisterStartupScript(this.GetType(), "", ""); } ds.Clear(); } } }; } protected void Data_Bind() { strTitle = "添加供应链订单"; Page.Title = strTitle + " - " + GetWebName; } } }