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_editjdr : 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 (!IsPostBack) { if (Session["IFPassword"] == null) { Response.Redirect("/Member_IFPassword.aspx?Url=/admin_member_editjdr.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.SuperiorsID).ToString(); txtUserID1.Text = strtjr; } } } } Btn_Edit.Click += delegate(object s, EventArgs ex) { bool b = true; if (txtUserID.Text.Trim() == "") { b = false; ClientScript.RegisterStartupScript(this.GetType(), "", ""); } if (txtUserID2.Text.Trim() == "") { b = false; ClientScript.RegisterStartupScript(this.GetType(), "", ""); } if (b) { Btn_Edit.Enabled = false; int YID = 0, YSuperiorsID = 0, uLevel14=0; Double Yumoney19 = 0.00; string Yuserstate = "", YSuperiorsIDS = ""; SqlDataReader Dr = daoUser.GetUserId(gtype, txtUserID.Text.Trim()); if (Dr.HasRows) { if (Dr.Read()) { Yuserstate = Dr["UserState"].ToString(); YID = int.Parse(Dr["ID"].ToString()); uLevel14 = int.Parse(Dr["uLevel14"].ToString()); YSuperiorsID = int.Parse(Dr["SuperiorsID"].ToString()); YSuperiorsIDS = Dr["SuperiorsIDS"].ToString(); Yumoney19 = Double.Parse(Dr["umoney19"].ToString()); } Dr.Close(); int SuperiorsID = 0; string SuperiorsIDS = ""; SqlDataReader Dr2 = daoUser.GetUserId(gtype, txtUserID2.Text.Trim()); if (Dr2.HasRows) { if (Dr2.Read()) { SuperiorsID = int.Parse(Dr2["Id"].ToString()); SuperiorsIDS = Dr2["SuperiorsIDS"].ToString(); } Dr2.Close(); DateTime dt = DateTime.Now; if (SuperiorsID != YSuperiorsID) { if (SuperiorsIDS != "") { SuperiorsIDS = SuperiorsIDS + SuperiorsID + ","; } else { SuperiorsIDS = "," + SuperiorsID + ","; } daoUser.UpdateJDR(SuperiorsID, SuperiorsIDS, YID); DataSet ds = daoUser.GetList1("id,SuperiorsID", "a.uutype='0' And (charindex('," + YID + ",',SuperiorsIDS)>0 Or id=" + YID + ") Order By uLevel0 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 dSuperiorsID = Convert.ToInt32(Drr["SuperiorsID"].ToString()); Mtxfw.Model.user_info umodel = daoUser.GetModel(dSuperiorsID); if (umodel != null) { string strSuperiorsIDS = umodel.SuperiorsIDS; int uLevel0 = 0; if (strSuperiorsIDS != "") { strSuperiorsIDS += dSuperiorsID + ","; uLevel0 = strSuperiorsIDS.Split(',').Length - 1; } else { strSuperiorsIDS = "," + dSuperiorsID + ","; uLevel0 = 1; } daoUser.UpdateSuperiorsIDS(strSuperiorsIDS, dID); daoUser.UpdateuLevel("uLevel0", uLevel0, dID); } } } ds.Clear(); Mtxfw.Model.user_Results_jl4 Modeljl4; if (uLevel14 == 1) { daoUser.UpdateuLevel0("tjcount", -1, YSuperiorsID); daoUser.UpdateuLevel0("tjcount", 1, SuperiorsID); string[] ASuperiorsIDS = (YSuperiorsIDS).Split(','); //降级 for (int ak = ASuperiorsIDS.Length - 2; ak > 0; ak--) { if (ASuperiorsIDS[ak] != "") { ds = daoUser.GetList1("ID,uLevel,uLevel4,uLevel11,IFBecomeAgents,umoney19,umoney21,SuperiorsIDS", "uutype='0' And UserState='正常' And IFStores=0 And uLevel8=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 YuLevel4 = Convert.ToInt32(ds.Tables[0].Rows[0]["uLevel4"].ToString()); int YuLevel11 = Convert.ToInt32(ds.Tables[0].Rows[0]["uLevel11"].ToString()); int IFBecomeAgents = Convert.ToInt32(ds.Tables[0].Rows[0]["IFBecomeAgents"].ToString()); Double umoney19 = Convert.ToDouble((Convert.ToDouble(ds.Tables[0].Rows[0]["umoney19"]) - Yumoney19).ToString("f2")); Double Yumoney21 = Convert.ToDouble(Convert.ToDouble(ds.Tables[0].Rows[0]["umoney21"]).ToString("f2")); daoUser.UpdateMoney("umoney19", -Yumoney19, dID); daoUser.UpdateuLevel0("temcount", -1, dID); } } } ASuperiorsIDS = (SuperiorsIDS).Split(','); //升级 for (int ak = ASuperiorsIDS.Length - 2; ak > 0; ak--) { if (ASuperiorsIDS[ak] != "") { ds = daoUser.GetList1("ID,uLevel,uLevel4,uLevel11,IFBecomeAgents,SuperiorsIDS,umoney19", "uutype='0' And UserState='正常' And IFStores=0 And uLevel8=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 YuLevel4 = Convert.ToInt32(ds.Tables[0].Rows[0]["uLevel4"].ToString()); int YuLevel11 = Convert.ToInt32(ds.Tables[0].Rows[0]["uLevel11"].ToString()); int IFBecomeAgents = Convert.ToInt32(ds.Tables[0].Rows[0]["IFBecomeAgents"].ToString()); Double umoney19 = Convert.ToDouble((Convert.ToDouble(ds.Tables[0].Rows[0]["umoney19"]) - Yumoney19).ToString("f2")); //更新业绩 daoUser.UpdateMoney("umoney19", Yumoney19, dID); daoUser.UpdateuLevel0("temcount", 1, dID); } } } } Modeljl4 = new Mtxfw.Model.user_Results_jl4(); Modeljl4.MemberId = YID; Modeljl4.MemberId1 = YSuperiorsID; Modeljl4.MemberId2 = SuperiorsID; Modeljl4.IFUpdateMoney = 0; Modeljl4.utype = "0"; Modeljl4.addtime = dt; Modeljl4.gtype = gtype; new DAL.user_Results_jl4().Add(Modeljl4); DataSet dss = daoUser.GetList1("id", "a.gtype=" + gtype + " and a.uutype='0' And a.UserState='正常' And a.IFStores=0"); if (dss.Tables[0].Rows.Count > 0) { foreach (System.Data.DataRow Drr in dss.Tables[0].Rows) { int dID = Convert.ToInt32(Drr["ID"].ToString()); Double Aumoney21 = 0.00; string strAumoney21 = daoUser.Getzd("sum(umoney21) as umoney21", "a.uutype='0' And a.UserState='正常' and (charindex('," + dID + ",',a.SuperiorsIDs)>0 or id=" + dID + ")").ToString(); if (strAumoney21 != "") { Aumoney21 = Convert.ToDouble(strAumoney21); } Aumoney21 = Convert.ToDouble(Aumoney21.ToString("f2")); daoUser.UpdateMoney2("umoney19", Aumoney21, dID); } } dss.Clear(); 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 { Dr2.Close(); ClientScript.RegisterStartupScript(this.GetType(), "", ""); } } else { Dr.Close(); ClientScript.RegisterStartupScript(this.GetType(), "", ""); } } }; } } }