Beispiel #1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            bool   ok      = false;
            bool   is_ajax = false; bool.TryParse(context.Request["is_ajax"], out is_ajax);
            string act     = context.Request["act"];
            int    uid     = _101shop.v3.Controllers.BaseController.GetUserId();
            int    pid     = 0; int.TryParse(context.Request["pid"], out pid);

            if (!string.IsNullOrEmpty(act))
            {
                if (is_ajax)
                {
                    switch (act)
                    {
                    case "AddFavorite":    //需要登陆
                        if (uid > 0 && pid > 0)
                        {
                            SOSOshop.BLL.Memberfavorite bll = new SOSOshop.BLL.Memberfavorite();
                            ok = "0" != bll.AddMemberFavorite(uid, pid);
                            context.Response.Write(ok ? '1' : '0');
                        }
                        else
                        {
                            context.Response.Write('0');
                        }
                        break;
                    }
                    context.Response.End();
                }
                else
                {
                    switch (act)
                    {
                    case "updateEmail":    //邮箱验证1
                        if (uid > 0)
                        {
                            int      Step   = 1;
                            DateTime h24    = DateTime.Now.AddHours(-24.0);
                            string   source = "http://" + context.Request.Url.Host + "/include/ajax.ashx?act=" + act + "&v";
                            string where = "UID = " + uid + " AND CHARINDEX('" + context.Server.UrlEncode(source) + "', Source) > 0 AND OperateTime > CONVERT(DATETIME, '" + h24.ToString() + "', 120)";
                            int getpass_ticks = SysLog.SelectCount("FieldForValue = '1' AND FieldAfterValue = '0' AND " + where);
                            if (getpass_ticks > 0)
                            {
                                Step = 2;
                                context.Session["updateEmail"] = true;
                                SysLog.Query("UPDATE yxs_SysLog SET FieldForValue = '1', FieldAfterValue = '1' WHERE " + where);
                            }
                            context.Response.Redirect("/MemberCenter/Email?Step=" + Step, true);
                        }
                        else
                        {
                            context.Response.Redirect("/Account/LogOn", true);
                        }
                        break;

                    case "updateEmailComplete":    //邮箱验证2
                        if (uid > 0)
                        {
                            int      Step   = 2;
                            DateTime h24    = DateTime.Now.AddHours(-24.0);
                            string   source = "http://" + context.Request.Url.Host + "/include/ajax.ashx?act=" + act + "&v";
                            string where = "UID = " + uid + " AND CHARINDEX('" + context.Server.UrlEncode(source) + "', Source) > 0 AND OperateTime > CONVERT(DATETIME, '" + h24.ToString() + "', 120)";
                            int getpass_ticks = SysLog.SelectCount("FieldForValue = '1' AND FieldAfterValue = '0' AND " + where);
                            if (getpass_ticks > 0)
                            {
                                Step = 3;
                                SysLog.Query("UPDATE yxs_SysLog SET FieldForValue = '1', FieldAfterValue = '1' WHERE " + where);
                            }
                            context.Response.Redirect("/MemberCenter/Email?Step=" + Step, true);
                        }
                        else
                        {
                            int.TryParse(context.Request["uid"], out uid);
                            DateTime h24    = DateTime.Now.AddHours(-24.0);
                            string   source = "http://" + context.Request.Url.Host + "/include/ajax.ashx?act=" + act + "&v";
                            string where = "UID = " + uid + " AND CHARINDEX('" + context.Server.UrlEncode(source) + "', Source) > 0 AND OperateTime > CONVERT(DATETIME, '" + h24.ToString() + "', 120)";
                            int getpass_ticks = SysLog.SelectCount("FieldForValue = '1' AND FieldAfterValue = '0' AND " + where);
                            if (getpass_ticks > 0)
                            {
                                SysLog.Query("UPDATE yxs_SysLog SET FieldForValue = '1', FieldAfterValue = '1' WHERE " + where);
                                SOSOshop.BLL.MemberAccount bll = new SOSOshop.BLL.MemberAccount();
                                ok = 0 < bll.ExecuteNonQuery(string.Format("IF (NOT EXISTS(SELECT TOP(1) * FROM membercheck WHERE CheckType='E' AND UID={0})) INSERT INTO membercheck (UID, Checked, CheckType) VALUES ({0},1,'E') ELSE UPDATE membercheck SET Checked=1 WHERE CheckType='E' AND UID={0}", uid));
                            }
                            if (ok)
                            {
                                context.Response.Redirect("/MemberCenter/EmailChecked?uid=" + uid, true);
                            }
                            else
                            {
                                context.Response.Redirect("/", true);
                            }
                        }
                        break;

                    case "ClearCache":    //清除所有缓存
                        if (context.Request["All"] != null)
                        {
                            new DbBase().ClearCache();
                        }
                        context.Response.Redirect("/", true);
                        break;
                    }
                }
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     tablist.Sorting += new GridViewSortEventHandler(tablist_Sorting);
     if (!IsPostBack)
     {
         #region ajax
         if (ChangeHope.WebPage.PageRequest.GetFormString("Option") != string.Empty && ChangeHope.WebPage.PageRequest.GetFormString("id") != "")
         {
             string types = Request["Option"].Trim();
             string id    = ChangeHope.WebPage.PageRequest.GetFormString("id");
             string ids   = ChangeHope.WebPage.PageRequest.GetFormString("ids").Trim(',');
             int    uid   = 0; int.TryParse(id, out uid);
             //获取上级单位
             if (types == "GetParentIncName")
             {
                 if (!string.IsNullOrEmpty(ids))
                 {
                     StringBuilder s        = new StringBuilder();
                     DataSet       IncNames = bll.ExecuteDataSet("select ID, Name, isnull(BuyFilingStatus,2) from DrugsBase_Enterprise where ID in (" + ids + ")");
                     if (IncNames != null && IncNames.Tables.Count > 0 && IncNames.Tables[0].Rows.Count > 0)
                     {
                         foreach (DataRow dr in IncNames.Tables[0].Rows)
                         {
                             s.Append("{ID:" + dr[0] + ",Name:'" + dr[1].ToString().Replace("'", "\\'") + "',BuyFilingStatus:" + dr[2] + "},");
                         }
                     }
                     Response.Write("[" + s.ToString().TrimEnd(',') + "]");
                 }
                 else if (uid > 0)
                 {
                     string s       = "";
                     object IncName = bll.ExecuteScalar("select Name from DrugsBase_Enterprise where ID='" + uid + "'");
                     if (IncName != null)
                     {
                         s = IncName.ToString();
                     }
                     Response.Write(s);
                 }
             }
             //删除
             else if (types == "del")
             {
                 if (isDelete())
                 {
                     bool noBecause = ChangeHope.WebPage.PageRequest.GetFormString("noBecause") == "";
                     if (noBecause && bll.ExecuteScalar("select 1 from orders where ReceiverId in (" + id + ")") != null)
                     {
                         Response.Write("noBecauseOrders");
                     }
                     else
                     {
                         bool ok = false;
                         if (uid > 0)
                         {
                             ok = new SOSOshop.BLL.MemberAccount().Delete(uid);
                         }
                         else
                         {
                             ok = new SOSOshop.BLL.MemberAccount().DeleteAll(id);
                         }
                         Response.Write(ok ? "ok" : "");
                         if (ok)
                         {
                             #region 后台用户操作日志记录
                             SOSOshop.Model.AdminInfo adminInfo = SOSOshop.BLL.AdministrorManager.Get();
                             SOSOshop.BLL.Logs.Log.LogAdminAdd("删除买家信息", (adminInfo == null ? 0 : adminInfo.AdminId), (adminInfo == null ? "" : adminInfo.AdminName), 1);
                             #endregion
                         }
                     }
                 }
                 else
                 {
                     Response.Write("no");
                 }
             }
             //审核
             else if (types == "State")
             {
                 if (isEdit())
                 {
                     bool ok = 0 < bll.ExecuteNonQuery("UPDATE memberaccount SET State = 0 where State <> 0 and UID in (" + id + ")");
                     Response.Write(ok ? "ok" : "");
                 }
                 else
                 {
                     Response.Write("no");
                 }
             }
             //获取积分
             else if (types == "getIntegral")
             {
                 int integral = 0;
                 if (SOSOshop.BLL.PowerPass.isPass("008009001"))
                 {
                     try
                     {
                         SOSOshop.BLL.Integral.MemberIntegral bll2 = new SOSOshop.BLL.Integral.MemberIntegral();
                         integral = bll2.GetRealityIntegral(uid);
                     }
                     catch { }
                     Response.Write(integral);
                 }
                 else
                 {
                     Response.Write("no");
                 }
             }
             //赠送积分
             else if (types == "editIntegral")
             {
                 int integral = 0; int.TryParse(Request["integral"], out integral);
                 if (SOSOshop.BLL.PowerPass.isPass("008009015"))
                 {
                     bool ok = false;
                     try
                     {
                         SOSOshop.BLL.Integral.MemberIntegral bll2      = new SOSOshop.BLL.Integral.MemberIntegral();
                         SOSOshop.Model.AdminInfo             adminInfo = SOSOshop.BLL.AdministrorManager.Get();
                         string remarks = string.Format("管理员{0}赠送积分", (adminInfo == null ? "" : adminInfo.AdminName));
                         bll2.PresentIntegral(uid, integral, remarks);
                         ok = true;
                         #region 后台用户操作日志记录
                         SOSOshop.BLL.Logs.Log.LogAdminAdd(remarks + "给" + Request["TrueName"] + ":" + integral, (adminInfo == null ? 0 : adminInfo.AdminId), (adminInfo == null ? "" : adminInfo.AdminName), 1);
                         #endregion
                     }
                     catch { }
                     Response.Write(ok ? "ok" : "");
                 }
                 else
                 {
                     Response.Write("no");
                 }
             }
             Response.End();
             return;
         }
         #endregion
         if (!SOSOshop.BLL.PowerPass.isPass("008009001") && !SOSOshop.BLL.PowerPass.isPass("008009012"))
         {
             SOSOshop.BLL.PromptInfo.Popedom("000000000000", "对不起,您没有查看的权限!");
         }
         //显示列表
         Search_Click(null, null);
     }
     //权限赋值
     isCheckUp         = SOSOshop.BLL.PowerPass.isPass("008009013");
     IsEdit            = SOSOshop.BLL.PowerPass.isPass("008009004");
     IsDelete          = SOSOshop.BLL.PowerPass.isPass("008009003");
     IsPresentIntegral = SOSOshop.BLL.PowerPass.isPass("008009015");
 }
 /// <summary>
 /// 修改账户详情
 /// </summary>
 private bool UpdateAccount()
 {
     SOSOshop.BLL.MemberAccount accountBll = new SOSOshop.BLL.MemberAccount();
     if (ViewState["memberId"] != null)
     {
         SOSOshop.Model.MemberAccount model = accountBll.GetModel(Convert.ToInt32(ViewState["memberId"]));
         string password = model.PassWord;
         string resetPwd = "123456";
         model.PassWord = "";
         if (this.cb_resetPwd.Visible && this.cb_resetPwd.Checked)
         {
             model.PassWord = password = resetPwd;
             model.PassWord = ChangeHope.Common.DEncryptHelper.Encrypt(model.PassWord, 1);
         }
         model.CompanyClass = DropDownList1.SelectedValue;
         model.RegisterDate = Convert.ToDateTime(ViewState["RegisterDate"].ToString());
         model.RegisterIP   = ViewState["RegisterIP"].ToString();
         model.MobilePhone  = this.txtMobilePhone.Text.Trim();
         model.Capital      = Convert.ToDecimal(ViewState["Capital"].ToString());
         model.Coupons      = Convert.ToInt32(ViewState["Coupons"].ToString());
         model.Points       = Convert.ToInt32(ViewState["Points"].ToString());
         model.Email        = this.txtEmail.Text.Trim().ToString();
         model.Email_QQ     = this.txtEmail_QQ.Text.Trim().ToString();
         //if (this.ddlUserType.Enabled) model.UserType = Convert.ToInt32(this.ddlUserType.SelectedValue);
         int rgPeriodOfValidity = ChangeHope.WebPage.PageRequest.GetFormInt("rgPeriodOfValidity");
         if (rgPeriodOfValidity == -1)
         {
             model.PeriodOfValidity = ViewState["PeriodOfValidity"] == null ? Date_rgPeriodOfValidity : Convert.ToDateTime(ViewState["PeriodOfValidity"].ToString());
         }
         else
         {
             model.PeriodOfValidity = rgPeriodOfValidity == 1 ? Date_rgPeriodOfValidity : Convert.ToDateTime(txtPeriodOfValidity.Text);
         }
         string type = this.radType.SelectedValue;
         if (type == "1")
         {
             if (model.Question == null || model.Question.Trim() == "")
             {
                 string Question = this.ddlQuestion.Value;
                 string Answer   = this.txtAnswer.Text.Trim().ToString();
                 if (Question == "")
                 {
                     this.ltlMsg.Text     = "操作失败:找回密码问题选择错误,请选择一个问题!";
                     this.pnlMsg.Visible  = true;
                     this.pnlMsg.CssClass = "actionErr";
                     return(false);
                 }
                 if (Answer == "")
                 {
                     this.ltlMsg.Text     = "操作失败:找回密码答案填写错误,不能为空!";
                     this.pnlMsg.Visible  = true;
                     this.pnlMsg.CssClass = "actionErr";
                     return(false);
                 }
                 model.Question       = Question;
                 model.Answer         = Answer;
                 this.palOld.CssClass = "msgNormal";
             }
             else
             {
                 string oldQuestion = this.ddlQuestion.Value;
                 string oldAnswer   = this.txtOldAnswer.Text.Trim().ToString();
                 string newAnswer   = this.txtNewAnswer.Text.Trim().ToString();
                 if (oldQuestion == "" || oldQuestion != model.Question)
                 {
                     this.ltlMsg.Text     = "操作失败:原找回密码问题选择错误!";
                     this.pnlMsg.Visible  = true;
                     this.pnlMsg.CssClass = "actionErr";
                     return(false);
                 }
                 if (oldAnswer == "" || oldAnswer != model.Answer)
                 {
                     this.ltlMsg.Text     = "操作失败:原找回密码答案填写错误!";
                     this.pnlMsg.Visible  = true;
                     this.pnlMsg.CssClass = "actionErr";
                     return(false);
                 }
                 if (newAnswer == "")
                 {
                     this.ltlMsg.Text     = "操作失败:新找回密码答案不能为空!";
                     this.pnlMsg.Visible  = true;
                     this.pnlMsg.CssClass = "actionErr";
                     return(false);
                 }
                 model.Answer         = newAnswer;
                 this.palOld.CssClass = "msgNormal";
             }
         }
         model.State      = int.Parse(DropDownList2.SelectedValue); //默认 通过审核 注意和冻结 2 不一样;冻结不能登陆。
         enabledErpAction = model.State != 2;                       //只同步审核的买家
         accountBll.Update(model);
         //发送短信通知已经通过审核
         if (model.State == 0)
         {
             if (CheckBox1.ToolTip != "0" && CheckBox1.Checked)
             {
                 string msg = "恭喜你已经通过审核,请凭手机号登录" + (password == resetPwd ? ",登录密码为" + password : "");
                 SOSOshop.BLL.Sms.SendAndSaveDataBase(txtMobilePhone.Text.Trim(), msg, "系统", txtMobilePhone.Text.Trim());
             }
         }
         return(true);
     }
     return(false);
 }
        /// <summary>
        /// 添加账户
        /// </summary>
        /// <returns></returns>
        private void AddAccount()
        {
            enabledErpAction = true;
            SOSOshop.BLL.MemberAccount   accountBll = new SOSOshop.BLL.MemberAccount();
            SOSOshop.Model.MemberAccount model      = new SOSOshop.Model.MemberAccount();
            model.UserId = this.txtUserId.Text;
            string password = model.PassWord;
            string resetPwd = "123456";

            model.PassWord = "";
            if (this.cb_resetPwd.Visible && this.cb_resetPwd.Checked)
            {
                model.PassWord = password = resetPwd;
                model.PassWord = ChangeHope.Common.DEncryptHelper.Encrypt(model.PassWord, 1);
            }
            else if (this.txtPassword.Text.Trim() != "")
            {
                model.PassWord = password = this.txtPassword.Text.Trim();
                model.PassWord = ChangeHope.Common.DEncryptHelper.Encrypt(model.PassWord, 1);
            }
            if (model.PassWord == "")
            {
                model.PassWord = password = resetPwd;
                model.PassWord = ChangeHope.Common.DEncryptHelper.Encrypt(model.PassWord, 1);
            }
            if (Request.Form["rgPeriodOfValidity"] == "1")
            {
                model.PeriodOfValidity = DateTime.Now.AddYears(100);
            }
            else
            {
                model.PeriodOfValidity = DateTime.Parse(txtPeriodOfValidity.Text);
            }

            model.RegisterDate = DateTime.Now;
            model.RegisterIP   = ChangeHope.WebPage.PageRequest.GetIP();
            model.MobilePhone  = this.txtMobilePhone.Text.Trim();
            model.Email        = this.txtEmail.Text.Trim().ToString();
            model.Email_QQ     = this.txtEmail_QQ.Text.Trim().ToString();
            model.Question     = "";
            model.Answer       = "";
            string type = this.radType.SelectedValue;

            if (type == "1")
            {
                if (model.Question == null || model.Question.Trim() == "")
                {
                    string Question = this.ddlQuestion.Value;
                    string Answer   = this.txtAnswer.Text.Trim().ToString();
                    if (Question == "")
                    {
                        this.ltlMsg.Text     = "操作失败:找回密码问题选择错误,请选择一个问题!";
                        this.pnlMsg.Visible  = true;
                        this.pnlMsg.CssClass = "actionErr";
                        return;
                    }
                    if (Answer == "")
                    {
                        this.ltlMsg.Text     = "操作失败:找回密码答案填写错误,不能为空!";
                        this.pnlMsg.Visible  = true;
                        this.pnlMsg.CssClass = "actionErr";
                        return;
                    }
                    model.Question       = Question;
                    model.Answer         = Answer;
                    this.palOld.CssClass = "msgNormal";
                }
                else
                {
                    string oldQuestion = this.ddlQuestion.Value;
                    string oldAnswer   = this.txtOldAnswer.Text.Trim().ToString();
                    string newAnswer   = this.txtNewAnswer.Text.Trim().ToString();
                    if (oldQuestion == "" || oldQuestion != model.Question)
                    {
                        this.ltlMsg.Text     = "操作失败:原找回密码问题选择错误!";
                        this.pnlMsg.Visible  = true;
                        this.pnlMsg.CssClass = "actionErr";
                        return;
                    }
                    if (oldAnswer == "" || oldAnswer != model.Answer)
                    {
                        this.ltlMsg.Text     = "操作失败:原找回密码答案填写错误!";
                        this.pnlMsg.Visible  = true;
                        this.pnlMsg.CssClass = "actionErr";
                        return;
                    }
                    if (newAnswer == "")
                    {
                        this.ltlMsg.Text     = "操作失败:新找回密码答案不能为空!";
                        this.pnlMsg.Visible  = true;
                        this.pnlMsg.CssClass = "actionErr";
                        return;
                    }
                    model.Answer         = newAnswer;
                    this.palOld.CssClass = "msgNormal";
                }
            }
            model.State = int.Parse(DropDownList2.SelectedValue);//默认 通过审核 注意和冻结 2 不一样;冻结不能登陆。
            int uid = accountBll.Add(model);

            model.UID = uid;
            if (uid > 0)
            {
                #region 添加积分记录(取消此功能)
                //YXShop.Model.Member.Integral modelInte = new YXShop.Model.Member.Integral();
                //YXShop.BLL.Member.Integral bllInte = new YXShop.BLL.Member.Integral();
                //modelInte.Userid = GetIdByUserId(model.UserId);
                //modelInte.IntegralClass = 3;
                //modelInte.Origin = "注册赠送";
                //modelInte.IntegralNum = model.Points;
                //modelInte.GainDate = DateTime.Now;
                //modelInte.NoteDate = DateTime.Now;
                //modelInte.NoteName = "系统自动记录";
                //modelInte.Remark = "注册买家时赠送的积分";
                //modelInte.IntegralStatus = 0;
                //try
                //{
                //    bllInte.Add(modelInte);
                //}
                //catch
                //{
                //    this.ltlMsg.Text = "添加买家资料失败!";
                //    this.pnlMsg.Visible = true;
                //    this.pnlMsg.CssClass = "actionErr";
                //    return;
                //}
                #endregion

                #region 添加点卷记录(取消此功能)
                //YXShop.Model.Member.UserInfoNote modelNote = new YXShop.Model.Member.UserInfoNote();
                //YXShop.BLL.Member.UserInfoNote bllNote = new YXShop.BLL.Member.UserInfoNote();
                //modelNote.UserID = GetIdByUserId(model.UserId);
                //modelNote.TicketCount = 0;
                //modelNote.Causation = "注册赠送的点卷";
                //modelNote.BosomNote = "注册赠送的点卷";
                //modelNote.NoteDate = DateTime.Parse(DateTime.Now.ToShortDateString());
                //modelNote.NoteName = "系统自动记录";
                //modelNote.NoteType = 0;
                //modelNote.BuckleOrAdd = 0;
                //modelNote.Username = model.UserId;
                //try
                //{
                //    bllNote.Add(modelNote);
                //}
                //catch
                //{
                //    this.ltlMsg.Text = "添加买家资料失败!";
                //    this.pnlMsg.Visible = true;
                //    this.pnlMsg.CssClass = "actionErr";
                //    return;
                //}
                #endregion

                #region 添加附属信息
                SOSOshop.BLL.MemberInfo   bllInfo   = new SOSOshop.BLL.MemberInfo();
                SOSOshop.Model.MemberInfo modelInfo = new SOSOshop.Model.MemberInfo();
                modelInfo.UID         = uid;
                modelInfo.Member_Type = 1;
                modelInfo.TrueName    = txtTrueName.Text.Trim();
                modelInfo.Photo       = "";//txtPhoto.Text;
                int area = 0; int.TryParse(Request["province"], out area);
                modelInfo.Province = area;
                area                    = 0; int.TryParse(Request["city"], out area);
                modelInfo.City          = area;
                area                    = 0; int.TryParse(Request["county"], out area);
                modelInfo.Borough       = area;
                modelInfo.Address       = txtAddress.Text;
                modelInfo.OfficePhone   = txtOfficePhone.Text;
                modelInfo.HomePhone     = ""; // txtHomePhone.Text;
                modelInfo.Fax           = txtFax.Text;
                modelInfo.PersonWebSite = ""; // txtPersonWebSite.Text;
                modelInfo.QQ            = ""; // txtQQ.Text;
                modelInfo.PriceCategory = DropDownList3.SelectedValue;
                modelInfo.ParentId      = 0;
                modelInfo.Parents       = "";

                bool ok = bllInfo.Add(modelInfo, enabledErpAction && int.Parse(DropDownList2.SelectedValue) == 0 /* && modelInfo.ParentId > 0*/);
                //添加权限
                if (ok)
                {
                    SOSOshop.BLL.MemberPermission   cBll = new SOSOshop.BLL.MemberPermission();
                    SOSOshop.Model.MemberPermission c    = new SOSOshop.Model.MemberPermission();
                    c.UID = uid;
                    c.IsMoneyAndShipping = true;//款到发货权限
                    //if (int.Parse(DropDownList2.SelectedValue) == 0 && modelInfo.ParentId > 0 && 1 == BuyerLib.GetGSP(modelInfo.ParentId))
                    //{
                    //    modelInfo = bllInfo.GetModel(modelInfo.UID);
                    //    int Member_Class = modelInfo.Member_Class;
                    //    //SOSOshop.BLL.Service.MemberInfo.GetErp_KeHuLB(modelInfo.Code, ref Member_Class, ref Crm_Class);
                    //    if (Member_Class == 0)
                    //    {
                    //        c.IsTrade = true;
                    //        c.IsLookPrice_01 = true;
                    //        c.IsLookProduct_01 = true;
                    //        c.IsLookPrice_02 = false;
                    //        c.IsLookProduct_02 = false;
                    //    }
                    //    else if (Member_Class == 1)
                    //    {
                    //        c.IsTrade = true;
                    //        c.IsLookPrice_01 = false;
                    //        c.IsLookProduct_01 = false;
                    //        c.IsLookPrice_02 = true;
                    //        c.IsLookProduct_02 = true;
                    //    }
                    //}
                    ok = cBll.Add(c);
                }
                //已经通过审核,同步CRM,ERP
                if (ok && int.Parse(DropDownList2.SelectedValue) == 0 && modelInfo.ParentId > 0)
                {
                    //同步CRM
                    CrmActionHandle(modelInfo);
                }
                if (ok)
                {
                    this.ltlMsg.Text     = "保存成功·<script>if(confirm('添加成功!继续添加请点击确定。')){location.href='Buyer_edit.aspx?act=new';}else{location.href='BuyerLib.aspx';}</script>";
                    this.pnlMsg.Visible  = true;
                    this.pnlMsg.CssClass = "actionOk";
                }
                else
                {
                    this.ltlMsg.Text     = "添加买家资料失败!";
                    this.pnlMsg.Visible  = true;
                    this.pnlMsg.CssClass = "actionErr";
                    return;
                }
                #endregion

                //发送短信通知已经通过审核
                if (model.State == 0)
                {
                    if (CheckBox1.ToolTip != "0" && CheckBox1.Checked)
                    {
                        string msg = "恭喜你已经通过管理员审核,请凭手机号登录,登录密码为" + password + "。";
                        SOSOshop.BLL.Sms.SendAndSaveDataBase(txtMobilePhone.Text.Trim(), msg, "系统", txtMobilePhone.Text.Trim());
                    }
                }
            }
            else
            {
                this.ltlMsg.Text     = "添加买家资料失败!";
                this.pnlMsg.Visible  = true;
                this.pnlMsg.CssClass = "actionErr";
                return;
            }
        }
        private void GetAccountAndInfo(int id)
        {
            var adminInfo = AdministrorManager.Get();

            SOSOshop.BLL.MemberAccount   bll       = new SOSOshop.BLL.MemberAccount();
            SOSOshop.Model.MemberAccount model     = bll.GetModelNoCache(id);
            SOSOshop.BLL.MemberInfo      bllInfo   = new SOSOshop.BLL.MemberInfo();
            SOSOshop.Model.MemberInfo    infomodel = bllInfo.GetModel(id);
            DropDownList3.SelectedValue = infomodel.PriceCategory;

            txtdiscount.Text = infomodel.discount.ToString();
            if (model != null && infomodel != null)
            {
                DropDownList1.SelectedValue = model.CompanyClass;
                #region 会员审核状态
                DropDownList2.SelectedValue = model.State.ToString();
                DropDownList2.Enabled       = SOSOshop.BLL.PowerPass.isPass("008009013");//权限


                CheckBox1.ToolTip = DropDownList2.SelectedValue;
                if (model.State == 1 && infomodel.Editer == adminInfo.AdminId)
                {
                    CheckBox1.Visible = CheckBox1.Enabled = CheckBox1.Checked = true;
                }
                #endregion
                DropDownList1.SelectedValue = model.CompanyClass;
                //修改权限
                bool isEdit = SOSOshop.BLL.PowerPass.isPass("008009004");
                if (model.Question == null || model.Question.Trim() == "")
                {
                    findPassword.Visible  = true;
                    findPassword1.Visible = findPassword2.Visible = findPassword3.Visible = false;
                }
                else
                {
                    findPassword.Visible  = false;
                    findPassword1.Visible = findPassword2.Visible = findPassword3.Visible = true;
                }
                lblUserId.Text = model.UserId;
                SOSOshop.BLL.MemberRank   mrbll   = new SOSOshop.BLL.MemberRank();
                SOSOshop.Model.MemberRank mrmodel = mrbll.GetModel(Convert.ToInt32(model.UserGroup));
                lblUserLevel.Text   = mrmodel != null ? mrmodel.Name : "未知"; //买家等级
                txtMobilePhone.Text = model.MobilePhone;
                txtEmail.Text       = model.Email;                           //电子邮件
                txtEmail_QQ.Text    = model.Email_QQ;                        //QQ邮箱
                //登陆有效期
                if (model.PeriodOfValidity.ToString("yyyy-MM-dd") == Date_rgPeriodOfValidity.ToString("yyyy-MM-dd"))
                {
                    txtPeriodOfValidity.Text = "";
                }
                else
                {
                    txtPeriodOfValidity.Text = CheckTimeOut(model.PeriodOfValidity.ToString(), PeriodOfValiditymsg);
                }
                CheckTimeAccessKey(txtPeriodOfValidity);

                ViewState["RegisterDate"]     = model.RegisterDate.ToString();
                ViewState["RegisterIP"]       = model.RegisterIP.ToString();
                ViewState["Capital"]          = model.Capital.ToString();
                ViewState["Coupons"]          = model.Coupons.ToString();
                ViewState["Points"]           = model.Points.ToString();
                ViewState["PeriodOfValidity"] = model.PeriodOfValidity.ToString();

                string p = "<span id=\"spanParents\" style=\"\"><span><br>&nbsp;<a href=\"javascript:void(0)\" title=\"点击添加其他单位\" onclick=\"addInc(this)\">添加</a>"
                           + "<span>&nbsp;<input name=\"ParentIncName\" type=\"text\" value=\"\" position=\"{x:235,y:110}\" onclick=\"selectParentWindow(this)\" style=\"height:18px;width:300px;cursor:pointer;color:black;\">"
                           + "<input type=\"hidden\" name=\"ParentId\" value=\"0\">"
                           + "</span></span></span>";
                this.txtUId.Value        = id.ToString();
                this.txtTrueName.Text    = infomodel.TrueName;
                this.txtAddress.Text     = infomodel.Address;
                this.txtOfficePhone.Text = infomodel.OfficePhone;
                this.txtFax.Text         = infomodel.Fax;

                #region 实例化省市区联动
                DataSet dsProvinces = bll.ExecuteDataSet("select isnull((select TOP(1) Name from Region where ID=" + infomodel.Province + "),'') as a,isnull((select TOP(1) Name from Region where ID=" + infomodel.City + "),'') as b,isnull((select TOP(1) Name from Region where ID=" + infomodel.Borough + "),'') as c");
                if (dsProvinces != null && dsProvinces.Tables.Count > 0 && dsProvinces.Tables[0].Rows.Count > 0)
                {
                    ConsigneeProvince = dsProvinces.Tables[0].Rows[0][0].ToString();
                    ConsigneeCity     = dsProvinces.Tables[0].Rows[0][1].ToString();
                    ConsigneeBorough  = dsProvinces.Tables[0].Rows[0][2].ToString();
                }
                #endregion

                #region 添加其他单位

                if (infomodel.ParentId >= 0)
                {
                    DataSet ds1 = bll.ExecuteDataSet("SELECT ID UID,Name IncName FROM DrugsBase_Enterprise WHERE id IN (" + (string.IsNullOrEmpty(infomodel.Parents) ? infomodel.ParentId.ToString() : infomodel.Parents.TrimEnd(',')) + ")");
                    if (ds1.Tables.Count > 0 && ds1.Tables[0].Rows.Count > 0)
                    {
                        p = "<span id=\"spanParents\">";
                        for (int i = 0; i < ds1.Tables[0].Rows.Count; i++)
                        {
                            DataRow dr1   = ds1.Tables[0].Rows[i];
                            bool    isdef = (infomodel.ParentId == Convert.ToInt32(dr1[0]));
                            if (i == 0)
                            {
                                if (infomodel.ParentId <= 0)
                                {
                                    isdef = true;
                                }
                                Literal1.Text = dr1[1].ToString();
                            }
                            else
                            {
                                Literal1.Text = dr1[0].ToString();
                            }
                        }
                        p += "</span>";
                        bool editParent = false;// int ddl2 = 1; int.TryParse(DropDownList2.SelectedValue, out ddl2); editParent = (ddl2 == 1);
                    }
                }
                #endregion

                SelectEditer();      // 查询交易员
                SelectDropDownList(ddl_Editer, infomodel.Editer.ToString());
                BindOutSellPerson(); // 查询外销人员
                SelectDropDownList(ddlOSP, infomodel.OSPId.ToString());
                if (infomodel.Editer <= 0)
                {
                    ddl_Editer.Visible = ddl_Editer.Enabled = true; tipEditer.Visible = true;
                    lblEditer.Text     = "";
                }
                else if (ddl_Editer.SelectedIndex > 0)
                {
                    //未审核时
                    if (int.Parse(DropDownList2.SelectedValue) == 1)
                    {
                        ddl_Editer.Visible = ddl_Editer.Enabled = true; tipEditer.Visible = true;
                        if (ddl_Editer.SelectedIndex > 0)
                        {
                            lblEditer.Text = ddl_Editer.SelectedItem.Text;
                        }
                    }
                    else
                    {
                        ddl_Editer.Visible = ddl_Editer.Enabled = true; tipEditer.Visible = true;
                        if (ddl_Editer.SelectedIndex > 0)
                        {
                            lblEditer.Text = ddl_Editer.SelectedItem.Text;
                        }
                    }
                }
                else
                {
                    ddl_Editer.Visible = ddl_Editer.Enabled = true; tipEditer.Visible = true;
                    lblEditer.Text     = "等待分配客服...";
                }
                if (int.Parse(DropDownList2.SelectedValue) != 1 && ddlOSP.SelectedIndex > 0)
                {
                    ddlOSP.Visible = ddlOSP.Enabled = true; tipOSP.Visible = true;
                    if (ddlOSP.SelectedIndex > 0)
                    {
                        lbOSP.Text = ddlOSP.SelectedItem.Text;
                    }
                }
            }
        }