⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 membermodify.aspx.cs

📁 易想商城系统
💻 CS
字号:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Collections.Generic;
using YXShop.Common;
using Shop.Web.UI;

namespace YXShop.Web.Admin.Consumer
{
    public partial class MemberModify : System.Web.UI.Page
    {
        public static int id = 0;
        BasePage bp = new BasePage();
        YXShop.BLL.MemberInfo mbBll = new YXShop.BLL.MemberInfo();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (YXShop.Common.WebUtility.isNumeric(Request.QueryString["ID"]))
                {
                    id = Convert.ToInt32(Request.QueryString["ID"]);
                    BindMemberInfo(id);
                }
                else
                {
                    Response.Redirect("MemberAllList.aspx");
                }
            }
        }
        #region xxxxx
        private void InitMember(DropDownList ddl, int memberGroupID)
        {
            YXShop.BLL.MemberRand membBll = new YXShop.BLL.MemberRand();
            List<YXShop.Model.MemberRand> li = membBll.GetAll();
            ListItem lItem = null;
            foreach (YXShop.Model.MemberRand mRand in li)
            {
                lItem = new ListItem();
                lItem.Value = mRand.Rank_ID.ToString();
                lItem.Text = mRand.Rank_name;
                if (mRand.Rank_ID == memberGroupID)
                {
                    lItem.Selected = true;
                }
                ddl.Items.Add(lItem);
                lItem = null;
            }
        }
        private void InitRadionList(RadioButtonList rbList, int valueID)
        {
            for (int i = 0; i < rbList.Items.Count; i++)
            {
                if (rbList.Items[i].Value == valueID.ToString())
                {
                    rbList.Items[i].Selected = true;
                }
                else
                {
                    rbList.Items[i].Selected = false;
                }
            }
        }
        private void InitSelectList(DropDownList ddl, string textStr)
        {
            for (int i = 0; i < ddl.Items.Count; i++)
            {
                if (ddl.Items[i].Text == textStr)
                {
                    ddl.Items[i].Selected = true;
                }
                else
                {
                    ddl.Items[i].Selected = false;
                }
            }
        }
        #endregion

        private void BindMemberInfo(int MemberID)
        {
            List<YXShop.Model.MemberInfo> mbList = mbBll.GetListByColumn("UID", MemberID);
            YXShop.BLL.UserCommon ucBll = new YXShop.BLL.UserCommon();
            List<YXShop.Model.UserCommon> ucList = ucBll.GetListByColumn("UID", MemberID);
            if (ucList.Count > 0 && mbList.Count > 0)
            {
                YXShop.Model.MemberInfo model = mbList[0];
                #region 初始化
                Label1.Text = ucList[0].UserName; //mbList[0].uUserName;
                HiddenField1.Value = ucList[0].PassWord; //model.uUserPwd;
                uUserEmail.Text = ucList[0].UEmail;// model.uEMail;
                uFindQuestion.Text = ucList[0].UQuestion;// model.uQuestion;
                uFindAnswer.Text = ucList[0].USolution;// model.uAnswer;
                InitMember(DropDownList1, Convert.ToInt32(model.uGroupId));//会员组
                tbPost.Text = model.post;
                uUserState.Checked = Convert.ToInt32(model.fMemberState) == 0 ? false : true;

                Image1.ImageUrl = "~/" + model.uPhotoAddr;
                imgH.Text = model.uPhotoH.ToString();
                imgW.Text = model.uPhotoW.ToString();

                #region 扩展属性参数
                cAddrInfo.Text = model.cAddrInfo;
                TextBox8.Text = model.pPapersNumber;

                cFaxNumber.Text = model.cFaxNumber;
                cHomePhone.Text = model.cHomePhone;
                cICQNumber.Text = model.cICQNumber;
                cMobilePhone.Text = model.cMobilePhone;
                //1
                cMSNNumber.Text = model.cMSNNumber;
                cOfficePhone.Text = model.cOfficePhone;
                cPersonIndex.Text = model.cPersonIndex;
                cPHSNumber.Text = model.cPHSNumber;
                cPrefixal.Text = model.cPrefixal;
                //2
                cQQNumber.Text = model.cQQNumber;
                cTrueName.Text = model.cTrueName;
                cUCNumber.Text = model.cUCNumber;
                pAaH.Text = model.pAaH;
                pAH.Text = model.pAH;
                //3
                //pBirthday.Date = model.pBirthday;
                pCaH.Text = model.pCaH;
                pEaL.Text = model.pEaL;
                pEB.SelectedItem.Text = model.pEB;
                pFamilyInfo.Text = model.pFamilyInfo;
                //4
                pLaH.Text = model.pLaH;
                InitRadionList(pMarriage, Convert.ToInt32(model.pMarriage));
                //gongzi.SelectedValue = model.pMonthlyIncome;
                pNation.Text = model.pNation;
                pNos.Text = model.pNos;
                //5
                pPaH.Text = model.pPaH;

                InitSelectList(pPapersType, model.pPapersType);
                InitRadionList(pSex, Convert.ToInt32(model.pSex));

                //0 = model.uPrivacySettings;
                //string.Empty = model.dIncName;
                ////6
                //string.Empty = model.dIncAddr;
                //string.Empty = model.dDepartment;
                //string.Empty = model.dOperation;
                //string.Empty = model.dPosition;
                //this.uIdiograph.Text = model.uIdiograph;
                //7
                #endregion
                #endregion
            }
            else
            {

            }
        }
        protected void okBtn_Click(object sender, EventArgs e)
        {
            YXShop.BLL.MemberInfo memeber = new YXShop.BLL.MemberInfo();
            #region 创建参数
            YXShop.Model.MemberInfo model = new YXShop.Model.MemberInfo();
            List<YXShop.Model.MemberInfo> mbList = memeber.GetListByColumn("UId", id);
            if (mbList != null && mbList.Count > 0)
            {
                model = mbList[0];
            }
            else
            {
                return;
            }

            //model.uUserName = this.Label1.Text;
            ////如果传进来的密码是空,就修改为yx123456
            //model.uUserPwd = HiddenField1.Value == string.Empty ? System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile("yx123456", "MD5") : HiddenField1.Value;
            //model.uEMail = this.uUserEmail.Text;
            //model.uQuestion = this.uFindQuestion.Text;
            //model.uAnswer = this.uFindAnswer.Text;

            #region 會员主表数据
            YXShop.Model.UserCommon ucModel = new YXShop.Model.UserCommon();
            ucModel.UserName = this.Label1.Text;
            ucModel.PassWord = HiddenField1.Value == string.Empty ? System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile("yx123456", "MD5") : HiddenField1.Value;
            ucModel.UEmail = this.uUserEmail.Text.Trim();
            ucModel.UQuestion = this.uFindQuestion.Text.Trim();
            ucModel.USolution = this.uFindAnswer.Text.Trim(); 
            #endregion


            model.uGroupId = Convert.ToInt32(this.DropDownList1.SelectedValue);
            model.post = this.tbPost.Text;
            model.fMemberState = this.uUserState.Checked ? 1 : 0;
            #region 文件上传fMemberState
            string ImgAddr = "";
            if (userImgFU.HasFile)
            {
                string fileUpPath = ConfigurationSettings.AppSettings["memberImgFile"].ToString();
                string imgPre = ConfigurationSettings.AppSettings["imgFilePre"].ToString();
                ImgAddr = YXShop.DBUtility.UploadFile.UploadPicFile(userImgFU, fileUpPath, imgPre);
                if (ImgAddr.StartsWith("error"))
                {
                    YXShop.Common.alert.Show(this, ImgAddr.Replace("error:", ""));
                    return;
                }
            }
            #endregion
            model.uPhotoAddr = ImgAddr;
            model.uPhotoH = this.imgH.Text != "" ? Convert.ToInt32(this.imgH.Text.Trim()) : 0;
            model.uPhotoW = this.imgW.Text != "" ? Convert.ToInt32(this.imgW.Text.Trim()) : 0;
            model.fRegisterTime = DateTime.Now;

            #region 扩展属性参数
            model.cAddrInfo = WebUtility.replaceStr(cAddrInfo.Text);
            model.pPapersNumber = TextBox8.Text.Trim();

            model.cFaxNumber = cFaxNumber.Text.Trim();
            model.cHomePhone = cHomePhone.Text.Trim();
            model.cICQNumber = cICQNumber.Text.Trim();
            model.cMobilePhone = cMobilePhone.Text.Trim();
            //1
            model.cMSNNumber = cMSNNumber.Text.Trim();
            model.cOfficePhone = cOfficePhone.Text.Trim();
            model.cPersonIndex = cPersonIndex.Text.Trim();
            model.cPHSNumber = cPHSNumber.Text.Trim();
            model.cPrefixal = WebUtility.replaceStr(cPrefixal.Text.Trim());
            //2
            model.cQQNumber = cQQNumber.Text.Trim();
            model.cTrueName = WebUtility.replaceStr(cTrueName.Text.Trim());
            model.cUCNumber = cUCNumber.Text;
            model.pAaH = pAaH.Text.Replace(",", ",").TrimEnd(',');
            model.pAH = WebUtility.replaceStr(pAH.Text.Trim());
            //3
            model.pBirthday = pBirthday.Date;
            model.pCaH = WebUtility.replaceStr(pCaH.Text.Replace(",", ",").TrimEnd(','));
            model.pEaL = WebUtility.replaceStr(pEaL.Text.Replace(",", ",").TrimEnd(','));
            model.pEB = pEB.SelectedItem.Text;
            model.pFamilyInfo = WebUtility.StringToHtml(WebUtility.replaceStr(string.Empty));
            //4
            model.pLaH = WebUtility.replaceStr(pLaH.Text.Replace(",", ",").TrimEnd(','));
            model.pMarriage = GetRadionListValue(pMarriage);
            model.pMonthlyIncome = Convert.ToInt32(gongzi.SelectedValue);
            model.pNation = WebUtility.replaceStr(pNation.Text);
            model.pNos = WebUtility.replaceStr(pNos.Text);
            //5
            model.pPaH = WebUtility.replaceStr(pPaH.Text.Replace(",", ",").TrimEnd(','));
            model.pPapersType = GetDropdownListValue(pPapersType);
            model.pSex = GetRadionListValue(pSex);


            model.uPrivacySettings = 0;
            model.dIncName = string.Empty;
            //6
            model.dIncAddr = string.Empty;
            model.dDepartment = string.Empty;
            model.dOperation = string.Empty;
            model.dPosition = string.Empty;
            model.uIdiograph = this.uIdiograph.Text;
            //7
            #endregion

            #region Add
            model.fCostFund = 0;
            model.fCostIntegral = 0;

            model.fCostStamps = 0;
            model.fDelNoteScalar = 0;
            model.fIntegral = 0;
            model.fLastSignIP = string.Empty;
            model.fLastSignTime = null;

            model.fLeaveDays = 0;
            model.fNote = string.Empty;
            model.fSignInTimes = 0;
            model.fSurplusCapital = 0;
            model.fUsableStamps = 0;
            #endregion

            #endregion
            try
            {
                if (memeber.Amend(model) > 0)
                {
                    bp.PageRight("会员信息修改成功.", "MemberInfo.aspx?Pro_ID=" + id + "");
                }
            }
            catch { }
        }
        /// <summary>
        /// 得到单选组的选择值
        /// </summary>
        /// <param name="rbli"></param>
        /// <returns></returns>
        private int GetRadionListValue(RadioButtonList rbli)
        {
            int reInt = 0;
            foreach (ListItem li in rbli.Items)
            {
                if (li.Selected)
                {
                    reInt = WebUtility.isNumeric(li.Value) ? Convert.ToInt32(li.Value) : 0;
                    break;
                }
            }
            return reInt;
        }

        private string GetDropdownListValue(DropDownList ddl)
        {
            string restr = string.Empty;
            foreach (ListItem li in ddl.Items)
            {
                if (li.Selected)
                {
                    restr = li.Text.Trim();
                    break;
                }
            }
            return restr;
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -