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

📄 userreg.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 Shop.Web.UI;

namespace YXShop.Web.Admin.Consumer
{
    public partial class UserReg : System.Web.UI.Page
    {
        BasePage bp = new BasePage();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack) 
            {
                if (!string.IsNullOrEmpty(Request.QueryString["UserType"])) 
                {
                    if (YXShop.Common.WebUtility.isNumeric(Request.QueryString["UserType"])) 
                    {
                        int UserType = Convert.ToInt32(Request.QueryString["UserType"]);
                        for (int i = 0; i < RadioButtonList1.Items.Count; i++) 
                        {
                            if (i == UserType) 
                            {
                                RadioButtonList1.Items[i].Selected = true;
                                //if (i != 0)
                                //{
                                //    Button2.Enabled = true;
                                //}
                                //else 
                                //{
                                //    Button2.Enabled = false;
                                //}
                            }
                        }
                    }
                }
                BindComType(DropDownList1);
            }
        }
        #region 单位类型
        private void BindComType(DropDownList ddl)
        {
            ddl.Items.Clear();
            YXShop.BLL.Pro_Categories proCate = new YXShop.BLL.Pro_Categories();
            List<YXShop.Model.Pro_Categories> list = proCate.GetListByColumn("ProC_FatherID", 0);
            ListItem lItem = null;
            foreach (YXShop.Model.Pro_Categories proCateModel in list)
            {
                lItem = new ListItem();
                lItem.Value = proCateModel.ProC_ID.ToString();
                lItem.Text = proCateModel.ProC_CategroiesName;

                ddl.Items.Add(lItem);
            }
        }
        #endregion
        protected void Button1_Click(object sender, EventArgs e)
        {
            YXShop.BLL.UserCommon ucBll = new YXShop.BLL.UserCommon();
            string userName = UserRegInfo();
            if (userName==string.Empty)
            {
                bp.PageError("添加单位会员失败.", "UserList.aspx?UserType=1");
            }
            else
            {
                List<YXShop.Model.UserCommon> ucList = ucBll.GetListByColumn("UserName", userName);
                if (ucList.Count > 0)
                {
                    if (CompanyInfo(ucList[0].UID.ToString()) > 0)
                    {
                        bp.PageRight("创建单位会员成功!<li><a href='UserReg.aspx'>继续添加</a></li>", "UserList.aspx?UserType=1");
                    }
                    else
                    {
                        ucBll.Delect(ucList[0].UID);
                        bp.PageError("添加单位会员失败!", "UserList.aspx?UserType=1");
                    }
                }
            }
        }

        private string UserRegInfo() 
        {
            YXShop.BLL.UserCommon ucBll = new YXShop.BLL.UserCommon();
            string userName = YXShop.Common.WebUtility.replaceStr(TextBox1.Text.Trim());
            List<YXShop.Model.UserCommon> ucList = ucBll.GetListByColumn("UserName", userName);
            if (ucList != null && ucList.Count == 1)
            {
                bp.PageError("用户名已经存在", "UserList.aspx?UserType=1");
                Response.End();
            }
            else 
            {
                YXShop.Model.UserCommon ucModel = new YXShop.Model.UserCommon();
                ucModel.UserName = userName;
                ucModel.UserType = Convert.ToInt32(RadioButtonList1.SelectedValue);
                ucModel.PassWord = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(TextBox3.Text.Trim(), "MD5");
                ucModel.UQuestion = TextBox4.Text.Trim();
                ucModel.USolution = TextBox5.Text.Trim();
                ucModel.UEmail = TextBox6.Text;
                ucModel.UCeateDate = DateTime.Now;
                ucModel.UState = RadioButtonList1.SelectedIndex > 0 ? 1 : 0;//当为普通会员时,不必审核,其它类型的会员,要求后台审核
                ucModel.UUpdate = DateTime.Now;
                if (ucBll.Create(ucModel) > 0)
                {
                    return userName;
                }
            }
            return string.Empty;
        }

        #region  单位信息
        protected int CompanyInfo(string UID)
        {
            YXShop.BLL.ComMembers comBll = new YXShop.BLL.ComMembers();
            string userName = YXShop.Common.WebUtility.replaceStr(TextBox1.Text.Trim());
            string upInfo1 = "", upInfo2 = "";

            List<YXShop.Model.ComMembers> list = comBll.GetListByColumn("ComName", userName);
            if (list == null)
            {
                bp.PageError("程序运行时错误!", "UserReg.aspx");
                Response.End();
            }
            if (list != null && list.Count > 0)
            {
                bp.PageError("该会员已经存在!", "UserReg.aspx");
                Response.End();
            }
            else
            {
                #region 上传图片
                string fileUpPath = ConfigurationSettings.AppSettings["memberImgFile"].ToString();//保存文件的路徑,保存在会员图片文件目录下
                string imgPre = ConfigurationSettings.AppSettings["imgFilePre"].ToString();

                if (FileUpload1.HasFile && FileUpload2.HasFile)
                {
                    upInfo1 = YXShop.DBUtility.UploadFile.UploadPicFile(FileUpload1, fileUpPath, imgPre);//上传工商执照
                    if (upInfo1.StartsWith("error"))
                    {
                        bp.PageError("上传工商执照失败!<li>原因可能是:"+upInfo1.Replace("error:", "")+"</li>", "UserReg.aspx");
                        Response.End();
                    }
                    else
                    {
                        upInfo2 = YXShop.DBUtility.UploadFile.UploadPicFile(FileUpload2, fileUpPath, imgPre);//上传许可证号
                        if (upInfo2.StartsWith("error"))
                        {
                            Label4.Text = upInfo2.Replace("error:", "");
                            bp.PageError("上传许可证号失败!<li>原因可能是:" + upInfo1.Replace("error:", "") + "</li>", "UserReg.aspx");
                            Response.End();
                        }
                    }
                }
                #endregion
            }
            YXShop.Model.ComMembers comModel = new YXShop.Model.ComMembers();
            comModel.UID =Convert.ToInt32(UID);
            comModel.ComName = userName;
            comModel.CharterPic = upInfo1;
            comModel.ComType = Convert.ToInt32(DropDownList1.SelectedValue);
            comModel.AdmissionNumber = YXShop.Common.WebUtility.replaceStr(tbAdmission.Text.Trim());
            comModel.CorporationPic = upInfo2;
            comModel.CertificateOrgan = YXShop.Common.WebUtility.replaceStr(tbCartOrg.Text.Trim());
            comModel.IDCard = tbNument.Text;
            comModel.TaxNo = YXShop.Common.WebUtility.replaceStr(TextBox8.Text.Trim());
            comModel.ComAddress = TextBox9.Text.Trim();
            comModel.ComPost = TextBox10.Text.Trim();
            comModel.ComPrincipal = tbFName.Text.Trim();
            comModel.ComTel = TextBox12.Text;
            comModel.ComFax = TextBox13.Text;
            comModel.ComEmail = TextBox14.Text;
            comModel.ComWebsite = TextBox15.Text;
            comModel.ComIntegral = 0;
            comModel.MoneyBalance = 0;
            comModel.ConsumeMoney = 0;
            comModel.Province = "0";
            return comBll.Create(comModel);
        }

        #endregion
    }
}

⌨️ 快捷键说明

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