Ejemplo n.º 1
0
    protected void btnModify_Click(object sender, EventArgs e)
    {
        Hi.Model.SYS_AdminUser User = new Hi.BLL.SYS_AdminUser().GetModel(UserID);
        string OldLoginPwd          = this.txtOldPassWord.Value.Trim().ToString();
        string NewLoginPwd          = this.txtNewPassWord.Value.Trim().ToString();
        string ConfrimNewPassWord   = this.txtConfrimNewPassWord.Value.Trim();

        //修改的密码,两次填写不一致
        if (ConfrimNewPassWord == NewLoginPwd)
        {
            if (User.LoginPwd.ToString() == OldLoginPwd)
            {
                if (new Hi.BLL.SYS_AdminUser().UpdatePassWord(NewLoginPwd, UserID.ToString()))
                {
                    JScript.AlertMsgMo(this, "修改成功", "function(){ window.location.href='changePwd.aspx'; }");
                }
            }
            else
            {
                JScript.AlertMsg(this, "原始密码错误,请重新输入!");
                return;
            }
        }
        else
        {
            JScript.AlertMsg(this, "密码填写不一致!");
            return;
        }
    }
Ejemplo n.º 2
0
 protected void btn_zx(object sender, EventArgs e)
 {
     Hi.Model.BD_Company comp = new Hi.BLL.BD_Company().GetModel(KeyID);
     if (comp != null)
     {
         comp.Isorgzx     = 1;
         comp.Orgzxdate   = DateTime.Now;
         comp.IsZXAudit   = 1;
         comp.ZXAuditDate = DateTime.Now;
         comp.ts          = DateTime.Now;
         comp.modifyuser  = Common.UserID();
         if (new Hi.BLL.BD_Company().Update(comp))
         {
             JScript.AlertMsgMo(this, "确认成功", "function(){ window.location.href=window.location.href; }");
         }
         else
         {
             JScript.AlertMsgMo(this, "确认失败", "function(){ window.location.href=window.location.href; }");
         }
     }
     else
     {
         JScript.AlertMsgMo(this, "厂商不存在", "function(){ window.location.href=window.location.href; }");
     }
 }
Ejemplo n.º 3
0
 protected void btn_NUse(object sender, EventArgs e)
 {
     Hi.Model.BD_Company comp = new Hi.BLL.BD_Company().GetModel(KeyID);
     comp.IsEnabled  = 0;
     comp.ts         = DateTime.Now;
     comp.modifyuser = UserID;
     if (new Hi.BLL.BD_Company().Update(comp))
     {
         //List<Hi.Model.SYS_Users> user = new Hi.BLL.SYS_Users().GetList("", " isnull(dr,0)=0 and compid=" + KeyID + "", "");
         //foreach (Hi.Model.SYS_Users model1 in user)
         //{
         //    model1.IsEnabled = 0;
         //    model1.ts = DateTime.Now;
         //    model1.modifyuser = UserID;
         //    new Hi.BLL.SYS_Users().Update(model1);
         //}
         List <Hi.Model.BD_Distributor> dis = new Hi.BLL.BD_Distributor().GetList("", " isnull(dr,0)=0 and compid=" + KeyID + "", "");
         foreach (Hi.Model.BD_Distributor model2 in dis)
         {
             model2.IsEnabled  = 0;
             model2.ts         = DateTime.Now;
             model2.modifyuser = UserID;
             new Hi.BLL.BD_Distributor().Update(model2);
         }
         JScript.AlertMsgMo(this, "用户禁用成功", "function(){ window.location.href='CompList.aspx'; }");
     }
 }
Ejemplo n.º 4
0
 public void DataBinds()
 {
     if (KeyID != 0)
     {
         int       pageCount    = 0;
         int       Counts       = 0;
         string    JoinTableStr = " SYS_CompUser inner join Sys_Users Users on  SYS_CompUser.userid=Users.id and isnull(SYS_CompUser.dr,0)=0 and isnull(Users.dr,0)=0 ";
         DataTable LUser        = new Hi.BLL.SYS_CompUser().GetList(1, 1, "SYS_CompUser.createdate", false, " users.Tel,Identitys,Email,Address,SYS_CompUser.id,UserName,SYS_CompUser.compid,trueName,utype Type,Phone,SYS_CompUser.IsEnabled,SYS_CompUser.createdate,SYS_CompUser.DisID ,OpenID,Sex ", JoinTableStr, "  and SYS_CompUser.id=" + KeyID + " and exists(select 1 from BD_distributor bd where isnull(bd.dr,0)=0 and bd.id= SYS_CompUser.disid) ", out pageCount, out Counts);
         if (LUser.Rows.Count > 0)
         {
             lblDisName.InnerText   = Common.GetDisValue(LUser.Rows[0]["DisID"].ToString().ToInt(0), "disname").ToString();
             lblUname.InnerText     = LUser.Rows[0]["UserName"].ToString();
             lblOpenID.InnerText    = LUser.Rows[0]["OpenID"].ToString();
             lblSex.InnerText       = LUser.Rows[0]["Sex"].ToString();
             lblPhone.InnerText     = LUser.Rows[0]["Phone"].ToString();
             lblTel.InnerText       = LUser.Rows[0]["Tel"].ToString();
             lblIdentitys.InnerText = LUser.Rows[0]["Identitys"].ToString();
             lblTrueName.InnerText  = LUser.Rows[0]["TrueName"].ToString();
             lblIsEnabled.InnerHtml = LUser.Rows[0]["IsEnabled"].ToString().ToInt(0) == 1 ? "启用" : "<i style='color:red;'>禁用</i>";
             lblEmail.InnerText     = LUser.Rows[0]["Email"].ToString();
             //lblAddress.InnerText = user.Address;
         }
         else
         {
             JScript.AlertMsgMo(this, "该用户不存在!", " function (){ location.href='DisUserList.aspx' }");
             return;
         }
     }
     else
     {
         JScript.AlertMsgMo(this, "数据错误!", " function (){ location.href='DisUserList.aspx' }");
         return;
     }
 }
Ejemplo n.º 5
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        SqlTransaction Tran = DBUtility.SqlHelper.CreateStoreTranSaction();

        Hi.Model.SYS_Users user = new Hi.Model.SYS_Users();
        if (Common.GetUserExists(txtUserName.Value.Trim()))
        {
            JScript.AlertMsg(this, "登录帐号已存在。");
            return;
        }
        if (Common.GetUserExists("Phone", txtUserPhone.Value.Trim()))
        {
            JScript.AlertMsg(this, "手机号码已存在。");
            return;
        }
        user.UserName     = Common.NoHTML(txtUserName.Value.Trim());
        user.TrueName     = Common.NoHTML(txtUserTrueName.Value.Trim());
        user.UserPwd      = Util.md5(txtUserPwd.Value.Trim());
        user.Phone        = Common.NoHTML(txtUserPhone.Value.Trim());
        user.AuditState   = 2;
        user.IsEnabled    = 1;
        user.CreateDate   = DateTime.Now;
        user.CreateUserID = UserID;
        user.ts           = DateTime.Now;
        user.modifyuser   = UserID;
        int userid = new Hi.BLL.SYS_Users().Add(user, Tran);

        Hi.Model.SYS_CompUser CompUser = new Hi.Model.SYS_CompUser();
        CompUser.CompID       = KeyID;
        CompUser.DisID        = 0;
        CompUser.CreateDate   = DateTime.Now;
        CompUser.CreateUserID = UserID;
        CompUser.modifyuser   = UserID;
        CompUser.CType        = 1;
        CompUser.UType        = 3;
        CompUser.IsEnabled    = 1;
        CompUser.IsAudit      = 2;
        CompUser.ts           = DateTime.Now;
        CompUser.dr           = 0;
        CompUser.UserID       = userid;
        CompUser.RoleID       = 0;
        new Hi.BLL.SYS_CompUser().Add(CompUser, Tran);
        //新增角色用户
        List <Hi.Model.SYS_Role> list = new Hi.BLL.SYS_Role().GetList("", "isnull(dr,0)=0 and IsEnabled=1 and CompID=" + KeyID + " and RoleName='企业管理员'", "");

        Hi.Model.SYS_RoleUser RoleUser = new Hi.Model.SYS_RoleUser();
        RoleUser.FunType    = 1;
        RoleUser.UserID     = userid;
        RoleUser.RoleID     = list[0].ID;
        RoleUser.IsEnabled  = true;
        RoleUser.CreateUser = this.UserID.ToString();
        RoleUser.CreateDate = DateTime.Now;
        RoleUser.ts         = DateTime.Now;
        RoleUser.dr         = 0;
        new Hi.BLL.SYS_RoleUser().Add(RoleUser, Tran);
        Tran.Commit();
        JScript.AlertMsgMo(this, "添加成功", "function(){ window.location.href=window.location.href; }");
    }
Ejemplo n.º 6
0
    /// <summary>
    /// 新增修改方法
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string hid = Request["hid"] + "";

        if (!string.IsNullOrWhiteSpace(hid))
        {
            Hi.Model.SYS_Hospital hospital = new Hi.BLL.SYS_Hospital().GetModel(Convert.ToInt32(hid));
            hospital.HospitalCode  = this.hospitalCode.Value.Trim();  //医院编码
            hospital.HospitalName  = this.hospitalName.Value.Trim();  //医院全称
            hospital.HospitalLevel = this.hospitalLevel.Value.Trim(); //医院级别
            hospital.Province      = this.hidProvince.Value.Trim();   //省
            hospital.City          = this.hidCity.Value.Trim();       //市
            hospital.Area          = this.hidArea.Value.Trim();       //区
            hospital.Address       = this.address.Value.Trim();       //详细地址
            if (new Hi.BLL.SYS_Hospital().Update(hospital))
            {
                Response.Redirect("hospitalInfo.aspx?hid=" + hospital.ID);
            }
            else
            {
                JScript.AlertMsgMo(this, "医院编辑失败", "function (){ window.location.reload(); }");
            }
        }
        else
        {
            List <Hi.Model.SYS_Hospital> hoslist = new Hi.BLL.SYS_Hospital().GetList("", " HospitalName='" + this.hospitalName.Value.Trim() + "'", "");

            if (hoslist != null && hoslist.Count > 0)
            {
                JScript.AlertMsgMo(this, "医院名称已存在", "function (){  }");
            }
            else
            {
                Hi.Model.SYS_Hospital hospital = new Hi.Model.SYS_Hospital();
                hospital.HospitalCode  = this.hospitalCode.Value.Trim();  //医院编码
                hospital.HospitalName  = this.hospitalName.Value.Trim();  //医院全称
                hospital.HospitalLevel = this.hospitalLevel.Value.Trim(); //医院级别
                hospital.Province      = this.hidProvince.Value.Trim();   //省
                hospital.City          = this.hidCity.Value.Trim();       //市
                hospital.Area          = this.hidArea.Value.Trim();       //区
                hospital.Address       = this.address.Value.Trim();       //详细地址
                hospital.CreateDate    = DateTime.Now;
                hospital.dr            = false;
                hospital.CreateUser    = UserID.ToString();
                hospital.IsEnabled     = true;
                hospital.ts            = DateTime.Now;
                int id = new Hi.BLL.SYS_Hospital().Add(hospital);
                if (id > 0)
                {
                    Response.Redirect("hospitalInfo.aspx?hid=" + id);
                }
                else
                {
                    JScript.AlertMsgMo(this, "医院编辑失败", "function (){ window.location.reload(); }");
                }
            }
        }
    }
Ejemplo n.º 7
0
 //保存首页显示排序
 protected void btnSaveSort_click(object sender, EventArgs e)
 {
     Hi.Model.BD_Company comp = new Hi.BLL.BD_Company().GetModel(KeyID);
     comp.SortIndex = Common.NoHTML(txtSort.Value.Trim());
     if (new Hi.BLL.BD_Company().Update(comp))
     {
         JScript.AlertMsgMo(this, "保存成功!", "function(){}");
     }
 }
Ejemplo n.º 8
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        Hi.Model.SYS_Users user = new Hi.Model.SYS_Users();
        int rolid = 0;

        if (Common.GetUserExists(txtUserName.Value.Trim()))
        {
            JScript.AlertMsg(this, "该用户已存在。");
            return;
        }
        if (!int.TryParse(HidRoid.Value, out rolid) || HidRoid.Value == "-1")
        {
            JScript.AlertMsg(this, "未选择岗位。");
            return;
        }
        if (Common.GetUserExists("Phone", txtUserPhone.Value.Trim()))
        {
            JScript.AlertMsg(this, "手机号码已存在。");
            return;
        }
        SqlTransaction Tran = DBUtility.SqlHelper.CreateStoreTranSaction();

        rolid             = HidRoid.Value.ToInt(0);
        user.UserName     = Common.NoHTML(txtUserName.Value.Trim());
        user.TrueName     = Common.NoHTML(txtTrueName.Value.Trim());
        user.UserPwd      = Util.md5(txtUserPwd.Value.Trim());
        user.Phone        = Common.NoHTML(txtUserPhone.Value.Trim());
        user.AuditState   = 2;
        user.IsEnabled    = 1;
        user.CreateDate   = DateTime.Now;
        user.CreateUserID = UserID;
        user.ts           = DateTime.Now;
        user.modifyuser   = UserID;
        int userid = new Hi.BLL.SYS_Users().Add(user, Tran);

        Hi.Model.SYS_CompUser CompUser = new Hi.Model.SYS_CompUser();
        CompUser.CompID       = TextComp.Compid.ToInt(0);
        CompUser.DisID        = 0;
        CompUser.CreateDate   = DateTime.Now;
        CompUser.CreateUserID = UserID;
        CompUser.modifyuser   = UserID;
        CompUser.CType        = 1;
        CompUser.UType        = 3;
        CompUser.IsEnabled    = 1;
        CompUser.IsAudit      = 2;
        CompUser.ts           = DateTime.Now;
        CompUser.dr           = 0;
        CompUser.UserID       = userid;
        CompUser.RoleID       = rolid;
        new Hi.BLL.SYS_CompUser().Add(CompUser, Tran);
        Tran.Commit();
        string str = string.Format("医站通提示:\n尊敬的用户您好,管理员给您创建了一个帐号为{0}的用户,请登录网站查看\n【医站通】", user.UserName);

        JScript.AlertMsgMo(this, "添加成功", "function(){ window.location.href='CompUserList.aspx?page=" + page + "'; }");
    }
Ejemplo n.º 9
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     Hi.Model.BD_Company comp = new Hi.BLL.BD_Company().GetModel(CompID);
     if (comp != null)
     {
         comp.CustomCompinfo = txtCustomInfo.Text;
         if (new Hi.BLL.BD_Company().Update(comp))
         {
             JScript.AlertMsgMo(this, "操作成功", "function(){ window.location.href=window.location.href; }");
         }
     }
 }
Ejemplo n.º 10
0
 public void DataBindShow()
 {
     if (KeyID > 0)
     {
         Hi.Model.BD_Goods good = new Hi.BLL.BD_Goods().GetModel(KeyID);
         //List<Hi.Model.BD_Goods> ListGoods = new Hi.BLL.BD_Goods().GetList("IsFirstShow,Sortindex,NewPic,GoodsName,ShowName,ID", " dr=0 and id=" + KeyID + "  ", "");
         if (good != null)
         {
             if (good.IsFirstShow)
             {
                 rdShowYes.Checked = true;
                 rdShowNo.Checked  = false;
             }
             if (!string.IsNullOrWhiteSpace(good.NewPic))
             {
                 ImgNewPic.Style.Remove("display");
                 ImgNewPic.Src      = ConfigurationManager.AppSettings["ImgViewPath"] + "CompImage/" + good.NewPic;
                 HdNewPicName.Value = good.NewPic;
             }
             lblGoodsName.InnerText = good.GoodsName;
             txt_SortIndex.Value    = good.Sortindex.ToString();
             txt_ShowName.Value     = good.ShowName;
         }
         else
         {
             if (Request.UrlReferrer != null)
             {
                 JScript.AlertMsgMo(this, "商品数据有误", "function (){ window.parent.layer.close(window.parent.LayserIndex); }");
                 return;
             }
             else
             {
                 Response.Write("商品数据有误。");
                 Response.End();
             }
         }
     }
     else
     {
         if (Request.UrlReferrer != null)
         {
             JScript.AlertMsgMo(this, "商品数据有误", "function (){ window.parent.layer.close(window.parent.LayserIndex); }");
             return;
         }
         else
         {
             Response.Write("商品数据有误。");
             Response.End();
         }
     }
 }
Ejemplo n.º 11
0
    public void Download_Click(object sender, EventArgs e)
    {
        LinkButton bt       = sender as LinkButton;
        string     fileName = bt.Attributes["fileName"];
        string     filePath = Server.MapPath("../../UploadFile/") + fileName;

        if (File.Exists(filePath))
        {
            FileInfo file = new FileInfo(filePath);
            Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8");                                                                                                     //解决中文乱码
            Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(file.Name.Substring(0, file.Name.LastIndexOf("_")) + Path.GetExtension(file.Name))); //解决中文文件名乱码
            Response.AddHeader("Content-length", file.Length.ToString());
            Response.ContentType = "application/octet-stream";
            Response.WriteFile(file.FullName);
            Response.Flush();
            Response.End();
        }
        else
        {
            JScript.AlertMsgMo(this, "附件不存在", "function(){ location.href=location.href;}");
        }
    }
Ejemplo n.º 12
0
 protected void btn_NUse(object sender, EventArgs e)
 {
     Hi.Model.BD_Org Org = new Hi.BLL.BD_Org().GetModel(KeyID);
     if (Org != null)
     {
         Org.IsEnabled  = 0;
         Org.ts         = DateTime.Now;
         Org.modifyuser = UserID;
         if (new Hi.BLL.BD_Org().Update(Org))
         {
             List <Hi.Model.SYS_AdminUser> user = new Hi.BLL.SYS_AdminUser().GetList("", " isnull(dr,0)=0 and orgid=" + KeyID + "", "");
             foreach (Hi.Model.SYS_AdminUser model1 in user)
             {
                 model1.IsEnabled  = 0;
                 model1.ts         = DateTime.Now;
                 model1.modifyuser = UserID;
                 new Hi.BLL.SYS_AdminUser().Update(model1);
             }
             JScript.AlertMsgMo(this, "用户禁用成功", "function(){ window.location.href='OrgList.aspx'; }");
         }
     }
 }
Ejemplo n.º 13
0
 protected void btn_Del(object sender, EventArgs e)
 {
     Hi.Model.BD_Company comp = new Hi.BLL.BD_Company().GetModel(KeyID);
     if (comp != null)
     {
         if (comp.AuditState == 2)
         {
             JScript.ShowAlert(this, "已审核的企业不允许删除");
             return;
         }
         SqlTransaction Tran = DBUtility.SqlHelper.CreateStoreTranSaction();
         comp.dr         = 1;
         comp.ts         = DateTime.Now;
         comp.modifyuser = UserID;
         new Hi.BLL.BD_Company().Update(comp, Tran);
         int        userid                  = 0;
         List <int> ListUserid              = new List <int>();
         List <int> ListDelUserid           = new List <int>();
         List <Hi.Model.SYS_CompUser> luser = new Hi.BLL.SYS_CompUser().GetList("", " dr=0 and Compid=" + comp.ID + " and Utype in (3,4) and Ctype=1 ", "");
         foreach (Hi.Model.SYS_CompUser model in luser)
         {
             if (model.UType == 4)
             {
                 userid = model.UserID;
             }
             if (!ListUserid.Contains(model.UserID))
             {
                 List <Hi.Model.SYS_CompUser> ListCompUser = new Hi.BLL.SYS_CompUser().GetList("id", " dr=0 and Userid=" + model.UserID + " ", "");
                 if (ListCompUser.Count == 1)
                 {
                     ListDelUserid.Add(model.UserID);
                 }
                 ListUserid.Add(model.UserID);
             }
             model.dr         = 1;
             model.ts         = DateTime.Now;
             model.modifyuser = Common.UserID();
             new Hi.BLL.SYS_CompUser().Update(model, Tran);
         }
         string Phone = "";
         List <Hi.Model.SYS_Users> user = new Hi.BLL.SYS_Users().GetList("", " isnull(dr,0)=0 and id=" + userid + "", "");
         if (user.Count > 0)
         {
             Phone = user[0].Phone;
         }
         if (ListDelUserid.Count > 0)
         {
             List <Hi.Model.SYS_Users> ListUsers = new Hi.BLL.SYS_Users().GetList("", " dr=0 and id in(" + string.Join(",", ListDelUserid) + ")", "");
             foreach (Hi.Model.SYS_Users model in ListUsers)
             {
                 model.dr         = 1;
                 model.ts         = DateTime.Now;
                 model.modifyuser = Common.UserID();
                 new Hi.BLL.SYS_Users().Update(model, Tran);
             }
         }
         Tran.Commit();
         if (Request["type"] == "1")
         {
             if (string.IsNullOrWhiteSpace(Phone))
             {
                 Phone = Common.GetCompValue(comp.ID, "Phone").ToString();
             }
             string msg = "您所注册的企业:" + comp.CompName + "已注销!";
             Common.GetPhone(Phone, msg);
             JScript.AlertMsgMo(this, "删除成功", "function(){ window.location.href='CompAuditList.aspx'; }");
         }
         else
         {
             JScript.AlertMsgMo(this, "删除成功", "function() { window.location.href='CompList.aspx'; }");
         }
     }
 }
Ejemplo n.º 14
0
    public void btnAddList_Click(object sender, EventArgs e)
    {
        string         path  = "";
        int            count = 0;
        int            index = 0;
        SqlTransaction Tran  = null;

        try
        {
            if (FileUpload1.HasFile == false)//HasFile用来检查FileUpload是否有指定文件
            {
                JScript.AlertMsg(this, "请您选择Excel文件", "");
                return;                                                                            //当无文件时,返回
            }
            string IsXls = System.IO.Path.GetExtension(FileUpload1.FileName).ToString().ToLower(); //System.IO.Path.GetExtension获得文件的扩展名
            if (IsXls != ".xls" && IsXls != ".xlsx")
            {
                JScript.AlertMsg(this, "只可以选择Excel文件", "");
                return;//当选择的不是Excel文件时,返回
            }
            if (!Directory.Exists(Server.MapPath("TemplateFile")))
            {
                Directory.CreateDirectory(Server.MapPath("TemplateFile"));
            }
            string filename = FileUpload1.FileName;
            string name     = filename.Replace(IsXls, "");
            path = Server.MapPath("TemplateFile/") + name + "-" + DateTime.Now.ToString("yyyyMMddhhmmssffff") + IsXls;
            FileUpload1.SaveAs(path);
            DataTable dt = Common.ExcelToDataTable(path, TitleIndex);
            if (dt == null)
            {
                throw new Exception("Excel表中无数据");
            }
            if (dt.Rows.Count == 0)
            {
                throw new Exception("Excel表中无数据");
            }
            string    Discode     = string.Empty;
            string    DisName     = string.Empty;
            string    DisUserName = string.Empty;
            string    DisAddrees  = string.Empty;
            string    DisPerson   = string.Empty;
            string    DisPhone    = string.Empty;
            string    DisRemark   = string.Empty;
            string    Provice     = string.Empty;
            string    City        = string.Empty;
            string    Area        = string.Empty;
            DataRow[] rows        = dt.Select();
            Tran       = DBUtility.SqlHelper.CreateStoreTranSaction();
            Eroor      = false;
            TitleError = string.Empty;
            foreach (DataRow row in rows)
            {
                try
                {
                    if (row["代理商(代理商)名称 *\n(2-20个汉字或字母,推荐使用中文名称)"].ToString().Trim() == "" && row["管理员姓名 *\n(请填写真实姓名,以便更好地为您服务)"].ToString().Trim() == "" && row["详细地址 *\n(常用收货地址)"].ToString().Trim() == "")
                    {
                        break;
                    }
                    index++;
                    if (row["代理商(代理商)名称 *\n(2-20个汉字或字母,推荐使用中文名称)"].ToString().Trim() == "示例代理商名称1" || row["代理商(代理商)名称 *\n(2-20个汉字或字母,推荐使用中文名称)"].ToString().Trim() == "示例代理商名称2" || row["代理商(代理商)名称 *\n(2-20个汉字或字母,推荐使用中文名称)"].ToString().Trim() == "示例代理商名称3")
                    {
                        continue;
                    }
                    DisName     = DisExistsAttribute("DisName", CheckDisLen(CheckVal(row["代理商(代理商)名称 *\n(2-20个汉字或字母,推荐使用中文名称)"].ToString().Trim(), "代理商(代理商)名称", index), index), "代理商(代理商)名称", index, Tran);
                    DisPerson   = CheckVal(row["管理员姓名 *\n(请填写真实姓名,以便更好地为您服务)"].ToString().Trim(), "管理员姓名", index);
                    DisUserName = UserExistsAttribute("username", CheckVal(row["管理员登录帐号 *\n(2-20个文字、字母、数字,可以录入代理商姓名、简称等,一经设定无法更改,将来可用手机号进行登录)"].ToString().Trim(), "管理员登录帐号", index), "管理员登录帐号", index, Tran);
                    DisPhone    = CheckPhone(CheckVal(row["管理员手机 *\n(登录、发送验证短信)"].ToString().Trim(), "管理员手机", index), "管理员手机", index, Tran);
                    Provice     = CheckVal(row["所在省*"].ToString().Trim(), "省", index);
                    City        = CheckVal(row["所在市*"].ToString().Trim(), "市", index);
                    if (City.IndexOf("_") > 0)
                    {
                        City = City.Substring(City.IndexOf("_") + 1, City.Length - City.IndexOf("_") - 1);
                    }
                    Area       = CheckVal(row["所在区*"].ToString().Trim(), "区", index);
                    DisAddrees = CheckVal(row["详细地址 *\n(常用收货地址)"].ToString().Trim(), "详细地址(常用收货地址)", index);
                    DisRemark  = row["备注"].ToString().Trim();
                }
                catch (Exception ex)
                {
                    if (ex is ApplicationException)
                    {
                        Eroor       = true;
                        TitleError += ex.Message;
                        continue;
                    }
                    else
                    {
                        throw new Exception("代理商Excel模版格式错误,请重新下载模版填入数据后导入。");
                    }
                }

                Hi.Model.BD_Distributor Dis = new Hi.Model.BD_Distributor();
                //Dis.DisCode = Discode;
                Dis.CompID       = CompID;
                Dis.DisName      = DisName;
                Dis.Province     = Provice;
                Dis.City         = City;
                Dis.Area         = Area;
                Dis.Address      = DisAddrees;
                Dis.Principal    = DisPerson;
                Dis.Phone        = DisPhone;
                Dis.Remark       = DisRemark;
                Dis.IsCheck      = 0;
                Dis.CreditType   = 0; //不可以赊销
                Dis.Paypwd       = Util.md5("123456");
                Dis.IsEnabled    = 1;
                Dis.AuditState   = 2;
                Dis.CreateDate   = DateTime.Now;
                Dis.CreateUserID = UserID;
                Dis.ts           = DateTime.Now;
                Dis.modifyuser   = UserID;
                int disid = 0;
                if ((disid = new Hi.BLL.BD_Distributor().Add(Dis, Tran)) > 0)
                {
                    List <Hi.Model.SYS_Role> l = new Hi.BLL.SYS_Role().GetList("", "isnull(dr,0)=0 and isenabled=1 and DisID=" + disid + " and RoleName='企业管理员'", "", Tran);
                    if (l.Count == 0)
                    {
                        //新增角色(企业管理员)
                        Hi.Model.SYS_Role role = new Hi.Model.SYS_Role();
                        role.CompID       = CompID;
                        role.DisID        = disid;
                        role.RoleName     = "企业管理员";
                        role.IsEnabled    = 1;
                        role.SortIndex    = "1";
                        role.CreateDate   = DateTime.Now;
                        role.CreateUserID = UserID;
                        role.ts           = DateTime.Now;
                        role.modifyuser   = UserID;
                        role.dr           = 0;
                        int Roid = new Hi.BLL.SYS_Role().Add(role, Tran);
                        //新增管理员用户和角色
                        Hi.Model.SYS_Users user = new Hi.Model.SYS_Users();
                        user.Type         = 5;
                        user.DisID        = disid;
                        user.CompID       = CompID;
                        user.UserName     = DisUserName;
                        user.Phone        = DisPhone;
                        user.TrueName     = DisPerson;
                        user.UserPwd      = Util.md5("123456");
                        user.IsEnabled    = 1;
                        user.AuditState   = 2;
                        user.RoleID       = Roid;
                        user.CreateDate   = DateTime.Now;
                        user.CreateUserID = UserID;
                        user.ts           = DateTime.Now;
                        user.modifyuser   = UserID;
                        new Hi.BLL.SYS_Users().Add(user, Tran);
                        //新增角色权限表  在审核通过时会加
                    }

                    Hi.Model.BD_DisAddr addr = new Hi.Model.BD_DisAddr();
                    addr.Province     = Provice;
                    addr.City         = City;
                    addr.Area         = Area;
                    addr.DisID        = disid;
                    addr.Principal    = DisPerson;
                    addr.Phone        = DisPhone;
                    addr.Address      = Provice + City + Area + DisAddrees;
                    addr.IsDefault    = 1;
                    addr.ts           = DateTime.Now;
                    addr.CreateDate   = DateTime.Now;
                    addr.CreateUserID = UserID;
                    addr.modifyuser   = UserID;
                    new Hi.BLL.BD_DisAddr().Add(addr, Tran);
                }
                else
                {
                    throw new ApplicationException("导入失败,服务器异常请重试。");
                }
                count++;
            }
            if (!Eroor)
            {
                Tran.Commit();
                if (Request["nextstep"] + "" == "1")
                {
                    JScript.AlertMsgMo(this, "导入成功,共导入" + count + "条代理商", "function(){  $(window.parent.leftFrame.document).find('.menuson li.active').removeClass('active');window.parent.leftFrame.document.getElementById('ktxzjxs').className = 'active'; window.location.href='DisList.aspx?nextstep=1'; }");
                }
                else
                {
                    JScript.AlertMsgMo(this, "导入成功,共导入" + count + "条代理商", "function(){  $(window.parent.leftFrame.document).find('.menuson .lista1 div.al').removeClass('active');window.parent.leftFrame.document.getElementById('jxsxxwh').className = 'al active'; window.location.href='DisList.aspx'; }");
                }
            }
            else
            {
                Tran.Rollback();
                JScript.AlertMsgMo(this, TitleError, "function(){ $('a.bulk').trigger('click'); }");
            }
        }
        catch (Exception ex)
        {
            if (Tran != null)
            {
                if (Tran.Connection != null)
                {
                    Tran.Rollback();
                }
            }
            JScript.AlertMsgMo(this, ex.Message, "function(){ $('a.bulk').trigger('click'); }");
        }
        finally
        {
            if (!string.IsNullOrEmpty(path))
            {
                if (File.Exists(path))
                {
                    File.Delete(path);
                }
            }
        }
    }
Ejemplo n.º 15
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        if (KeyID > 0)
        {
            bool Audit = false;
            Hi.Model.BD_Company comp = new Hi.BLL.BD_Company().GetModel(KeyID);
            if (comp != null)
            {
                if (comp.dr == 1)
                {
                    JScript.AlertMsg(this, "厂商不存在!。");
                    return;
                }
                string         str  = string.Empty;
                SqlTransaction Tran = null;
                try
                {
                    if (comp.AuditState == 2)
                    {
                        Audit = true;
                    }
                    if (Common.CompExistsAttribute("CompName", txtCompName.Value.Trim(), KeyID.ToString()))
                    {
                        JScript.AlertMsg(this, "该厂商名称已存在。");
                        return;
                    }
                    string CompAddr = hidProvince.Value.Trim();
                    if (!string.IsNullOrWhiteSpace(hidCity.Value.Trim()) && hidCity.Value.Trim() != "选择市")
                    {
                        CompAddr += "-" + hidCity.Value.Trim();
                    }
                    if (!string.IsNullOrWhiteSpace(hidArea.Value.Trim()) && hidArea.Value.Trim() != "选择区")
                    {
                        CompAddr += "-" + hidArea.Value.Trim();
                    }
                    comp.CompAddr = CompAddr;
                    comp.CompName = Common.NoHTML(txtCompName.Value.Trim());
                    comp.Capital  = Capital.Value.Trim();
                    comp.CompType = Convert.ToInt32(CompType.SelectedValue);
                    comp.Tel      = Common.NoHTML(txtTel.Value.Trim());
                    if (txtPrincipal.Value.Trim() != "")
                    {
                        comp.Principal = Common.NoHTML(txtPrincipal.Value.Trim());
                    }
                    else
                    {
                        comp.Principal = Common.NoHTML(txtUserTrueName.Value.Trim());
                    }
                    comp.Legal = Common.NoHTML(txtLegal.Value.Trim());
                    if (txtPhone.Value.Trim() != "")
                    {
                        comp.Phone = Common.NoHTML(txtPhone.Value.Trim());
                    }
                    else
                    {
                        comp.Phone = Common.NoHTML(txtUserPhone.Value.Trim());
                    }
                    comp.ShortName  = Common.NoHTML(txtShotName.Value.Trim());
                    comp.Zip        = Common.NoHTML(txtZip.Value.Trim());
                    comp.Identitys  = Common.NoHTML(txtIdentitys.Value.Trim());
                    comp.Licence    = Common.NoHTML(txtLicence.Value.Trim());
                    comp.LegalTel   = Common.NoHTML(txtLegalTel.Value.Trim());
                    comp.ManageInfo = Common.NoHTML(txtInfo.Value.Trim());
                    comp.Fax        = Common.NoHTML(txtFax.Value.Trim());
                    comp.Account    = Common.NoHTML(txtAccount.Value.Trim());
                    comp.Address    = Common.NoHTML(txtAddress.Value.Trim());
                    comp.IndID      = txtIndusName.SelectedValue.ToInt(0);
                    comp.Trade      = txtIndusName.Items[txtIndusName.SelectedIndex].Text;
                    comp.AuditState = 2;
                    comp.AuditDate  = DateTime.Now;//add by hgh 审核日期
                    comp.AuditUser  = UserID.ToString();

                    comp.ts               = DateTime.Now;
                    comp.modifyuser       = UserID;
                    comp.OrganizationCode = Common.NoHTML(txtOrcode.Value.Trim());
                    comp.IsEnabled        = rdEbleYes.Checked ? 1 : 0;
                    comp.HotShow          = rdHotShowYes.Checked ? 1 : 0;
                    comp.FirstShow        = Convert.ToInt32(ddlChkShow.SelectedValue);// rdFirstShowYes.Checked ? 1 : 0;
                    comp.Remark           = Common.NoHTML(txtRemark.Value.Trim());
                    comp.Erptype          = ddlErptype.SelectedValue.ToInt(0);
                    //企业编号  add by hgh
                    comp.CompCode = Common.CreateCode(KeyID);
                    if (HidFfileName.Value != "")
                    {
                        if (string.IsNullOrEmpty(comp.Attachment))
                        {
                            comp.Attachment = HidFfileName.Value;
                        }
                        else
                        {
                            comp.Attachment += "," + HidFfileName.Value;
                        }
                    }
                    List <Hi.Model.SYS_CompUser> ListComp = new Hi.BLL.SYS_CompUser().GetList("", " dr=0 and Ctype=1 and Utype=4 and CompID=" + KeyID + "", "");
                    if (ListComp.Count > 0)
                    {
                        Tran  = DBUtility.SqlHelper.CreateStoreTranSaction();
                        Audit = ListComp[0].IsAudit == 2;
                        if (Audit)
                        {
                            List <Hi.Model.BD_Distributor> dis = new Hi.BLL.BD_Distributor().GetList("", " isnull(dr,0)=0 and compid=" + KeyID + "", "");
                            foreach (Hi.Model.BD_Distributor model2 in dis)
                            {
                                model2.IsEnabled  = comp.IsEnabled;
                                model2.ts         = DateTime.Now;
                                model2.modifyuser = UserID;
                                new Hi.BLL.BD_Distributor().Update(model2, Tran);
                            }
                            new Hi.BLL.BD_Company().Update(comp, Tran);
                            List <Hi.Model.SYS_Users> user = new Hi.BLL.SYS_Users().GetList("", " isnull(dr,0)=0 and id=" + ListComp[0].UserID + " ", "");
                            if (user.Count > 0)
                            {
                                user[0].TrueName   = Common.NoHTML(txtUserTrueName.Value.Trim());
                                user[0].ts         = DateTime.Now;
                                user[0].modifyuser = UserID;
                                new Hi.BLL.SYS_Users().Update(user[0], Tran);
                            }
                            Tran.Commit();
                            Response.Redirect("CompInfo.aspx?go=1&KeyID=" + KeyID + "&type=5", false);
                        }
                        else
                        {
                            if (UserType == 3 || UserType == 4)
                            {
                                comp.OrgID      = OrgID;
                                comp.SalesManID = SalesManID;
                            }
                            if ((new Hi.BLL.BD_Company().Update(comp, Tran)))
                            {
                                //新增数据字典
                                Hi.Model.BD_DefDoc doc = new Hi.Model.BD_DefDoc();
                                doc.CompID     = KeyID;
                                doc.AtCode     = "";
                                doc.AtName     = "计量单位";
                                doc.ts         = DateTime.Now;
                                doc.modifyuser = UserID;
                                doc.dr         = 0;
                                List <Hi.Model.BD_DefDoc> ll = new Hi.BLL.BD_DefDoc().GetList("", "isnull(dr,0)=0 and compid=" + KeyID + " and atname='计量单位'", "", Tran);
                                if (ll.Count == 0)
                                {
                                    new Hi.BLL.BD_DefDoc().Add(doc, Tran);
                                }

                                //代理商加盟是否需要审核
                                Hi.Model.SYS_SysName sysname = new Hi.Model.SYS_SysName();
                                sysname.CompID     = KeyID;
                                sysname.Code       = "";
                                sysname.Name       = "代理商加盟是否需要审核";
                                sysname.Value      = "0";
                                sysname.ts         = DateTime.Now;
                                sysname.modifyuser = UserID;
                                List <Hi.Model.SYS_SysName> sysl = new Hi.BLL.SYS_SysName().GetList("", "Name='代理商加盟是否需要审核' and CompID=" + KeyID, "", Tran);
                                if (sysl != null && sysl.Count == 0)
                                {
                                    new Hi.BLL.SYS_SysName().Add(sysname, Tran);
                                }

                                //费用科目
                                Hi.Model.BD_DefDoc doc1 = new Hi.Model.BD_DefDoc();
                                doc1.CompID     = KeyID;
                                doc1.AtCode     = "";
                                doc1.AtName     = "费用科目";
                                doc1.ts         = DateTime.Now;
                                doc1.modifyuser = UserID;
                                doc1.dr         = 0;
                                List <Hi.Model.BD_DefDoc> ll1 = new Hi.BLL.BD_DefDoc().GetList("", "isnull(dr,0)=0 and compid=" + KeyID + " and atname='费用科目'", "", Tran);
                                if (ll1.Count == 0)
                                {
                                    new Hi.BLL.BD_DefDoc().Add(doc1, Tran);
                                }


                                doc.CompID     = KeyID;
                                doc.AtCode     = "";
                                doc.AtName     = "代理商等级";
                                doc.ts         = DateTime.Now;
                                doc.modifyuser = UserID;
                                doc.dr         = 0;
                                List <Hi.Model.BD_DefDoc> lll = new Hi.BLL.BD_DefDoc().GetList("", "isnull(dr,0)=0 and compid=" + KeyID + " and atname='代理商等级'", "", Tran);
                                if (lll.Count == 0)
                                {
                                    new Hi.BLL.BD_DefDoc().Add(doc, Tran);
                                }
                                List <Hi.Model.SYS_Role> l = new Hi.BLL.SYS_Role().GetList("", "isnull(dr,0)=0 and isenabled=1 and compid=" + KeyID + " and RoleName='企业管理员'", "");
                                if (l.Count == 0)
                                {
                                    //新增角色(企业管理员)
                                    Hi.Model.SYS_Role role = new Hi.Model.SYS_Role();
                                    role.CompID       = KeyID;
                                    role.RoleName     = "企业管理员";
                                    role.IsEnabled    = 1;
                                    role.SortIndex    = "1";
                                    role.CreateDate   = DateTime.Now;
                                    role.CreateUserID = UserID;
                                    role.ts           = DateTime.Now;
                                    role.modifyuser   = UserID;
                                    role.dr           = 0;
                                    int Roid = new Hi.BLL.SYS_Role().Add(role, Tran);

                                    //新增角色用户
                                    Hi.Model.SYS_RoleUser RoleUser = new Hi.Model.SYS_RoleUser();
                                    RoleUser.FunType    = 1;
                                    RoleUser.UserID     = ListComp[0].UserID;
                                    RoleUser.RoleID     = Roid;
                                    RoleUser.IsEnabled  = true;
                                    RoleUser.CreateUser = this.UserID.ToString();
                                    RoleUser.CreateDate = DateTime.Now;
                                    RoleUser.ts         = DateTime.Now;
                                    RoleUser.dr         = 0;
                                    new Hi.BLL.SYS_RoleUser().Add(RoleUser, Tran);

                                    //修改用户对应的角色
                                    List <Hi.Model.SYS_Users> ListUser = new Hi.BLL.SYS_Users().GetList("", " isnull(dr,0)=0 and id=" + ListComp[0].UserID + " ", "");
                                    if (ListUser.Count > 0)
                                    {
                                        ListUser[0].TrueName   = Common.NoHTML(txtUserTrueName.Value.Trim());
                                        ListUser[0].ts         = DateTime.Now;
                                        ListUser[0].modifyuser = UserID;
                                        ListUser[0].AuditState = 2;
                                        new Hi.BLL.SYS_Users().Update(ListUser[0], Tran);
                                    }
                                    ListComp[0].IsAudit    = 2;
                                    ListComp[0].modifyuser = UserID;
                                    ListComp[0].ts         = DateTime.Now;
                                    ListComp[0].RoleID     = Roid;
                                    new Hi.BLL.SYS_CompUser().Update(ListComp[0], Tran);

                                    Hi.Model.BD_CompNews CNew = new Hi.Model.BD_CompNews();
                                    CNew.NewsTitle    = "欢迎登录" + ConfigurationManager.AppSettings["PhoneSendName"].ToString() + "平台";
                                    CNew.NewsContents = "”" + ConfigurationManager.AppSettings["PhoneSendName"].ToString() + "”平台为企业和代理商之间搭建了电子商务平台,通过企业入驻及代理商的加盟,形成覆盖全行业的线上销售网络。同时,充分利用平台信息化整合优势,帮助入驻企业销售模式电商化改造,以及为代理商信息化建设提供有力支持。另外,还将为供应链上的相关各方提供全渠道的结算服务以及授信融资等多项互联网金融服务。";
                                    CNew.IsEnabled    = 1;
                                    CNew.IsTop        = 0;
                                    CNew.NewsType     = 2;
                                    CNew.ShowType     = "1,2";
                                    CNew.CompID       = KeyID;
                                    CNew.CreateDate   = DateTime.Now;
                                    CNew.CreateUserID = UserID;
                                    CNew.ts           = DateTime.Now;
                                    CNew.modifyuser   = UserID;
                                    new Hi.BLL.BD_CompNews().Add(CNew, Tran);

                                    //新增角色权限表
                                    Hi.Model.SYS_RoleSysFun rolesys = null;
                                    //add by hgh   增加了:and funcode<>'1030'
                                    List <Hi.Model.SYS_SysFun> funList = new Hi.BLL.SYS_SysFun().GetList("", " Type=1 and funcode<>'1030'", "");
                                    foreach (Hi.Model.SYS_SysFun sys in funList)
                                    {
                                        rolesys              = new Hi.Model.SYS_RoleSysFun();
                                        rolesys.CompID       = KeyID;
                                        rolesys.RoleID       = Roid;
                                        rolesys.FunCode      = sys.FunCode;
                                        rolesys.FunName      = sys.FunName;
                                        rolesys.IsEnabled    = 1;
                                        rolesys.CreateUserID = UserID;
                                        rolesys.CreateDate   = DateTime.Now;
                                        rolesys.ts           = DateTime.Now;
                                        rolesys.modifyuser   = UserID;
                                        new Hi.BLL.SYS_RoleSysFun().Add(rolesys, Tran);
                                    }

                                    //新增代理商分类
                                    Hi.Model.BD_DisType distype = new Hi.Model.BD_DisType();
                                    distype.CompID       = KeyID;
                                    distype.TypeName     = "全部";
                                    distype.ParentId     = 0;
                                    distype.TypeCode     = "1001";
                                    distype.SortIndex    = "1000";
                                    distype.IsEnabled    = 0;
                                    distype.CreateUserID = UserID;
                                    distype.CreateDate   = DateTime.Now;
                                    distype.ts           = DateTime.Now;
                                    distype.modifyuser   = UserID;
                                    distype.dr           = 0;
                                    new Hi.BLL.BD_DisType().Add(distype, Tran);
                                    Tran.Commit();

                                    //审核成功   添加一条默认的商品分类 -开始

                                    string Typecode = "";//商品大类
                                    //Hi.Model.SYS_GType gtype = new Hi.BLL.SYS_GType().GetList(" top 1 *", " Deep=3  and FullCode like '"+ Typecode + "-%' and IsEnabled=1 and dr=0 ", " parentid,ID")[0];
                                    //Hi.Model.BD_GoodsCategory DisType = new Hi.Model.BD_GoodsCategory();

                                    //DisType.Code = NewCategoryCode("1");
                                    //DisType.Deep = 1;
                                    //DisType.ParCode = "";
                                    //DisType.ParentId = 0;
                                    //DisType.CompID = KeyID;
                                    //DisType.CategoryName = "默认";
                                    //DisType.GoodsTypeID = gtype.ID;
                                    //DisType.SortIndex = "1000";
                                    //DisType.CreateDate = DateTime.Now;
                                    //DisType.CreateUserID = 0;
                                    //DisType.IsEnabled = 1;
                                    //DisType.ts = DateTime.Now;
                                    //DisType.modifyuser = 0;
                                    //SqlTransaction trans = SqlHelper.CreateStoreTranSaction();
                                    //try
                                    //{
                                    //    int countID = 0;
                                    //    if ((countID = new Hi.BLL.BD_GoodsCategory().Add(DisType, trans)) > 0)
                                    //    {
                                    //        List<Hi.Model.BD_Goods> gList = new Hi.BLL.BD_Goods().GetList("", " CategoryID=''", "");
                                    //        if (gList != null && gList.Count > 0)
                                    //        {
                                    //            foreach (var bdGoodse in gList)
                                    //            {
                                    //                bdGoodse.CategoryID = countID;
                                    //                new Hi.BLL.BD_Goods().Update(bdGoodse, trans);
                                    //            }
                                    //        }
                                    //        trans.Commit();

                                    //    }

                                    //}
                                    //catch (Exception ex)
                                    //{
                                    //    Tiannuo.LogHelper.LogHelper.Error("Error", ex);
                                    //    if (trans != null)
                                    //    {
                                    //        if (trans.Connection != null)
                                    //        {
                                    //            trans.Rollback();
                                    //        }
                                    //    }
                                    //    return;
                                    //}
                                    //finally
                                    //{
                                    //    SqlHelper.ConnectionClose();
                                    //    if (trans != null)
                                    //    {
                                    //        if (trans.Connection != null)
                                    //        {
                                    //            trans.Connection.Close();
                                    //        }
                                    //    }
                                    //}
                                    //审核成功   添加一条默认的商品分类 -结束



                                    DBUtility.GetPhoneCode getphonecode = new DBUtility.GetPhoneCode();
                                    str = getphonecode.ReturnSTRS(ListUser[0].Phone, comp.CompName, ListUser[0].UserName);
                                    if (str != "Success")
                                    {
                                        JScript.AlertMsgMo(this, "审核通过的通知短信发送失败!请自行发送短信通知企业。", "function(){ window.location.href='CompInfo.aspx?go=1&KeyID=" + KeyID + "&type=" + Request.QueryString["type"] + "" + "'; }");
                                    }
                                    else
                                    {
                                        JScript.AlertMsgMo(this, "审核成功", "function(){ window.location.href='CompInfo.aspx?go=1&KeyID=" + KeyID + "&type=5'; }");
                                    }
                                }
                                else
                                {
                                    ListComp[0].IsAudit    = 2;
                                    ListComp[0].modifyuser = UserID;
                                    ListComp[0].ts         = DateTime.Now;
                                    new Hi.BLL.SYS_CompUser().Update(ListComp[0], Tran);
                                    Hi.Model.SYS_Users           user  = null;
                                    List <Hi.Model.SYS_CompUser> User2 = new Hi.BLL.SYS_CompUser().GetList("", " dr=0 and utype=4 and CompID=" + KeyID + "", "");
                                    if (User2.Count > 0)
                                    {
                                        user = new Hi.BLL.SYS_Users().GetModel(User2[0].UserID);
                                    }
                                    Tran.Commit();

                                    // 发短信通知
                                    DBUtility.GetPhoneCode getphonecode = new DBUtility.GetPhoneCode();
                                    getphonecode.GetUser(ConfigurationManager.AppSettings["PhoneCodeAccount"].ToString(), ConfigurationManager.AppSettings["PhoneCodePwd"].ToString());
                                    str = getphonecode.ReturnSTRS(user.Phone, comp.CompName, user.UserName);
                                    if (str != "Success")
                                    {
                                        JScript.AlertMsgMo(this, "审核通过的通知短信发送失败!请自行发送短信通知企业。", "function(){ window.location.href='CompInfo.aspx?go=1&KeyID=" + KeyID + "&type=" + Request.QueryString["type"] + "" + "'; }");
                                    }
                                    else
                                    {
                                        JScript.AlertMsgMo(this, "审核成功", "function(){ window.location.href='CompInfo.aspx?go=1&KeyID=" + KeyID + "&type=5'; }");
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        JScript.AlertMsg(this, "用户明细数据异常!。");
                        return;
                    }
                }
                catch (Exception ex)
                {
                    Tiannuo.LogHelper.LogHelper.Error("Error", ex);
                    if (Tran != null)
                    {
                        if (Tran.Connection != null)
                        {
                            Tran.Rollback();
                        }
                    }
                    JScript.AlertMsgMo(this, "审核失败", "function(){ window.location.href=window.location.href; }");
                }
                finally
                {
                    DBUtility.SqlHelper.ConnectionClose();
                }
            }
            else
            {
                JScript.AlertMsg(this, "厂商不存在!。");
                return;
            }


            //cust by ggh 20180327 begin  审核通过时,默认给核心企业设置手续费

            Settings(KeyID);

            //cust by ggh 20180327  end  审核通过时,默认给核心企业设置手续费
        }
        else
        {
            if (Common.GetUserExists(txtUsername.Value.Trim()))
            {
                JScript.AlertMsg(this, "该登录帐号已存在。");
                return;
            }
            if (Common.CompExistsAttribute("CompName", txtCompName.Value.Trim()))
            {
                JScript.AlertMsg(this, "该厂商名称已存在。");
                return;
            }
            Regex Phonereg = new Regex("^0?1[0-9]{10}$");
            if (!Phonereg.IsMatch(txtUserPhone.Value.Trim()))
            {
                JScript.AlertMsg(this, "手机号码格式错误!");
                return;
            }
            if (Common.GetUserExists("Phone", txtUserPhone.Value.Trim()))
            {
                JScript.AlertMsg(this, "手机号码已被注册!");
                return;
            }
            Hi.Model.BD_Company comp = new Hi.Model.BD_Company();
            if (UserType == 3 || UserType == 4)
            {
                comp.OrgID      = OrgID;
                comp.SalesManID = SalesManID;
            }
            comp.CompName = Common.NoHTML(txtCompName.Value.Trim());
            comp.Capital  = Capital.Value.Trim();
            comp.CompType = Convert.ToInt32(CompType.SelectedValue);
            comp.Tel      = Common.NoHTML(txtTel.Value.Trim());
            if (txtPrincipal.Value.Trim() != "")
            {
                comp.Principal = Common.NoHTML(txtPrincipal.Value.Trim());
            }
            else
            {
                comp.Principal = Common.NoHTML(txtUserTrueName.Value.Trim());
            }
            comp.Legal    = Common.NoHTML(txtLegal.Value.Trim());
            comp.LegalTel = Common.NoHTML(txtLegalTel.Value.Trim());
            if (txtPhone.Value.Trim() != "")
            {
                comp.Phone = Common.NoHTML(txtPhone.Value.Trim());
            }
            else
            {
                comp.Phone = Common.NoHTML(txtUserPhone.Value.Trim());
            }
            comp.ShortName        = Common.NoHTML(txtShotName.Value.Trim());
            comp.Zip              = Common.NoHTML(txtZip.Value.Trim());
            comp.Identitys        = Common.NoHTML(txtIdentitys.Value.Trim());
            comp.Licence          = Common.NoHTML(txtLicence.Value.Trim());
            comp.ManageInfo       = Common.NoHTML(txtInfo.Value.Trim());
            comp.Fax              = Common.NoHTML(txtFax.Value.Trim());
            comp.OrganizationCode = Common.NoHTML(txtOrcode.Value.Trim());
            comp.Trade            = txtIndusName.Items[txtIndusName.SelectedIndex].Text;
            comp.Account          = Common.NoHTML(txtAccount.Value.Trim());
            comp.Attachment       = HidFfileName.Value;
            comp.Address          = Common.NoHTML(txtAddress.Value.Trim());
            comp.CustomCompinfo   = "本公司产品种类丰富、质量优良、价格公道、服务周到。感谢您长期的支持与厚爱,您的满意是我们最高的追求,我们将竭诚为您提供优质、贴心的服务!";

            string CompAddr = hidProvince.Value.Trim();
            if (!string.IsNullOrWhiteSpace(hidCity.Value.Trim()) && hidCity.Value.Trim() != "选择市")
            {
                CompAddr += "-" + hidCity.Value.Trim();
            }
            if (!string.IsNullOrWhiteSpace(hidArea.Value.Trim()) && hidArea.Value.Trim() != "选择区")
            {
                CompAddr += "-" + hidArea.Value.Trim();
            }
            comp.CompAddr = CompAddr;

            comp.IndID        = txtIndusName.SelectedValue.ToInt(0);
            comp.CreateDate   = DateTime.Now;
            comp.CreateUserID = UserID;
            comp.ts           = DateTime.Now;
            comp.modifyuser   = UserID;
            comp.IsEnabled    = rdEbleYes.Checked ? 1 : 0;
            comp.HotShow      = rdHotShowYes.Checked ? 1 : 0;
            comp.FirstShow    = Convert.ToInt32(ddlChkShow.SelectedValue);// rdFirstShowYes.Checked ? 1 : 0;
            comp.SortIndex    = "001";
            comp.Remark       = Common.NoHTML(txtRemark.Value.Trim());
            comp.Erptype      = ddlErptype.SelectedValue.ToInt(0);
            comp.AuditState   = 0;
            int            comid = 0;
            SqlTransaction Tran  = DBUtility.SqlHelper.CreateStoreTranSaction();
            comid         = new Hi.BLL.BD_Company().Add(comp, Tran);
            comp.CompCode = Common.CreateCode(comid);
            comp.ID       = comid;
            new Hi.BLL.BD_Company().Update(comp, Tran);
            Hi.Model.SYS_Users user = new Hi.Model.SYS_Users();
            user.UserName     = Common.NoHTML(txtUsername.Value.Trim());
            user.TrueName     = Common.NoHTML(txtUserTrueName.Value.Trim());
            user.UserPwd      = Util.md5(txtUpwd.Text.Trim());
            user.Phone        = Common.NoHTML(txtUserPhone.Value.Trim());
            user.AuditState   = 2;
            user.IsEnabled    = 1;
            user.AuditUser    = UserID.ToString();
            user.CreateUserID = UserID;
            user.CreateDate   = DateTime.Now;
            user.ts           = DateTime.Now;
            user.modifyuser   = UserID;
            int userid = 0;
            userid = new Hi.BLL.SYS_Users().Add(user, Tran);
            Hi.Model.SYS_CompUser CompUser = new Hi.Model.SYS_CompUser();
            CompUser.CompID       = comid;
            CompUser.DisID        = 0;
            CompUser.CreateDate   = DateTime.Now;
            CompUser.CreateUserID = UserID;
            CompUser.modifyuser   = UserID;
            CompUser.CType        = 1;
            CompUser.UType        = 4;
            CompUser.IsEnabled    = 1;
            CompUser.IsAudit      = 0;
            CompUser.ts           = DateTime.Now;
            CompUser.dr           = 0;
            CompUser.UserID       = userid;
            new Hi.BLL.SYS_CompUser().Add(CompUser, Tran);
            Tran.Commit();
            Response.Redirect("CompInfo.aspx?go=1&KeyID=" + comid, false);
        }
    }
Ejemplo n.º 16
0
    public void DataBinds()
    {
        if (Request["show"] == "0")
        {
            divshow.Visible = false;
        }
        if (KeyID > 0)
        {
            Hi.Model.BD_Company comp = new Hi.BLL.BD_Company().GetModel(KeyID);
            if (comp != null)
            {
                Common.BindErptype(ddlErptype, comp.Erptype);
                if (comp.AuditState == 0)
                {
                    if (Request["S"] == "1")
                    {
                        if (Request["type"] == "2")
                        {
                            Atitle.InnerText = "企业查询";
                        }
                        else
                        {
                            Atitle.InnerText = "企业审核";
                        }
                    }
                    else
                    {
                        if (Request["type"] == "2")
                        {
                            btnAdd.Text      = "确定并审核通过";
                            Atitle.InnerText = "企业查询";
                        }
                        else
                        {
                            btnAdd.Text      = "确定并审核通过";
                            Atitle.InnerText = "企业审核";
                        }
                    }
                }
                else
                {
                    if (Request["S"] == "1")
                    {
                        Atitle.InnerText = "企业查询";
                    }
                }
                //edit by hgh
                //if (comp.AuditState == 2)
                //{
                //    Response.Write("企业已通过审核不允许编辑");
                //    Response.End();
                //}
                txtPhone.Attributes.Remove("onblur");
                UpwsTitle.Visible      = false;
                UpwTitle.Visible       = false;
                txtLegalTel.Value      = comp.LegalTel;
                txtOrcode.Value        = comp.OrganizationCode;
                txtCompName.Value      = comp.CompName;
                Capital.Value          = comp.Capital;
                CompType.SelectedValue = comp.CompType.ToString();

                lblCompCode.InnerText      = comp.CompCode;
                txtTel.Value               = comp.Tel;
                txtIdentitys.Value         = comp.Identitys;
                txtPrincipal.Value         = comp.Principal;
                txtLegal.Value             = comp.Legal;
                txtPhone.Value             = comp.Phone;
                txtZip.Value               = comp.Zip;
                txtInfo.Value              = comp.ManageInfo;
                txtLicence.Value           = comp.creditCode;
                txtFax.Value               = comp.Fax;
                txtAccount.Value           = comp.Account;
                txtAddress.Value           = comp.Address;
                txtIndusName.SelectedValue = comp.IndID.ToString();
                txtRemark.Value            = comp.Remark;
                if (ddlErptype.Items.FindByValue(comp.Erptype.ToString()) != null)
                {
                    ddlErptype.SelectedValue = comp.Erptype.ToString();
                }
                if (!string.IsNullOrWhiteSpace(comp.CompAddr))
                {
                    string[] CompAddr = comp.CompAddr.Split('-');
                    if (CompAddr.Length > 0)
                    {
                        this.hidProvince.Value = CompAddr[0].ToString();
                        this.ddlProvince.Value = CompAddr[0].ToString();
                        if (CompAddr.Length > 1)
                        {
                            this.ddlCity.Value = CompAddr[1].ToString();
                            this.hidCity.Value = CompAddr[1].ToString();
                            if (CompAddr.Length > 2)
                            {
                                this.ddlArea.Value = CompAddr[2].ToString();
                                this.hidArea.Value = CompAddr[2].ToString();
                            }
                        }
                    }
                }
                if (comp.HotShow == 0)
                {
                    rdHotShowNo.Checked  = true;
                    rdHotShowYes.Checked = false;
                }
                txtShotName.Value = comp.ShortName;
                if (comp.CompName.Length <= 12 && comp.ShortName == "")
                {
                    txtShotName.Value = comp.CompName;
                }
                if (comp.IsEnabled == 0)
                {
                    rdEbleYes.Checked = false;
                    rdEbleNo.Checked  = true;
                }
                //if (comp.FirstShow == 0)
                //{
                //    rdFirstShowNo.Checked = true;
                //    rdFirstShowYes.Checked = false;
                //}
                this.ddlChkShow.SelectedValue = comp.FirstShow.ToString();
                List <Hi.Model.SYS_CompUser> ListComp = new Hi.BLL.SYS_CompUser().GetList("UserID", " dr=0 and Ctype=1 and Utype=4 and CompID=" + KeyID + "", "");
                if (ListComp.Count > 0)
                {
                    List <Hi.Model.SYS_Users> user = new Hi.BLL.SYS_Users().GetList("UserName,Phone,TrueName,UserPwd", "  isnull(dr,0)=0 and id=" + ListComp[0].UserID + " ", "");
                    if (user.Count > 0)
                    {
                        txtUsername.Disabled  = true;
                        txtUserPhone.Disabled = true;
                        txtUsername.Value     = user[0].UserName;
                        txtUserPhone.Value    = user[0].Phone;
                        txtUserTrueName.Value = user[0].TrueName;
                        txtUpwd.Attributes.Add("value", "123456123456");
                        txtUpwd.Enabled = false;
                        txtUpwds.Attributes.Add("value", "123456123456");
                        txtUpwds.Enabled = false;
                    }
                    else
                    {
                        if (Request.UrlReferrer != null)
                        {
                            JScript.AlertMsgMo(this, "用户数据有误", "function (){ history.go(-1); }");
                            return;
                        }
                        else
                        {
                            Response.Write("用户数据有误。");
                            Response.End();
                        }
                    }
                    if (UserType == 3 || UserType == 4)
                    {
                        if (comp.OrgID != OrgID)
                        {
                            Response.Write("数据不存在");
                            Response.End();
                        }
                    }
                }
                else
                {
                    if (Request.UrlReferrer != null)
                    {
                        JScript.AlertMsgMo(this, "用户明细数据有误", "function (){ history.go(-1); }");
                        return;
                    }
                    else
                    {
                        Response.Write("用户明细数据有误。");
                        Response.End();
                    }
                }
            }
            else
            {
                if (Request.UrlReferrer != null)
                {
                    JScript.AlertMsgMo(this, "数据错误", "function (){ history.go(-1); }");
                    return;
                }
                else
                {
                    Response.Write("数据错误。");
                    Response.End();
                }
            }
        }
        else
        {
            Common.BindErptype(ddlErptype, 0);
            txtUpwd.Attributes.Add("value", "123456");
            txtUpwds.Attributes.Add("value", "123456");
        }
    }