Files
g.hnyhua.cn/Mtxfw.VipSite/Admin_Member_appdeclaration_edit.aspx.cs
2026-02-07 15:48:27 +08:00

313 lines
17 KiB
C#

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Data;
namespace Mtxfw.VipSite
{
public partial class Admin_Member_appdeclaration_edit : Mtxfw.Utility.MemberBase
{
public Mtxfw.DAL.user_proxy daoproxy = new Mtxfw.DAL.user_proxy();
public Mtxfw.DAL.user_info daoUser = new Mtxfw.DAL.user_info();
public Mtxfw.Utility.Config config = new Mtxfw.Utility.Config("");
protected String pid, cid, qid, tid;
public int gtype = 0;
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
string hostname = Request.Url.Host;
try
{
if (!String.IsNullOrEmpty(Request.QueryString["ID"]))
{
int ID = int.Parse(Request.QueryString["ID"].ToString());
if (Session["IFPassword"] == null)
{
Response.Redirect("/Member_IFPassword.aspx?Url=/Admin_Member_appdeclaration_edit.aspx" + HttpUtility.UrlEncode("?") + "id=" + ID);
}
if (IFStores != 1)
{
Mtxfw.Utility.Tools.Message("您没有权限!", "/gl.aspx");
}
if (MemberJS.IndexOf("代理列表") == -1)
{
Mtxfw.Utility.Tools.Message("您没有权限!", "/gl.aspx");
}
if (!IsPostBack)
{
Page.Title = "修改代理 - " + config.webName;
if (Request.UrlReferrer != null)
{
Hidd_Url.Value = Request.UrlReferrer.ToString();
}
}
Mtxfw.Model.user_proxy pmodel = daoproxy.GetModel(ID);
if (pmodel != null)
{
Mtxfw.Model.user_info model = daoUser.GetModel(pmodel.MemberId);
if (model != null)
{
if (!IsPostBack)
{
Text_UserName.Text = model.UserName;
Text_Tel.Text = pmodel.ATel.ToString();
address.Text = pmodel.AAddress;
tradingname.Text = (pmodel.IFFill == 1 ? pmodel.Agentrading : "");
lng.Value = pmodel.longitude.ToString("0.######");
lat.Value = pmodel.latitude.ToString("0.######");
for (int i = 0; i < Drop_LB.Items.Count; i++)
{
if (pmodel.AgenLevel.ToString() == Drop_LB.Items[i].Value)
{
Drop_LB.Items[i].Selected = true;
}
else
{
Drop_LB.Items[i].Selected = false;
}
}
Mtxfw.Model.user_info umodel = daoUser.GetModel(pmodel.AgentRecomID);
if (umodel != null)
{
Text_RecomName.Text = umodel.UserName;
}
}
pid = pmodel.Agenprovince;
cid = pmodel.Agencity;
qid = pmodel.Agencounty;
tid = (pmodel.IFFill == 1 ? "-1" : pmodel.Agentrading);
}
}
}
}
catch (Exception err)
{
Mtxfw.Utility.Common.WriteHtml("/weixin/aerr.txt", err.ToString());
}
Btn_Update.Click += Update_Info;
}
protected void Update_Info(object s, EventArgs ex)
{
if (!String.IsNullOrEmpty(Request.QueryString["ID"]))
{
int ID = int.Parse(Request.QueryString["ID"].ToString());
Mtxfw.Model.user_proxy pmodel = daoproxy.GetModel(ID);
if (pmodel != null)
{
Mtxfw.Model.user_info umodel = daoUser.GetModel(pmodel.MemberId);
if (umodel != null)
{
int DLJB = Convert.ToInt32(Drop_LB.SelectedItem.Value);
string strProvince = "", strCity = "", strCounty = "";
if (Request.Form["select_p"] != null)
{
strProvince = Request.Form["select_p"].ToString();
}
if (Request.Form["select_c"] != null)
{
strCity = Request.Form["select_c"].ToString();
}
if (Request.Form["select_q"] != null)
{
strCounty = Request.Form["select_q"].ToString();
}
string tradingarea = "";
if (Request.Form["select_t"] != null)
{
tradingarea = Request.Form["select_t"].ToString();
}
bool b = true;
Text_Tel.Text = Text_Tel.Text.Trim();
if (Text_Tel.Text == "")
{
b = false;
ClientScript.RegisterStartupScript(this.GetType(), "", "<script type='text/javascript'>alert('联系电话不能为空!');</script>");
}
if (b)
{
if (DLJB == 5)
{
if (strProvince == "" || strProvince == "-1")
{
b = false;
ClientScript.RegisterStartupScript(this.GetType(), "", "<script type='text/javascript'>alert('省份必须选择!');</script>");
}
if (b)
{
if (daoproxy.GetCount("gtype=" + gtype + " and TType=1 And Id<>" + pmodel.Id + " And AgenLevel=" + DLJB + " And Agenprovince='" + strProvince + "'") > 0)
{
b = false;
ClientScript.RegisterStartupScript(this.GetType(), "", "<script type='text/javascript'>alert('所选省份已经有省代!');</script>");
}
}
}
else if (DLJB == 4)
{
if (strProvince == "" || strProvince == "-1")
{
b = false;
ClientScript.RegisterStartupScript(this.GetType(), "", "<script type='text/javascript'>alert('省份必须选择!');</script>");
}
if (b)
{
if (strCity == "" || strCity == "-1")
{
b = false;
ClientScript.RegisterStartupScript(this.GetType(), "", "<script type='text/javascript'>alert('城市必须选择!');</script>");
}
}
if (b)
{
if (daoproxy.GetCount("gtype="+ gtype + " and TType=1 And Id<>" + pmodel.Id + " And AgenLevel=" + DLJB + " And Agenprovince='" + strProvince + "' And Agencity='" + strCity + "'") > 0)
{
b = false;
ClientScript.RegisterStartupScript(this.GetType(), "", "<script type='text/javascript'>alert('所选城市已经有市代!');</script>");
}
}
}
else if (DLJB == 3)
{
if (strProvince == "" || strProvince == "-1")
{
b = false;
ClientScript.RegisterStartupScript(this.GetType(), "", "<script type='text/javascript'>alert('省份必须选择!');</script>");
}
if (b)
{
if (strCity == "" || strCity == "-1")
{
b = false;
ClientScript.RegisterStartupScript(this.GetType(), "", "<script type='text/javascript'>alert('城市必须选择!');</script>");
}
}
if (b)
{
if (strCounty == "" || strCounty == "-1")
{
b = false;
ClientScript.RegisterStartupScript(this.GetType(), "", "<script type='text/javascript'>alert('区县必须选择!');</script>");
}
}
if (b)
{
if (daoproxy.GetCount("gtype=" + gtype + " and TType=1 And Id<>" + pmodel.Id + " And AgenLevel=" + DLJB + " And Agenprovince='" + strProvince + "' And Agencity='" + strCity + "' And Agencounty='" + strCounty + "'") > 0)
{
b = false;
ClientScript.RegisterStartupScript(this.GetType(), "", "<script type='text/javascript'>alert('所选区县已经有区代!');</script>");
}
}
}
else if (DLJB == 2)
{
if (strProvince == "" || strProvince == "-1")
{
b = false;
ClientScript.RegisterStartupScript(this.GetType(), "", "<script type='text/javascript'>alert('省份必须选择!');</script>");
}
if (b)
{
if (strCity == "" || strCity == "-1")
{
b = false;
ClientScript.RegisterStartupScript(this.GetType(), "", "<script type='text/javascript'>alert('城市必须选择!');</script>");
}
}
if (b)
{
if (strCounty == "" || strCounty == "-1")
{
b = false;
ClientScript.RegisterStartupScript(this.GetType(), "", "<script type='text/javascript'>alert('区县必须选择!');</script>");
}
}
if (b)
{
if (tradingarea == "")
{
b = false;
ClientScript.RegisterStartupScript(this.GetType(), "", "<script type='text/javascript'>alert('街道/乡镇必须选择或填写!');</script>");
}
}
if (b)
{
if (daoproxy.GetCount("gtype=" + gtype + " and TType=1 And Id<>" + pmodel.Id + " And AgenLevel=" + DLJB + " And Agenprovince='" + strProvince + "' And Agencity='" + strCity + "' And Agencounty='" + strCounty + "' And Agentrading='" + tradingarea + "'") > 0)
{
b = false;
ClientScript.RegisterStartupScript(this.GetType(), "", "<script type='text/javascript'>alert('所选街道/乡镇已经有乡代!');</script>");
}
}
}
}
int AgentRecomID = 0;
Text_RecomName.Text = Text_RecomName.Text.Trim();
if (Text_RecomName.Text != "")
{
string strid = daoUser.Getzd("id", "IFStores=0 and UserName='" + Text_RecomName.Text + "'").ToString();
if (strid != "")
{
AgentRecomID = Convert.ToInt32(strid);
}
}
/*string strumoney24 = Text_DQ.Text.Trim();
if (b)
{
if (strumoney24 == "")
{
b = false;
ClientScript.RegisterStartupScript(this.GetType(), "", "<script type='text/javascript'>alert('加盟费不能为空!');</script>");
}
else
{
if (!System.Text.RegularExpressions.Regex.IsMatch(strumoney24, @"^-?([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)$") && !System.Text.RegularExpressions.Regex.IsMatch(strumoney24, @"^-?\d+$"))
{
b = false;
ClientScript.RegisterStartupScript(this.GetType(), "", "<script type='text/javascript'>alert('加盟费填写错误!');</script>");
}
}
}*/
if (b)
{
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 = "修改代理" + umodel.UserName + ",区域:" + new DAL.province().GetProvince(strProvince) + new DAL.city().GetCity(strCity) + new DAL.county().GetCounty(strCounty);
logmodel.UType = 0;
logmodel.gtype = gtype;
new DAL.User_CZ_log().Add(logmodel);
pmodel.AgenLevel = DLJB;
pmodel.AgentRecomID = AgentRecomID;
pmodel.Agenprovince = strProvince;
pmodel.Agencity = strCity;
pmodel.Agencounty = strCounty;
pmodel.IFFill = (tradingarea == "-1" ? 1 : 0);
pmodel.Agentrading = (tradingarea == "-1" ? tradingname.Text.Trim() : tradingarea);;
pmodel.AAddress = address.Text;
pmodel.ATel = Text_Tel.Text;
pmodel.latitude = 0;
pmodel.longitude = 0;
daoproxy.Update(pmodel);
if (pmodel.seef == 1)
{
daoUser.UpdateuLevel("uLevel25", DLJB, umodel.Id);
}
ClientScript.RegisterStartupScript(this.GetType(), "", "<script type='text/javascript'>alert('提交成功!');location.replace('" + Hidd_Url.Value + "')</script>");
}
}
}
}
}
}
}