using System; using System.Collections.Generic; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Text; using System.Data; using System.Data.SqlClient; namespace Mtxfw.VipSite { public partial class admin_member_edittjr : Mtxfw.Utility.MemberBase { public Mtxfw.DAL.user_Results_jl4 daojl = new Mtxfw.DAL.user_Results_jl4(); public Mtxfw.DAL.user_info daoUser = new Mtxfw.DAL.user_info(); public Mtxfw.Utility.Config config = new Mtxfw.Utility.Config(""); Mtxfw.DAL.user_bank daoBank = new Mtxfw.DAL.user_bank(); protected String pid, cid, qid; public int gtype = 0; protected override void OnLoad(EventArgs e) { base.OnLoad(e); string hostname = Request.Url.Host; if (Session["IFPassword"] == null) { Response.Redirect("/Member_IFPassword.aspx?Url=/admin_member_edittjr.aspx"); } if (IFStores != 1) { Mtxfw.Utility.Tools.Message("您没有权限!", "/gl.aspx"); } if (MemberJS.IndexOf("修改推荐人") == -1) { Mtxfw.Utility.Tools.Message("您没有权限!", "/gl.aspx"); } if (Request.UrlReferrer != null) { Hidd_Url.Value = Request.UrlReferrer.ToString(); } Page.Title = "修改推荐人 - " + config.webName; if (!String.IsNullOrEmpty(Request.QueryString["ID"])) { int ID = int.Parse(Request.QueryString["ID"].ToString()); Mtxfw.Model.user_info model = daoUser.GetModel(ID); if (model != null) { if (!IsPostBack) { /*string[] strProductName = config.webTongji.Split('|'); for (int i = 0; i < strProductName.Length; i++) { ProductName.Items.Add(new ListItem(strProductName[i], strProductName[i])); }*/ txtUserID.Text = model.UserName; string strtjr = daoUser.Getzd("UserName", "id=" + model.ContactID).ToString(); txtUserID1.Text = strtjr; } } } Btn_Edit.Click += delegate(object s, EventArgs ex) { bool b = true; Btn_Edit.Enabled = false; if (txtUserID.Text.Trim() == "") { b = false; Btn_Edit.Enabled = true; ClientScript.RegisterStartupScript(this.GetType(), "", ""); } if (txtUserID2.Text.Trim() == "") { b = false; Btn_Edit.Enabled = true; ClientScript.RegisterStartupScript(this.GetType(), "", ""); } if (b) { int YID = 0, YContactID = 0, uLevel = 0, uLevel14 = 0; Double Yumoney18 = 0.00,Yumoney19 = 0.00; string Yuserstate = "", YContactIDS = ""; SqlDataReader Dr = daoUser.GetUserId(gtype, txtUserID.Text.Trim()); if (Dr.HasRows) { if (Dr.Read()) { Yuserstate = Dr["UserState"].ToString(); YID = int.Parse(Dr["ID"].ToString()); YContactID = int.Parse(Dr["ContactID"].ToString()); uLevel = int.Parse(Dr["uLevel"].ToString()); uLevel14 = int.Parse(Dr["uLevel14"].ToString()); YContactIDS = Dr["ContactIDS"].ToString(); Yumoney18 = Double.Parse(Dr["umoney18"].ToString()); Yumoney19 = Double.Parse(Dr["umoney19"].ToString()); } Dr.Close(); int ContactID = 0, XContactID = 0, SJRememberID = 0; string ContactIDS = ""; SqlDataReader Dr2 = daoUser.GetUserId(gtype, txtUserID2.Text.Trim()); if (Dr2.HasRows) { if (Dr2.Read()) { ContactID = int.Parse(Dr2["Id"].ToString()); XContactID = int.Parse(Dr2["ContactID"].ToString()); ContactIDS = Dr2["ContactIDS"].ToString(); } Dr2.Close(); DateTime dt = DateTime.Now; if (XContactID != YID) { if (ContactID != YContactID) { if (ContactIDS != "") { ContactIDS = ContactIDS + ContactID + ","; } else { ContactIDS = "," + ContactID + ","; } daoUser.UpdateTJR(ContactID, ContactIDS, YID); DataSet ds = daoUser.GetList1("id,ContactID", "uutype='0' And (charindex('," + YID + ",',ContactIDS)>0 Or id=" + YID + ") Order By uLevel1 asc"); if (ds.Tables[0].Rows.Count > 0) { foreach (System.Data.DataRow Drr in ds.Tables[0].Rows) { int dID = Convert.ToInt32(Drr["ID"].ToString()); int dContactID = Convert.ToInt32(Drr["ContactID"].ToString()); Mtxfw.Model.user_info umodel = daoUser.GetModel(dContactID); if (umodel != null) { string strContactIDs = umodel.ContactIDS; int uLevel1 = 0; if (strContactIDs != "") { strContactIDs += dContactID + ","; uLevel1 = strContactIDs.Split(',').Length - 1; } else { strContactIDs = "," + dContactID + ","; uLevel1 = 1; } daoUser.UpdateContactIDS(strContactIDs, dID); daoUser.UpdateuLevel("uLevel1", uLevel1, dID); } } } ds.Clear(); Mtxfw.Model.user_Results_jl4 Modeljl4; if (uLevel14 == 1) { string[] ASuperiorsIDS = (YContactIDS).Split(','); //降级 for (int ak = ASuperiorsIDS.Length - 2; ak > 0; ak--) { if (ASuperiorsIDS[ak] != "") { ds = daoUser.GetList1("ID,uLevel,YuLevel24,IFBecomeAgents,umoney33,ContactIDS", "uutype='0' And UserState='正常' And IFStores=0 And id=" + ASuperiorsIDS[ak]); if (ds.Tables[0].Rows.Count > 0) { int dID = Convert.ToInt32(ds.Tables[0].Rows[0]["ID"].ToString()); int YuLevel = Convert.ToInt32(ds.Tables[0].Rows[0]["uLevel"].ToString()); int YuLevel24 = Convert.ToInt32(ds.Tables[0].Rows[0]["uLevel24"].ToString()); int YIFBecomeAgents = Convert.ToInt32(ds.Tables[0].Rows[0]["IFBecomeAgents"].ToString()); int dumoney33 = Convert.ToInt32(ds.Tables[0].Rows[0]["umoney33"].ToString().Split('.')[0]); string dContactIDS = ds.Tables[0].Rows[0]["ContactIDS"].ToString(); daoUser.UpdateMoney("umoney18", -Yumoney18, dID); } ds.Clear(); } } ASuperiorsIDS = (ContactIDS).Split(','); //升级 for (int ak = ASuperiorsIDS.Length - 2; ak > 0; ak--) { if (ASuperiorsIDS[ak] != "") { ds = daoUser.GetList1("ID,uLevel,YuLevel24,IFBecomeAgents,umoney33,ContactIDS", "uutype='0' And UserState='正常' And IFStores=0 And id=" + ASuperiorsIDS[ak]); if (ds.Tables[0].Rows.Count > 0) { int dID = Convert.ToInt32(ds.Tables[0].Rows[0]["ID"].ToString()); int YuLevel = Convert.ToInt32(ds.Tables[0].Rows[0]["uLevel"].ToString()); int YuLevel24 = Convert.ToInt32(ds.Tables[0].Rows[0]["uLevel24"].ToString()); int YIFBecomeAgents = Convert.ToInt32(ds.Tables[0].Rows[0]["IFBecomeAgents"].ToString()); int dumoney33 = Convert.ToInt32(ds.Tables[0].Rows[0]["umoney33"].ToString().Split('.')[0]); string dContactIDS = ds.Tables[0].Rows[0]["ContactIDS"].ToString(); daoUser.UpdateMoney("umoney18", Yumoney18, dID); } } } } Modeljl4 = new Mtxfw.Model.user_Results_jl4(); Modeljl4.MemberId = YID; Modeljl4.MemberId1 = YContactID; Modeljl4.MemberId2 = ContactID; Modeljl4.IFUpdateMoney = 0; Modeljl4.utype = "1"; Modeljl4.addtime = dt; Modeljl4.gtype = gtype; new DAL.user_Results_jl4().Add(Modeljl4); Model.User_CZ_log logmodel = new Model.User_CZ_log(); logmodel.MemberId = Card; logmodel.AddTime = dt; logmodel.IP = Mtxfw.Utility.Common.GetIP; logmodel.Body = "修改推荐人,用户名:" + txtUserID.Text + ",原推荐人:" + txtUserID1.Text + ",现推荐人:" + txtUserID2.Text; logmodel.UType = 0; logmodel.gtype = gtype; new DAL.User_CZ_log().Add(logmodel); ClientScript.RegisterStartupScript(this.GetType(), "", ""); } else { ClientScript.RegisterStartupScript(this.GetType(), "", ""); } } else { ClientScript.RegisterStartupScript(this.GetType(), "", ""); } } else { Dr2.Close(); ClientScript.RegisterStartupScript(this.GetType(), "", ""); } } else { Dr.Close(); ClientScript.RegisterStartupScript(this.GetType(), "", ""); } } }; } } }