Files
g.hnyhua.cn/Mtxfw.shop/Member_Info.aspx.cs

264 lines
10 KiB
C#
Raw Normal View History

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.shop
{
public partial class Member_Info : Mtxfw.Utility.MemberBase
{
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;
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if (!IsPostBack)
{
Page.Title = "我的信息 - " + config.webName;
int ID = Card;
if (!String.IsNullOrEmpty(Request.QueryString["ID"]))
{
ID = int.Parse(Request.QueryString["ID"].ToString());
Mtxfw.Model.user_info model2 = daoUser.GetModel(ID);
if (model2 != null)
{
if (model2.ContactID != Card)
{
Response.Redirect("/");
}
}
}
Mtxfw.Model.user_info model = daoUser.GetModel(ID);
if (model != null)
{
Text_UserName.Text = model.UserName;
if (model.IFUpUserName == 0)
{
Text_UserName.ReadOnly = true;
Text_UserName.Enabled = false;
PanelPassword.Visible = false;
}
else
{
PanelPassword.Visible = true;
string strUserName = daoUser.Getzd("UserName", "Id=" + model.ContactID).ToString();
Text_ContactName.Text = strUserName;
}
Text_Email.Text = model.Email;
Text_MailingAddress.Text = model.MailingAddress;
Text_SFZ.Text = model.SFZ;
Text_Mobile.Text = model.Mobile;
Text_Phone.Text = model.Phone;
Text_PostalCode.Text = model.PostalCode;
Text_NCName.Text = model.NCName;
Text_RealName.Text = model.RealName;
Text_CompanyName.Text = model.CompanyName;
Text_CompanyNumber.Text = model.CompanyNumber;
Text_CompanyContact.Text = model.CompanyContact;
Text_ProductName.Text = model.ProductName;
if (model.utype == "1")
{
Panel_Company.Visible = true;
}
else
{
Panel_Company.Visible = false;
}
for (int i = 0; i < Text_Sex.Items.Count; i++)
{
if (model.Sex.IndexOf(Text_Sex.Items[i].Value) != -1)
{
Text_Sex.Items[i].Selected = true;
}
else
{
Text_Sex.Items[i].Selected = false;
}
}
pid = model.Province;
cid = model.City;
qid = model.County;
Text_QQ.Text = model.QQ;
}
}
Btn_Update.Click += Update_Info;
}
protected String GetProvince()
{
StringBuilder sb = new StringBuilder();
Mtxfw.DAL.province daoPro = new Mtxfw.DAL.province();
System.Data.DataSet Ds = daoPro.GetCacheList("", "1=1 Order by Id Asc", "Province");
System.Data.DataTable Dt = (Ds != null && Ds.Tables[0] != null) ? Ds.Tables[0] : null;
foreach (System.Data.DataRow Dr in Dt.Rows)
{
sb.Append("<option value=\"" + Dr["ProvinceID"] + "\">" + Dr["ProvinceName"] + "</option>\r\n");
}
return sb.ToString();
}
protected void Update_Info(object s, EventArgs ex)
{
bool b=true;
int sex = 0;
for (int i = 0; i < Text_Sex.Items.Count; i++)
{
if (Text_Sex.Items[i].Selected == true)
{
sex += 1;
}
}
if (sex == 0)
{
b = false;
Mtxfw.Utility.Tools.Message("性别必须选择");
}
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();
}
if (strProvince == "" || strProvince == "-1")
{
b = false;
Mtxfw.Utility.Tools.Message("省份必须选择");
}
if (strCity == "" || strCity == "-1")
{
b = false;
Mtxfw.Utility.Tools.Message("城市必须选择");
}
if (b)
{
int ContactID = 0;
string ContactIDS = "";
int ID = Card;
if (!String.IsNullOrEmpty(Request.QueryString["ID"]))
{
ID = int.Parse(Request.QueryString["ID"].ToString());
}
Mtxfw.Model.user_info model = daoUser.GetModel(ID);
if (model.IFUpUserName == 1)
{
if (!String.IsNullOrEmpty(Text_ContactName.Text.Trim()))
{
if (!daoUser.IsExists2(Text_ContactName.Text.Trim(), 0))
{
b = false;
Mtxfw.Utility.Tools.Message("介绍人账号不存在,请换一个再试");
}
else
{
SqlDataReader dr = daoUser.GetUserId(Text_ContactName.Text.Trim());
if (dr.HasRows)
{
if (dr.Read())
{
ContactID = int.Parse(dr["Id"].ToString());
ContactIDS = dr["ContactIDS"].ToString();
}
}
dr.Close();
model.ContactID = ContactID;
if (ContactIDS == "")
{
model.ContactIDS = "," + ContactID.ToString() + ",";
}
else
{
model.ContactIDS = ContactIDS + ContactID.ToString() + ",";
}
}
}
if (b)
{
if (!String.IsNullOrEmpty(Text_UserName.Text))
{
if (daoUser.IsExists(Text_UserName.Text) && Text_UserName.Text != model.UserName)
{
b = false;
Mtxfw.Utility.Tools.Message("用户名已被其它用户占用,请换一个再试");
}
else
{
model.UserName = Text_UserName.Text;
}
}
if (Text_Password.Text != "")
{
model.Password = Mtxfw.Utility.Security.EncryptString(Text_Password.Text);
}
if (Text_Password2.Text != "")
{
model.Password2 = Mtxfw.Utility.Security.EncryptString(Text_Password2.Text);
}
}
}
model.NCName = Text_NCName.Text;
model.RealName = Text_RealName.Text;
model.Sex = Text_Sex.SelectedItem.Value;
model.SFZ = Text_SFZ.Text;
model.Phone = Text_Phone.Text;
model.Email = Text_Email.Text;
model.Province = strProvince;
model.City = strCity;
model.County = strCounty;
model.MailingAddress = Text_MailingAddress.Text;
model.PostalCode = Text_PostalCode.Text;
model.QQ = Text_QQ.Text;
model.CompanyName = Text_CompanyName.Text;
model.CompanyNumber = Text_CompanyNumber.Text;
model.CompanyContact = Text_CompanyContact.Text;
model.ProductName = Text_ProductName.Text;
if (b)
{
daoUser.Update(model);
if (model.IFUpUserName == 1)
{
daoUser.UpdateuLevel("IFUpUserName", 0, model.Id);
}
if (Session["returnurl"] != null)
{
string strurl = Session["returnurl"].ToString();
if (strurl.IndexOf("/Member_Info.aspx") == -1)
{
Session.Remove("returnurl");
Mtxfw.Utility.Tools.Message("修改资料成功", strurl);
}
else
{
Mtxfw.Utility.Tools.Message("修改资料成功", Request.Url.AbsoluteUri);
}
}
else
{
Mtxfw.Utility.Tools.Message("修改资料成功", Request.Url.AbsoluteUri);
}
}
}
}
}
}