using System;
using System.Collections;
using System.Data;
using System.Web.UI;
using System.Web.UI.WebControls;
using Sigil.Common;
using SigilSoft.Data.SqlClient;
using Sigil.Task;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Sigil.Stock;
namespace Sigil.Ste37
{
/// <summary>
/// 信息设置自定义画面
/// </summary>
public partial class ClientDetail : PageList
{
#region 声明控件
protected TextBox Email = new TextBox();
protected TextBox MemberName = new TextBox();
protected RadioButton SexMan = new RadioButton();
protected RadioButton SexWoman = new RadioButton();
protected TextBox birthday = new TextBox();
protected TextBox address_mobile = new TextBox();
protected TextBox address_phone = new TextBox();
protected TextBox address_Address1 = new TextBox();
protected TextBox address_postcode = new TextBox();
protected TextBox Remark = new TextBox();
protected Button Save = new Button();
protected TextBox Cid = new TextBox();
protected TextBox address_Id = new TextBox();
protected TextBox Mes_success = new TextBox();
protected TextBox Mes_failed = new TextBox();
#endregion
protected Member member = new Member();
//页面载入
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ReadCilent();
}
}
#region 保存
protected void SavaClient_Click(object sender, EventArgs e)
{
if (SaveClinet())
{
MessageBox.Show("修改成功", MainPanel, this.GetType());
}
else
{
MessageBox.Show("修改失败", MainPanel, this.GetType());
}
}
//保存信息
protected bool SaveClinet()
{
//Members.MemberUpdate(3, MemberName.Text, "", "", Email.Text, 0, "", DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now, 0, 0, true, "");
member.MemberId = TypeParser.ToInt32(Cid.Text);
member.MemberName = MemberName.Text;
member.Sex = SexMan.Checked;
member.Email = Email.Text;
member.Remark = Remark.Text;
member.Birthday = birthday.Text;
MemberAddress ma = new MemberAddress();
ma.Fax = MemberName.Text;
ma.Address2 = " ";
ma.City = "";
ma.Province = "";
ma.Country = "";
ma.Postcode = address_postcode.Text;
ma.Maid = TypeParser.ToInt32(address_Id.Text);
ma.Mid = TypeParser.ToInt32(Cid.Text);
ma.Mobile = address_mobile.Text;
ma.Phone = address_phone.Text;
ma.Address1 = address_Address1.Text;
Collection<Gladiator> mAddressList = new Collection<Gladiator>();
mAddressList.Add(ma);
int sucess = 0;
if (Cid.Text.Equals(string.Empty) == false)
sucess = Members.DoMemberANDAddressUpdateTransaction(member, mAddressList);
else
sucess = Members.DoMemberAndAddressInsertTransaction(member, mAddressList);
if (sucess == 0)
{
return false;
}
return true;
}
#endregion
#region 读取会员数据
protected void ReadCilent()
{
// int memberId = Convert.ToInt32(SessionHelper.GetSession("mid"));
int memberId = 3;
member = Members.GetDetail(memberId);
Cid.Text = memberId.ToString();
Email.Text = member.Email.ToString();
MemberName.Text = member.MemberName.ToString();
if (member.Sex == true)
{
SexMan.Checked = true;
SexWoman.Checked = false;
}
else
{
SexWoman.Checked = true;
SexMan.Checked = false;
}
birthday.Text = member.Birthday.ToString();
Remark.Text = member.Remark.ToString();
//读取第一条地址
ReadFirstAddress(memberId);
}
#endregion
#region 读取第一条地址
/// <summary>
/// 读取地址
/// </summary>
/// <param name="memberId"></param>
private void ReadFirstAddress(int memberId)
{
DataTable add = Members.GetAddresssList(memberId);
if (add != null && add.Rows.Count > 0)
{
DataRow address = add.Rows[0];
address_Id.Text = TypeParser.ToString(address["maid"]);
address_Address1.Text = TypeParser.ToString(address["address1"]);
address_mobile.Text = TypeParser.ToString(address["mobile"]);
address_phone.Text = TypeParser.ToString(address["phone"]);
address_postcode.Text = TypeParser.ToString(address["postcode"]);
}
}
#endregion
}
}