Ejemplo n.º 1
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.º 2
0
    public string GetReceivables(string Json)
    {
        Common.CatchInfo(Json, "GetReceivables", "1");

        int UserID = 0;

        JsonData Params = JsonMapper.ToObject(Json);

        try
        {
            if (Params["UserID"].ToString() == "")
            {
                return("{\"result\":\"F\",\"Description\":\"参数错误!\"}");
            }
            else
            {
                UserID = Convert.ToInt32(Params["UserID"].ToString());
            }
        }
        catch
        {
            return("{\"result\":\"F\",\"Description\":\"参数有误!\"}");
        }
        Hi.Model.SYS_CompUser CompUser_model = Common.Get_CompUser(UserID);
        //Hi.Model.SYS_Users user = new Hi.BLL.SYS_Users().GetModel(UserID);
        if (CompUser_model == null)
        {
            return("{\"result\":\"F\",\"Description\":\"参数有误,数据不存在!\"}");
        }
        //Hi.Model.BD_Distributor dis = new Hi.BLL.BD_Distributor().GetModel(UserID);
        string    strSql = "select dis.ID DisID,DisName,area.AreaName DisDress,DisLevel DisGrade, [Address] DetailedDre, Principal Contact,'' Balance,CompID from BD_Distributor dis left join BD_DisArea area on dis.AreaID=area.ID where isnull(dis.dr,0)=0 and dis.AuditState=2 and dis.CompID =" + CompUser_model.CompID;
        DataTable dt     = DBUtility.SqlHelper.Query(DBUtility.SqlHelper.LocalSqlServer, strSql).Tables[0];

        ArrayList arrayList = new ArrayList();

        foreach (DataRow dataRow in dt.Rows)
        {
            Dictionary <string, object> dictionary = new Dictionary <string, object>();  //实例化一个参数集合
            foreach (DataColumn dataColumn in dt.Columns)
            {
                if (dataColumn.ColumnName == "Balance")
                {
                    dictionary.Add(dataColumn.ColumnName, new Hi.BLL.PAY_PrePayment().sums(Convert.ToInt32(dataRow["DisID"].ToString()), Convert.ToInt32(dataRow["CompID"].ToString())).ToString("0.00"));
                }
                else
                {
                    dictionary.Add(dataColumn.ColumnName, dataRow[dataColumn.ColumnName].ToString());
                }
            }
            arrayList.Add(dictionary); //ArrayList集合中添加键值
        }

        JavaScriptSerializer js = new JavaScriptSerializer();
        string ReceivablesList  = js.Serialize(arrayList);

        return("{\"Result\":\"T\",\"Description\":\"成功!\",\"ReceivablesList\":" + ReceivablesList + "}");
    }
Ejemplo n.º 3
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.º 4
0
    public string GetTransfer(string Json)
    {
        Common.CatchInfo(Json, "GetTransfer", "1");

        int UserID = 0;
        int DisID  = 0;

        JsonData Params = JsonMapper.ToObject(Json);

        try
        {
            if (Params["UserID"].ToString() == "" || Params["DisID"].ToString() == "")
            {
                return("{\"result\":\"F\",\"Description\":\"参数错误!\"}");
            }
            else
            {
                UserID = Convert.ToInt32(Params["UserID"].ToString());
                DisID  = Convert.ToInt32(Params["DisID"].ToString());
            }
        }
        catch
        {
            return("{\"result\":\"F\",\"Description\":\"参数有误!\"}");
        }
        // Hi.Model.SYS_Users user = new Hi.BLL.SYS_Users().GetModel(UserID);
        // Hi.Model.BD_Distributor dis = new Hi.BLL.BD_Distributor().GetModel(UserID);
        Hi.Model.SYS_CompUser CompUser_model = Common.Get_CompUser(UserID);
        if (CompUser_model == null)
        {
            return("{\"result\":\"F\",\"Description\":\"参数有误,数据不存在!\"}");
        }
        string    strsql = "select dis.DisName DisName,pre.ID TransferNo ,pre.price Price,pre.CreatDate TransferDate,[user].TrueName TransferUser,pre.vdef1 Description from Pay_Prepayment pre left join BD_Distributor dis on pre.DisID=dis.ID left join SYS_Users [user] on pre.CrateUser = [user].ID where pre.Start=1 and pre.PreType=6 and pre.CompID=" + CompUser_model.CompID + " order by pre.CreatDate desc";
        DataTable dt     = DBUtility.SqlHelper.Query(DBUtility.SqlHelper.LocalSqlServer, strsql).Tables[0];

        ArrayList arrayList = new ArrayList();

        foreach (DataRow dataRow in dt.Rows)
        {
            Dictionary <string, object> dictionary = new Dictionary <string, object>();  //实例化一个参数集合
            foreach (DataColumn dataColumn in dt.Columns)
            {
                dictionary.Add(dataColumn.ColumnName, dataRow[dataColumn.ColumnName].ToString());
            }
            arrayList.Add(dictionary); //ArrayList集合中添加键值
        }

        JavaScriptSerializer js = new JavaScriptSerializer();
        string TransferList     = js.Serialize(arrayList);

        return("{\"Result\":\"T\",\"Description\":\"成功!\",\"TransferList\":" + TransferList + "}");
    }
Ejemplo n.º 5
0
    public static string Edit(string KeyID, string CompID, string DisID, string UserID, string HtID, string ForceDate, string InvalidDate, string HidFfileName1, string validDate1, string HidFfileName2, string validDate2, string HidFfileName3, string validDate3, string HidFfileName4, string validDate4, string ApplyRemark)
    {
        //
        Common.ResultMessage    Msg       = new Common.ResultMessage();
        Hi.Model.YZT_CMerchants cmModel   = new Hi.BLL.YZT_CMerchants().GetModel(KeyID.ToInt(0));
        Hi.Model.YZT_FirstCamp  firstcamp = new Hi.Model.YZT_FirstCamp();

        //判断是否是该厂商的代理商
        List <Hi.Model.SYS_CompUser> compulist = new Hi.BLL.SYS_CompUser().GetList("", " UserID=" + UserID + " and CompID=" + CompID + " and DisID=" + DisID + "", "");

        Hi.Model.SYS_Users usersModel = new Hi.BLL.SYS_Users().GetModel(UserID);

        //首营信息
        string    sql = "select an.*,fc.ID from YZT_Annex an left join YZT_FCmaterials fc  on an.fcID =fc.ID and an.fileAlias in (4) and an.type in(5,7,8,9) where fc.DisID=" + DisID + " and ISNULL(fc.dr,0)=0 and fc.type=2 and ISNULL(an.dr,0)=0";
        DataTable dt  = SqlHelper.GetTable(SqlHelper.LocalSqlServer, sql);

        LoginModel uModel = null;

        if (HttpContext.Current.Session["UserModel"] is LoginModel)
        {
            uModel = HttpContext.Current.Session["UserModel"] as LoginModel;
        }

        SqlTransaction Tran = null;

        try
        {
            Tran = DBUtility.SqlHelper.CreateStoreTranSaction();

            if (DisID == "0")
            {
                Hi.Model.BD_Distributor Distributor = new Hi.Model.BD_Distributor();
                Distributor.CompID       = 0;
                Distributor.DisName      = uModel.CompName;
                Distributor.IsEnabled    = 1;
                Distributor.Paypwd       = Util.md5("123456");
                Distributor.Phone        = uModel.Phone;
                Distributor.AuditState   = 0;
                Distributor.CreateDate   = DateTime.Now;
                Distributor.CreateUserID = uModel.UserID;
                Distributor.ts           = DateTime.Now;
                Distributor.modifyuser   = uModel.UserID;
                Distributor.IsCheck      = 0;
                Distributor.CreditType   = 0;
                Distributor.pic          = "";
                //Distributor.creditCode = txt_creditCode;
                Distributor.Leading = "";
                Distributor.Licence = "";
                int DistributorID = 0;
                if ((DistributorID = new Hi.BLL.BD_Distributor().Add(Distributor, Tran)) > 0)
                {
                    DisID = DistributorID.ToString();

                    //代理商账户登录
                    Hi.Model.SYS_CompUser compuser = new Hi.Model.SYS_CompUser();
                    compuser.UserID       = UserID.ToInt(0);
                    compuser.CompID       = CompID.ToInt(0);
                    compuser.DisID        = DisID.ToInt(0);
                    compuser.AreaID       = 0;
                    compuser.RoleID       = usersModel == null ? 0 : usersModel.RoleID;
                    compuser.CType        = 2;
                    compuser.UType        = 5;
                    compuser.IsAudit      = 0;
                    compuser.IsEnabled    = 1;
                    compuser.ts           = DateTime.Now;
                    compuser.CreateUserID = UserID.ToInt(0);
                    compuser.modifyuser   = UserID.ToInt(0);
                    compuser.CreateDate   = DateTime.Now;

                    if (new Hi.BLL.SYS_CompUser().Add(compuser, Tran) <= 0)
                    {
                        Tran.Rollback();
                        Msg.code = "用户信息添加失败";
                        return(new JavaScriptSerializer().Serialize(Msg));
                    }
                }
                else
                {
                    Tran.Rollback();
                    Msg.code = "用户信息添加失败";
                    return(new JavaScriptSerializer().Serialize(Msg));
                }
            }
            else
            {
                if (compulist != null && compulist.Count <= 0)
                {
                    //代理商账户登录
                    Hi.Model.SYS_CompUser compuser = new Hi.Model.SYS_CompUser();
                    compuser.UserID       = UserID.ToInt(0);
                    compuser.CompID       = CompID.ToInt(0);
                    compuser.DisID        = DisID.ToInt(0);
                    compuser.AreaID       = 0;
                    compuser.RoleID       = usersModel == null ? 0 : usersModel.RoleID;
                    compuser.CType        = 2;
                    compuser.UType        = 5;
                    compuser.IsAudit      = 0;
                    compuser.IsEnabled    = 1;
                    compuser.ts           = DateTime.Now;
                    compuser.CreateUserID = UserID.ToInt(0);
                    compuser.modifyuser   = UserID.ToInt(0);
                    compuser.CreateDate   = DateTime.Now;

                    if (new Hi.BLL.SYS_CompUser().Add(compuser, Tran) <= 0)
                    {
                        Tran.Rollback();
                        Msg.code = "用户信息添加失败";
                        return(new JavaScriptSerializer().Serialize(Msg));
                    }
                }
            }

            List <Hi.Model.YZT_FirstCamp> fcamplist = new Hi.BLL.YZT_FirstCamp().GetList("", " CMID=" + KeyID + " and DisID=" + DisID + " and CompID=" + CompID + " and HtID=" + HtID, "");
            if (fcamplist != null && fcamplist.Count > 0)
            {
                Tran.Rollback();
                Msg.code = "已申请合作";
                return(new JavaScriptSerializer().Serialize(Msg));
            }

            firstcamp.CMID        = KeyID.ToInt(0);
            firstcamp.CompID      = CompID.ToInt(0);
            firstcamp.DisID       = DisID.ToInt(0);
            firstcamp.ForceDate   = ForceDate != "" ? Convert.ToDateTime(ForceDate) : DateTime.MinValue;
            firstcamp.InvalidDate = InvalidDate != "" ? Convert.ToDateTime(InvalidDate) : DateTime.MinValue;
            firstcamp.State       = 0;
            firstcamp.HtID        = HtID.ToInt(0);
            firstcamp.Applyremark = ApplyRemark;

            firstcamp.ts           = DateTime.Now;
            firstcamp.modifyuser   = UserID.ToInt(0);
            firstcamp.CreateDate   = DateTime.Now;
            firstcamp.CreateUserID = UserID.ToInt(0);

            int id = new Hi.BLL.YZT_FirstCamp().Add(firstcamp, Tran);

            if (id > 0)
            {
                //string annexdel = " fileAlias=1 and type in(5,7,9,8) and fcID=" + id;
                //new Hi.BLL.YZT_Annex().AnnexDelete(annexdel, Tran);

                List <Hi.Model.YZT_FCmaterials> fcmlist = new Hi.BLL.YZT_FCmaterials().GetList("", "DisID=" + DisID + " and type=2", "");
                int fcmid = 0;
                Hi.Model.YZT_FCmaterials fcmmodel = null;
                if (fcmlist != null && fcmlist.Count > 0)
                {
                    fcmmodel = fcmlist[0];
                    fcmid    = fcmmodel.ID;
                }
                else
                {
                    fcmmodel              = new Hi.Model.YZT_FCmaterials();
                    fcmmodel.CompID       = 0;
                    fcmmodel.DisID        = DisID.ToInt(0);
                    fcmmodel.type         = 2;
                    fcmmodel.ts           = DateTime.Now;
                    fcmmodel.modifyuser   = UserID.ToInt(0);
                    fcmmodel.CreateUserID = UserID.ToInt(0);
                    fcmmodel.CreateDate   = DateTime.Now;
                    fcmmodel.dr           = 0;
                    fcmid = new Hi.BLL.YZT_FCmaterials().Add(fcmmodel, Tran);
                }

                int    count       = id;
                string ProvideData = cmModel.ProvideData;
                if (ProvideData.IndexOf("1") > -1)
                {
                    //营业执照
                    Hi.Model.YZT_Annex annexModel1 = insertAnnex(id, 5, HidFfileName1, validDate1, UserID, "1");
                    count = new Hi.BLL.YZT_Annex().Add(annexModel1, Tran);

                    Hi.Model.YZT_Annex updateModel1 = UpFCmaterials(dt, 5, HidFfileName1, validDate1, UserID);
                    if (updateModel1 != null)
                    {
                        new Hi.BLL.YZT_Annex().Update(updateModel1, Tran);
                    }
                    else
                    {
                        Hi.Model.YZT_Annex annexModel11 = insertAnnex(fcmid, 5, HidFfileName1, validDate1, UserID, "4");
                        new Hi.BLL.YZT_Annex().Add(annexModel11, Tran);
                    }
                }
                if (ProvideData.IndexOf("2") > -1)
                {
                    //医疗器械经营许可证
                    Hi.Model.YZT_Annex annexModel2 = insertAnnex(id, 7, HidFfileName2, validDate2, UserID, "1");
                    count = new Hi.BLL.YZT_Annex().Add(annexModel2, Tran);

                    Hi.Model.YZT_Annex updateModel2 = UpFCmaterials(dt, 7, HidFfileName2, validDate2, UserID);
                    if (updateModel2 != null)
                    {
                        new Hi.BLL.YZT_Annex().Update(updateModel2, Tran);
                    }
                    else
                    {
                        Hi.Model.YZT_Annex annexModel11 = insertAnnex(fcmid, 7, HidFfileName2, validDate2, UserID, "4");
                        new Hi.BLL.YZT_Annex().Add(annexModel11, Tran);
                    }
                }
                if (ProvideData.IndexOf("3") > -1)
                {
                    //开户许可证
                    Hi.Model.YZT_Annex annexModel3 = insertAnnex(id, 9, HidFfileName3, validDate3, UserID, "1");
                    count = new Hi.BLL.YZT_Annex().Add(annexModel3, Tran);

                    Hi.Model.YZT_Annex updateModel3 = UpFCmaterials(dt, 9, HidFfileName3, validDate3, UserID);
                    if (updateModel3 != null)
                    {
                        new Hi.BLL.YZT_Annex().Update(updateModel3, Tran);
                    }
                    else
                    {
                        Hi.Model.YZT_Annex annexModel11 = insertAnnex(fcmid, 9, HidFfileName3, validDate3, UserID, "4");
                        new Hi.BLL.YZT_Annex().Add(annexModel11, Tran);
                    }
                }
                if (ProvideData.IndexOf("4") > -1)
                {
                    //医疗器械备案
                    Hi.Model.YZT_Annex annexModel4 = insertAnnex(id, 8, HidFfileName4, validDate4, UserID, "1");
                    count = new Hi.BLL.YZT_Annex().Add(annexModel4, Tran);

                    Hi.Model.YZT_Annex updateModel4 = UpFCmaterials(dt, 8, HidFfileName4, validDate4, UserID);
                    if (updateModel4 != null)
                    {
                        new Hi.BLL.YZT_Annex().Update(updateModel4, Tran);
                    }
                    else
                    {
                        Hi.Model.YZT_Annex annexModel11 = insertAnnex(fcmid, 8, HidFfileName4, validDate4, UserID, "4");
                        new Hi.BLL.YZT_Annex().Add(annexModel11, Tran);
                    }
                }
                if (count <= 0)
                {
                    Tran.Rollback();
                    Msg.code = "编辑异常!";
                    return(new JavaScriptSerializer().Serialize(Msg));
                }
                Tran.Commit();
                Msg.result = true;
            }
            else
            {
                Tran.Rollback();
                Msg.code = "编辑异常!";
            }
        }
        catch (Exception)
        {
            Msg.code = "编辑异常!";
            throw;
        }
        return(new JavaScriptSerializer().Serialize(Msg));
    }
Ejemplo n.º 6
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.AlertMsgOne(this, "请您选择代理商Excel模板文件", JScript.IconOption.错误);
                return;                                                                            //当无文件时,返回
            }
            string IsXls = System.IO.Path.GetExtension(FileUpload1.FileName).ToString().ToLower(); //System.IO.Path.GetExtension获得文件的扩展名
            if (IsXls != ".xls" && IsXls != ".xlsx")
            {
                JScript.AlertMsgOne(this, "请您选择代理商Excel模板文件", JScript.IconOption.错误);
                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;
            string    DisCategory = string.Empty;
            string    DisLevel    = string.Empty;
            DataRow[] rows        = dt.Select();
            Tran       = DBUtility.SqlHelper.CreateStoreTranSaction();
            Eroor      = false;
            TitleError = string.Empty;
            foreach (DataRow row in rows)
            {
                int typeID = 0;
                int AreaID = 0;
                try
                {
                    //这个判断有bug呀,是遇到空行就停止的意思吗?
                    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);
                    DisCategory = row["代理商分类"].ToString().Trim();
                    DisLevel    = row["代理商区域"].ToString().Trim();
                    bool disType = true;
                    if (!string.IsNullOrEmpty(DisCategory))
                    {
                        disType = CheckDisCategory(DisCategory, index, out typeID);
                    }
                    if (!string.IsNullOrEmpty(DisLevel))
                    {
                        CheckDisLevel(DisLevel, index, out AreaID);
                    }
                    DisRemark = row["备注"].ToString().Trim();
                    if (Eroor)
                    {
                        continue;
                    }
                }
                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.DisTypeID    = typeID; //add by 2016.5.9
                Dis.AreaID       = AreaID; //add by 2016.5.10
                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.UserName     = DisUserName;
                        user.Phone        = DisPhone;
                        user.TrueName     = DisPerson;
                        user.UserPwd      = Util.md5("123456");
                        user.IsEnabled    = 1;
                        user.AuditState   = 2;
                        user.CreateDate   = DateTime.Now;
                        user.CreateUserID = UserID;
                        user.ts           = DateTime.Now;
                        user.modifyuser   = UserID;
                        int AddUserid = new Hi.BLL.SYS_Users().Add(user, Tran);

                        ///用户明细表
                        Hi.Model.SYS_CompUser CompUser = new Hi.Model.SYS_CompUser();
                        CompUser.CompID       = CompID;
                        CompUser.DisID        = disid;
                        CompUser.CreateDate   = DateTime.Now;
                        CompUser.CreateUserID = UserID;
                        CompUser.modifyuser   = UserID;
                        CompUser.CType        = 2;
                        CompUser.UType        = 5;
                        CompUser.IsEnabled    = 1;
                        CompUser.IsAudit      = 2;
                        CompUser.RoleID       = Roid;
                        CompUser.ts           = DateTime.Now;
                        CompUser.dr           = 0;
                        CompUser.UserID       = AddUserid;
                        new Hi.BLL.SYS_CompUser().Add(CompUser, Tran);
                        //新增角色权限表   //暂时屏蔽下
                        Hi.Model.SYS_RoleSysFun    rolesys = null;
                        List <Hi.Model.SYS_SysFun> funList = new Hi.BLL.SYS_SysFun().GetList("", " Type=2", "", Tran);
                        foreach (Hi.Model.SYS_SysFun sys in funList)
                        {
                            rolesys              = new Hi.Model.SYS_RoleSysFun();
                            rolesys.CompID       = CompID;
                            rolesys.DisID        = disid;
                            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_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.AlertMethod(this, "导入成功,共导入" + count + "条代理商", JScript.IconOption.笑脸, "function(){  window.location.href=window.location.href+'?nextstep=1'; /* $(window.parent.leftFrame.document).find('.menuson li.active').removeClass('active');window.parent.leftFrame.document.getElementById('ktxzjxs').className = 'active';*/}");
                }
                else
                {
                    JScript.AlertMethod(this, "导入成功,共导入" + count + "条代理商", JScript.IconOption.笑脸, "function(){  window.location.href=window.location.href; }");
                }
            }
            else
            {
                Tran.Rollback();
                JScript.AlertMethod(this, TitleError, JScript.IconOption.错误, "function(){ addList(); }");
            }
        }
        catch (Exception ex)
        {
            if (Tran != null)
            {
                if (Tran.Connection != null)
                {
                    Tran.Rollback();
                }
            }
            JScript.AlertMethod(this, ex.Message, JScript.IconOption.错误, "function(){ $('a.bulk').trigger('click'); }");
        }
        finally
        {
            if (!string.IsNullOrEmpty(path))
            {
                if (File.Exists(path))
                {
                    File.Delete(path);
                }
            }
        }
    }
Ejemplo n.º 7
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Hi.Model.SYS_CompUser model)
 {
     return(dal.Update(model));
 }
Ejemplo n.º 8
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Hi.Model.SYS_CompUser model)
 {
     return(dal.Add(model));
 }
Ejemplo n.º 9
0
    /// <summary>
    /// 确定导入
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnImport_Click(object sender, EventArgs e)
    {
        if (HttpContext.Current.Session["DisTable"] != null)
        {
            SqlTransaction Tran = DBUtility.SqlHelper.CreateStoreTranSaction();
            try
            {
                DataTable dt = HttpContext.Current.Session["DisTable"] as DataTable;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (dt.Rows[i]["chkstr"].ToString() == "数据正确!")
                    {
                        Hi.Model.BD_Distributor Dis = new Hi.Model.BD_Distributor();
                        //Dis.DisCode = Discode;
                        Dis.CompID       = CompID;
                        Dis.DisName      = dt.Rows[i]["disname"].ToString().Trim();
                        Dis.Province     = dt.Rows[i]["pro"].ToString().Trim();
                        Dis.City         = dt.Rows[i]["city"].ToString().Trim();
                        Dis.Area         = dt.Rows[i]["quxian"].ToString().Trim();
                        Dis.Address      = dt.Rows[i]["address"].ToString().Trim();
                        Dis.Principal    = dt.Rows[i]["principal"].ToString().Trim();
                        Dis.Phone        = dt.Rows[i]["phone"].ToString().Trim();
                        Dis.DisTypeID    = Convert.ToInt32(dt.Rows[i]["distypeid"].ToString().Trim()); //add by 2016.5.9
                        Dis.AreaID       = Convert.ToInt32(dt.Rows[i]["areaid"].ToString().Trim());    //add by 2016.5.10
                        Dis.Remark       = dt.Rows[i]["remark"].ToString().Trim();
                        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.UserName     = dt.Rows[i]["username"].ToString().Trim();
                                user.Phone        = dt.Rows[i]["phone"].ToString().Trim();
                                user.TrueName     = dt.Rows[i]["principal"].ToString().Trim();
                                user.UserPwd      = Util.md5("123456");
                                user.IsEnabled    = 1;
                                user.AuditState   = 2;
                                user.CreateDate   = DateTime.Now;
                                user.CreateUserID = UserID;
                                user.ts           = DateTime.Now;
                                user.modifyuser   = UserID;
                                int AddUserid = new Hi.BLL.SYS_Users().Add(user, Tran);

                                ///用户明细表
                                Hi.Model.SYS_CompUser CompUser = new Hi.Model.SYS_CompUser();
                                CompUser.CompID       = CompID;
                                CompUser.DisID        = disid;
                                CompUser.CreateDate   = DateTime.Now;
                                CompUser.CreateUserID = UserID;
                                CompUser.modifyuser   = UserID;
                                CompUser.CType        = 2;
                                CompUser.UType        = 5;
                                CompUser.IsEnabled    = 1;
                                CompUser.IsAudit      = 2;
                                CompUser.RoleID       = Roid;
                                CompUser.ts           = DateTime.Now;
                                CompUser.dr           = 0;
                                CompUser.UserID       = AddUserid;
                                new Hi.BLL.SYS_CompUser().Add(CompUser, Tran);
                                //新增角色权限表   //暂时屏蔽下
                                Hi.Model.SYS_RoleSysFun    rolesys = null;
                                List <Hi.Model.SYS_SysFun> funList = new Hi.BLL.SYS_SysFun().GetList("", " Type=2", "", Tran);
                                foreach (Hi.Model.SYS_SysFun sys in funList)
                                {
                                    rolesys              = new Hi.Model.SYS_RoleSysFun();
                                    rolesys.CompID       = CompID;
                                    rolesys.DisID        = disid;
                                    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_DisAddr addr = new Hi.Model.BD_DisAddr();
                            addr.Province     = dt.Rows[i]["pro"].ToString().Trim();
                            addr.City         = dt.Rows[i]["city"].ToString().Trim();
                            addr.Area         = dt.Rows[i]["quxian"].ToString().Trim();
                            addr.DisID        = disid;
                            addr.Principal    = dt.Rows[i]["principal"].ToString().Trim();
                            addr.Phone        = dt.Rows[i]["phone"].ToString().Trim();
                            addr.Address      = dt.Rows[i]["pro"].ToString().Trim() + dt.Rows[i]["city"].ToString().Trim() + dt.Rows[i]["quxian"].ToString().Trim() + dt.Rows[i]["address"].ToString().Trim();
                            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("导入失败,服务器异常请重试。");
                        }
                    }
                }
                Tran.Commit();
                Response.Redirect("ImportDis3.aspx", false);
                //ClientScript.RegisterStartupScript(this.GetType(), "Add", "<script>addlis(" + count + "," + count2 + ",'" + str + "');</script>");
            }
            catch (Exception ex)
            {
                if (Tran != null)
                {
                    if (Tran.Connection != null)
                    {
                        Tran.Rollback();
                    }
                }
                HttpContext.Current.Session["DisTable"] = null;
                JScript.AlertMethod(this, ex.Message, JScript.IconOption.错误, "function(){location.href='ImportDis.aspx'}");
            }
        }
        else
        {
            JScript.AlertMethod(this, "Excel没有数据,请重新导入", JScript.IconOption.错误, "function(){location.href='ImportDis.aspx'}");
        }
    }
Ejemplo n.º 10
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        Hi.Model.SYS_Users    User            = null;
        Hi.Model.SYS_CompUser CompUser        = null;
        Hi.Model.SYS_RoleUser RoleUser        = null;
        Hi.BLL.SYS_RoleUser   RoleUserService = new Hi.BLL.SYS_RoleUser();
        SqlTransaction        Tran            = null;

        if (KeyID != 0)
        {
            #region 优化权限前的代码
            //int userid = ViewState["Userid"].ToString().ToInt(0);
            //if (Common.GetUserExists("UserName", txtUserName.Value.Trim(), userid.ToString()))
            //{
            //    JScript.AlertMsgOne(this, "该登录帐号已存在!", JScript.IconOption.错误);
            //    return;
            //}
            //if (Common.GetUserExists("Phone", txtPhone.Value.Trim(), userid.ToString()))
            //{
            //    JScript.AlertMsgOne(this, "该手机号码已存在!", JScript.IconOption.错误);
            //    return;
            //}
            //if (txtPwd.Text.Trim() != txtUserPwd.Text.Trim())
            //{
            //    JScript.AlertMsgOne(this, "确认密码填写不一致!", JScript.IconOption.错误);
            //    return;
            //}
            //List<Hi.Model.SYS_CompUser> ListCompUser = new Hi.BLL.SYS_CompUser().GetList("", "id=" + KeyID + " and isnull(dr,0)=0", "");
            //if (ListCompUser.Count == 0)
            //{
            //    JScript.AlertMethod(this, "用户明细数据有误!", JScript.IconOption.错误, "function (){ history.go(-1) ; }");
            //    return;
            //}
            //if (rdEnabledNo.Checked)
            //{
            //    if (ListCompUser[0].UType == 5)
            //    {
            //        JScript.AlertMsgOne(this, "用户为系统管理员,不可禁用!", JScript.IconOption.错误);
            //        return;
            //    }
            //}
            //else
            //{
            //    if (ListCompUser[0].UType != 5)
            //    {
            //        List<Hi.Model.SYS_Role> ListRole = new Hi.BLL.SYS_Role().GetList("RoleName,IsEnabled", " dr=0 and id=" + ListCompUser[0].RoleID + "", "");
            //        if (ListRole.Count > 0)
            //        {
            //            if (ListRole[0].IsEnabled == 0)
            //            {
            //                JScript.AlertMsgOne(this, "请先启用该人员所在岗位(" + ListRole[0].RoleName + ")!", JScript.IconOption.错误, 2500);
            //                return;
            //            }
            //        }
            //    }
            //}
            //Tran = DBUtility.SqlHelper.CreateStoreTranSaction();
            //User = new Hi.BLL.SYS_Users().GetModel(userid);
            //User.TrueName = txtTrueName.Value.Trim();
            //User.Identitys = txtIdentitys.Value.Trim();
            //User.Address = txtAddress.Value.Trim();
            //User.Email = txtEmail.Value.Trim();
            //ListCompUser[0].IsEnabled = rdEnabledYes.Checked ? 1 : 0;
            //ListCompUser[0].ts = DateTime.Now;
            //ListCompUser[0].modifyuser = UserID;
            //if (txtUserPwd.Text.Trim() != Util.md5("123456"))
            //{
            //    User.UserPwd = Util.md5(txtUserPwd.Text.Trim());
            //}
            //if (ListCompUser[0].UType != 4)
            //{
            //    User.UserName = txtUserName.Value.Trim();
            //    User.Phone = txtPhone.Value.Trim();
            //}
            //User.ts = DateTime.Now;
            //User.modifyuser = UserID;
            //new Hi.BLL.SYS_Users().Update(User, Tran);
            //new Hi.BLL.SYS_CompUser().Update(ListCompUser[0], Tran);
            //Tran.Commit();
            //JScript.AlertMethod(this, "操作成功!", JScript.IconOption.正确, "function(){ cancel(); }");
            #endregion
            Tran = DBUtility.SqlHelper.CreateStoreTranSaction();
            //修改
            User     = new Hi.BLL.SYS_Users().GetModel(KeyID);
            CompUser = new Hi.Model.SYS_CompUser();
            if (User.UserName != txtUserName.Value.Trim())
            {
                if (Common.GetUserExists("UserName", txtUserName.Value.Trim()))
                {
                    JScript.AlertMsgOne(this, "该登录帐号已存在!", JScript.IconOption.错误);
                    return;
                }
            }
            if (User.Phone != txtPhone.Value.Trim())
            {
                if (txtPhone.Value.Trim() == "")
                {
                    JScript.AlertMsgOne(this, "手机号码不能为空!", JScript.IconOption.错误);
                    return;
                }
                if (Common.GetUserExists("Phone", txtPhone.Value.Trim()))
                {
                    JScript.AlertMsgOne(this, "该手机号码已存在!", JScript.IconOption.错误);
                    return;
                }
            }
            if (txtPwd.Text.Trim() != txtUserPwd.Text.Trim())
            {
                JScript.AlertMsgOne(this, "确认密码填写不一致!", JScript.IconOption.错误);
                return;
            }
            //禁用时判断
            if (rdEnabledNo.Checked)
            {
                List <Hi.Model.SYS_CompUser> ListCompUser = new Hi.BLL.SYS_CompUser().GetList("", " CompID=" + CompID + " AND UserID=" + KeyID + " AND dr=0 AND IsEnabled=1 ", "");
                if (ListCompUser[0].UType == 5)
                {
                    JScript.AlertMsgOne(this, "用户为管理员,不可禁用!", JScript.IconOption.错误);
                    return;
                }
                else
                {
                    User.IsEnabled     = 0;
                    CompUser.IsEnabled = 0;
                    List <Hi.Model.SYS_RoleUser> roleusers = new Hi.BLL.SYS_RoleUser().GetList("", " UserID=" + KeyID + " AND dr=0 ", "");
                    if (roleusers.Count > 0)
                    {
                        for (int i = 0; i < roleusers.Count; i++)
                        {
                            roleusers[i].IsEnabled = false;
                        }
                    }
                }
            }
            if (rdEnabledYes.Checked)
            {
                User.IsEnabled     = 1;
                CompUser.IsEnabled = 1;
            }
            User.UserName  = Common.NoHTML(txtUserName.Value.Trim());
            User.TrueName  = Common.NoHTML(txtTrueName.Value.Trim());
            User.Identitys = Common.NoHTML(txtIdentitys.Value.Trim());
            User.Phone     = Common.NoHTML(txtPhone.Value.Trim());
            if (txtPwd.Text.Trim() != User.UserPwd)
            {
                User.UserPwd = Util.md5(txtUserPwd.Text.Trim());
            }
            User.Address    = Common.NoHTML(txtAddress.Value.Trim());
            User.Email      = Common.NoHTML(txtEmail.Value.Trim());
            User.Type       = 1;
            User.ts         = DateTime.Now;
            User.modifyuser = UserID;
            CompUser.UType  = 1;
            //岗位权限表
            List <Hi.Model.SYS_RoleUser> roleuser = new Hi.BLL.SYS_RoleUser().GetList("", "  UserID=" + KeyID + "  AND dr=0 ", "");
            for (int i = 0; i < roleuser.Count; i++)
            {
                roleuser[i].IsEnabled = false;
                roleuser[i].ts        = DateTime.Now;
                RoleUserService.Update(roleuser[i]);
            }
            if (hidMyRole.Value != "")
            {
                string[] rolestr = hidMyRole.Value.Substring(0, hidMyRole.Value.Length - 1).Split(',');
                for (int i = 0; i < rolestr.Length; i++)
                {
                    List <Hi.Model.SYS_RoleUser> rolenew = new Hi.BLL.SYS_RoleUser().GetList("", "  UserID=" + KeyID + " AND dr=0 AND RoleID=" + rolestr[i].ToInt(0) + " ", "");
                    if (rolenew.Count > 0)
                    {
                        rolenew[0].IsEnabled = true;
                        rolenew[0].ts        = DateTime.Now;
                        RoleUserService.Update(rolenew[0]);
                    }
                    else
                    {
                        RoleUser            = new Hi.Model.SYS_RoleUser();
                        RoleUser.FunType    = 1;
                        RoleUser.UserID     = KeyID;
                        RoleUser.RoleID     = rolestr[i].ToInt(0);
                        RoleUser.IsEnabled  = true;
                        RoleUser.CreateUser = this.UserID.ToString();
                        RoleUser.CreateDate = DateTime.Now;
                        RoleUser.ts         = DateTime.Now;
                        RoleUser.dr         = 0;
                        RoleUserService.Add(RoleUser, Tran);
                    }
                }
            }
            new Hi.BLL.SYS_Users().Update(User, Tran);
            new Hi.BLL.SYS_CompUser().Update(CompUser, Tran);
            Tran.Commit();
            Response.Redirect("UserInfo.aspx?KeyId=" + Common.DesEncrypt(KeyID.ToString(), Common.EncryptKey));
        }
        else
        {
            if (Common.GetUserExists("UserName", txtUserName.Value.Trim()))
            {
                JScript.AlertMsgOne(this, "该登录帐号已存在!", JScript.IconOption.错误);
                return;
            }
            if (txtPhone.Value.Trim() == "")
            {
                JScript.AlertMsgOne(this, "手机号码不能为空!", JScript.IconOption.错误);
                return;
            }
            if (Common.GetUserExists("Phone", txtPhone.Value.Trim()))
            {
                JScript.AlertMsgOne(this, "该手机号码已存在!", JScript.IconOption.错误);
                return;
            }
            if (txtPwd.Text.Trim() != txtUserPwd.Text.Trim())
            {
                JScript.AlertMsgOne(this, "确认密码填写不一致!", JScript.IconOption.错误);
                return;
            }
            Tran          = DBUtility.SqlHelper.CreateStoreTranSaction();
            User          = new Hi.Model.SYS_Users();
            User.UserName = Common.NoHTML(txtUserName.Value.Trim());
            User.UserPwd  = Util.md5(txtUserPwd.Text.Trim());
            //User.UserLoginName = txtUserLoginName.Value.Trim();
            User.TrueName = Common.NoHTML(txtTrueName.Value.Trim());
            //User.Sex = rdSexYes.Checked ? "男" : "女";
            User.Phone = Common.NoHTML(txtPhone.Value.Trim());
            //User.Tel = txtTel.Value.Trim();
            User.Identitys    = Common.NoHTML(txtIdentitys.Value.Trim());
            User.Address      = Common.NoHTML(txtAddress.Value.Trim());
            User.Email        = Common.NoHTML(txtEmail.Value.Trim());
            User.IsEnabled    = rdEnabledYes.Checked ? 1 : 0;
            User.IsFirst      = 0;
            User.CreateDate   = DateTime.Now;
            User.CreateUserID = UserID;
            User.AuditUser    = UserID.ToString();
            User.ts           = DateTime.Now;
            User.modifyuser   = UserID;
            int userid = new Hi.BLL.SYS_Users().Add(User, Tran);
            CompUser              = new Hi.Model.SYS_CompUser();
            CompUser.CompID       = CompID;
            CompUser.DisID        = DisID;
            CompUser.CreateDate   = DateTime.Now;
            CompUser.CreateUserID = UserID;
            CompUser.modifyuser   = UserID;
            CompUser.CType        = 2;
            CompUser.UType        = 1;//用户类型
            CompUser.RoleID       = 0;
            CompUser.IsEnabled    = rdEnabledYes.Checked ? 1 : 0;
            CompUser.IsAudit      = 2;
            CompUser.ts           = DateTime.Now;
            CompUser.dr           = 0;
            CompUser.UserID       = userid;
            new Hi.BLL.SYS_CompUser().Add(CompUser, Tran);
            //岗位权限表
            if (hidMyRole.Value != "")
            {
                string[] rolestr = hidMyRole.Value.Split(',');
                foreach (string str in rolestr)
                {
                    if (str != "" && Convert.ToInt32(str) > 0)
                    {
                        RoleUser            = new Hi.Model.SYS_RoleUser();
                        RoleUser.FunType    = 1;
                        RoleUser.UserID     = userid;
                        RoleUser.RoleID     = Convert.ToInt32(str);
                        RoleUser.IsEnabled  = true;
                        RoleUser.CreateUser = this.UserID.ToString();
                        RoleUser.CreateDate = DateTime.Now;
                        RoleUser.ts         = DateTime.Now;
                        RoleUser.dr         = 0;
                        RoleUserService.Add(RoleUser, Tran);
                    }
                }
            }
            Tran.Commit();
            Response.Redirect("UserInfo.aspx?KeyId=" + Common.DesEncrypt(userid.ToString(), Common.EncryptKey));
            //this.Page.ClientScript.RegisterStartupScript(Page.GetType(), "msg", "<script>cancel()</script>");
        }
    }
Ejemplo n.º 11
0
    /// <summary>
    ///核心企业新增经销商
    /// </summary>
    /// <param name="JSon"></param>
    /// <returns></returns>
    public ReseltResellerEdit AddReseller(string JSon)
    {
        string UserID = string.Empty;
        string CompID = string.Empty;

        try
        {
            #region//JSon取值
            JsonData JInfo = JsonMapper.ToObject(JSon);
            if (JInfo["UserID"].ToString().Trim() == "" || JInfo["CompID"].ToString().Trim() == "" || JInfo["Reseller"].ToString().Trim() == "")
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "参数异常"
                       }
            }
            ;
            UserID = JInfo["UserID"].ToString();
            CompID = JInfo["CompID"].ToString();
            JsonData Reseller = JInfo["Reseller"];
            //判断登录信息是否异常
            Hi.Model.SYS_Users one = new Hi.Model.SYS_Users();
            if (!new Common().IsLegitUser(int.Parse(UserID), out one, Int32.Parse(CompID)))
            {
                return(new ReseltResellerEdit()
                {
                    Result = "F", Description = "登录信息异常"
                });
            }
            //判断核心企业信息是否异常
            Hi.Model.BD_Company comp = new Hi.BLL.BD_Company().GetModel(Int32.Parse(CompID));
            if (comp == null || comp.dr == 1 || comp.IsEnabled == 0 || comp.AuditState == 0)
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "核心企业信息异常"
                       }
            }
            ;
            #endregion
            #region//判断传入的经销商信息是否正确
            string resellername = Common.NoHTML(Reseller["ResellerName"].ToString().Trim());
            string resellercode = Common.NoHTML(Reseller["ResellerCode"].ToString().Trim());
            string address      = Common.NoHTML(Reseller["Address"].ToString().Trim());
            if (resellername == "")
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "请输入经销商名称"
                       }
            }
            ;
            //判断经销商名字是否已存在
            if (Common.DisExistsAttribute("DisName", resellername, CompID.ToString()))
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "经销商名称已经存在"
                       }
            }
            ;
            if (Reseller["ResellerProvince"].ToString().Trim() == "")
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "请选择经销商地址中的省"
                       }
            }
            ;
            if (Reseller["ResellerCity"].ToString().Trim() == "")
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "请选择经销商地址中的市"
                       }
            }
            ;
            if (Reseller["ResellerArea"].ToString().Trim() == "")
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "请选择经销商地址中的区"
                       }
            }
            ;
            if (address == "")
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "请输入经销商地址中的详细地址"
                       }
            }
            ;
            #endregion
            #region//判断登录信息的正确信
            JsonData account  = Reseller["Account"];
            string   username = Common.NoHTML(account["UserName"].ToString().Trim());
            string   truename = Common.NoHTML(account["TrueName"].ToString().Trim());
            if (account["UserName"].ToString().Trim() == "")
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "请输入登录账号"
                       }
            }
            ;
            //判断登录账号是否已经存在
            if (Common.GetUserExists(username))
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "该登录账号已存在"
                       }
            }
            ;
            if (truename == "")
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "请输入姓名"
                       }
            }
            ;
            if (account["Phone"].ToString().Trim() == "")
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "请登录信息中的手机号码"
                       }
            }
            ;
            //判断手机号有没被注册过
            Regex Phonereg = new Regex("^0?(13[0-9]|15[012356789]|18[0-9]|14[57]|17[7])[0-9]{8}$");
            if (!Phonereg.IsMatch(account["Phone"].ToString()))
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "登录信息中的手机号格式错误"
                       }
            }
            ;
            if (Common.GetUserExists("Phone", account["Phone"].ToString()))
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "登录信息中的手机号已被注册"
                       }
            }
            ;
            #endregion
            //创建需要导入的经销商实体
            Hi.Model.BD_Distributor disModel = new Hi.Model.BD_Distributor();
            disModel.CompID  = comp.ID;
            disModel.DisCode = resellercode;
            disModel.DisName = resellername;
            //传入分类ID的话,判断分类ID是否正确
            if (Reseller["ResellerClassifyID"].ToString().Trim() != "" && Reseller["ResellerClassifyID"].ToString() != "0")
            {
                Hi.Model.BD_DisType distpye = new Hi.BLL.BD_DisType().GetModel(Int32.Parse(Reseller["ResellerClassifyID"].ToString().Trim()));

                if (distpye == null || distpye.CompID != comp.ID)
                {
                    return new ReseltResellerEdit()
                           {
                               Result = "F", Description = "经销商分类异常"
                           }
                }
                ;
                if (distpye.dr == 1)
                {
                    return new ReseltResellerEdit()
                           {
                               Result = "F", Description = "此经销商分类已被删除"
                           }
                }
                ;
                //if (distpye.IsEnabled != 0)
                //    return new ReseltResellerEdit() { Result = "F", Description = "此经销商分类已被禁用" };

                disModel.DisTypeID = distpye.ID;
            }
            else
            {
                disModel.DisTypeID = 0;
            }
            //传入区域ID的话,判断区域ID是否正确
            if (Reseller["AreaID"].ToString().Trim() != "" && Reseller["AreaID"].ToString() != "0")
            {
                Hi.Model.BD_DisArea disarea = new Hi.BLL.BD_DisArea().GetModel(Int32.Parse(Reseller["AreaID"].ToString().Trim()));
                if (disarea == null || disarea.CompanyID != comp.ID)
                {
                    return new ReseltResellerEdit()
                           {
                               Result = "F", Description = "经销商区域异常"
                           }
                }
                ;
                if (disarea.dr == 1)
                {
                    return new ReseltResellerEdit()
                           {
                               Result = "F", Description = "此经销商区域已被删除"
                           }
                }
                ;
                disModel.AreaID = disarea.ID;
            }
            else
            {
                disModel.AreaID = 0;
            }
            disModel.DisLevel = "";
            disModel.Province = Reseller["ResellerProvince"].ToString();
            disModel.City     = Reseller["ResellerCity"].ToString();
            disModel.Area     = Reseller["ResellerArea"].ToString();
            disModel.Address  = address;
            //没输入经销商中的联系人,需要将登录信息的姓名赋值给联系人
            string principal = Common.NoHTML(Reseller["Principal"].ToString().Trim());
            string phone     = Common.NoHTML(Reseller["Phone"].ToString().Trim());
            if (principal == "")
            {
                disModel.Principal = truename;
            }
            else
            {
                disModel.Principal = principal;
            }
            //没输入联系人手机号,需要将登录信息中的手机号赋值给联系人手机号
            if (phone == "")
            {
                disModel.Phone = account["Phone"].ToString();
            }
            else
            {
                disModel.Phone = phone;
            }
            disModel.Leading      = "";
            disModel.LeadingPhone = "";
            disModel.Licence      = "";
            disModel.Tel          = Common.NoHTML(Reseller["Tel"].ToString());
            disModel.Zip          = Common.NoHTML(Reseller["Zip"].ToString());
            disModel.Fax          = Common.NoHTML(Reseller["Fax"].ToString());
            disModel.Remark       = "";
            disModel.DisAccount   = 0;
            disModel.IsCheck      = 1;
            disModel.CreditType   = 0;
            disModel.CreditAmount = 0;
            disModel.Paypwd       = Common.md5("123456");
            disModel.AuditState   = 2;
            disModel.IsEnabled    = 1;
            disModel.CreateUserID = one.ID;
            disModel.CreateDate   = DateTime.Now;
            disModel.ts           = DateTime.Now;
            disModel.dr           = 0;
            disModel.modifyuser   = one.ID;
            //开启事务,并将dismodel插入经销商表中
            SqlConnection conn = new SqlConnection(SqlHelper.LocalSqlServer);
            //开启数据库连接
            if (conn.State.ToString().ToLower() != "open")
            {
                conn.Open();
            }
            //开启事务
            SqlTransaction mytran = conn.BeginTransaction();
            int            DisID  = 0;
            try
            {
                //在经销商表中插入一条数据
                if ((DisID = new Hi.BLL.BD_Distributor().Add(disModel, mytran)) > 0)
                {
                    //经销商表插入成功的话继续新增角色
                    List <Hi.Model.SYS_Role> list_role = new Hi.BLL.SYS_Role().GetList("", "isnull(dr,0)=0 and isenabled=1 and DisID=" + DisID + " and RoleName='企业管理员'", "");

                    if (list_role == null || list_role.Count == 0)
                    {
                        //新增角色(企业管理员)
                        Hi.Model.SYS_Role role = new Hi.Model.SYS_Role();
                        role.CompID       = comp.ID;
                        role.DisID        = DisID;
                        role.RoleName     = "企业管理员";
                        role.IsEnabled    = 1;
                        role.SortIndex    = "1";
                        role.CreateDate   = DateTime.Now;
                        role.CreateUserID = one.ID;
                        role.ts           = DateTime.Now;
                        role.modifyuser   = one.ID;
                        role.dr           = 0;
                        int Roid = new Hi.BLL.SYS_Role().Add(role, mytran);
                        //新增管理员用户和角色
                        Hi.Model.SYS_Users user = new Hi.Model.SYS_Users();
                        user.UserName = username;
                        // user.CompID = CompID;
                        // user.Type = 5;
                        // user.RoleID = Roid;
                        user.TrueName     = truename;
                        user.UserPwd      = Common.md5("123456");
                        user.Phone        = account["Phone"].ToString();
                        user.AuditState   = 2;
                        user.IsEnabled    = 1;
                        user.CreateUserID = one.ID;
                        user.CreateDate   = DateTime.Now;
                        user.ts           = DateTime.Now;
                        user.modifyuser   = one.ID;
                        int AddUserid = new Hi.BLL.SYS_Users().Add(user, mytran);
                        ///用户明细表
                        Hi.Model.SYS_CompUser CompUser = new Hi.Model.SYS_CompUser();
                        CompUser.CompID       = comp.ID;
                        CompUser.DisID        = DisID;
                        CompUser.CreateDate   = DateTime.Now;
                        CompUser.CreateUserID = one.ID;
                        CompUser.modifyuser   = one.ID;
                        CompUser.CType        = 2;
                        CompUser.UType        = 5;
                        CompUser.IsEnabled    = 1;
                        CompUser.IsAudit      = 2;
                        CompUser.RoleID       = 0;
                        CompUser.ts           = DateTime.Now;
                        CompUser.dr           = 0;
                        CompUser.UserID       = AddUserid;
                        int compuserid = new Hi.BLL.SYS_CompUser().Add(CompUser, mytran);
                        //新增角色用户
                        Hi.Model.SYS_RoleUser RoleUser = new Hi.Model.SYS_RoleUser();
                        RoleUser.FunType    = 1;
                        RoleUser.UserID     = AddUserid;
                        RoleUser.RoleID     = Roid;
                        RoleUser.IsEnabled  = true;
                        RoleUser.CreateUser = UserID;
                        RoleUser.CreateDate = DateTime.Now;
                        RoleUser.ts         = DateTime.Now;
                        RoleUser.dr         = 0;
                        int roleuserid = new Hi.BLL.SYS_RoleUser().Add(RoleUser, mytran);
                        //新增角色权限表
                        Hi.Model.SYS_RoleSysFun    rolesys = null;
                        List <Hi.Model.SYS_SysFun> funList = new Hi.BLL.SYS_SysFun().GetList("", " Type=2", "");
                        foreach (Hi.Model.SYS_SysFun sys in funList)
                        {
                            rolesys              = new Hi.Model.SYS_RoleSysFun();
                            rolesys.CompID       = comp.ID;
                            rolesys.DisID        = DisID;
                            rolesys.RoleID       = Roid;
                            rolesys.FunCode      = sys.FunCode;
                            rolesys.FunName      = sys.FunName;
                            rolesys.IsEnabled    = 1;
                            rolesys.CreateUserID = one.ID;
                            rolesys.CreateDate   = DateTime.Now;
                            rolesys.ts           = DateTime.Now;
                            rolesys.modifyuser   = one.ID;
                            if (new Hi.BLL.SYS_RoleSysFun().Add(rolesys, mytran) <= 0)
                            {
                                mytran.Rollback();
                                return(new ReseltResellerEdit()
                                {
                                    Result = "F", Description = "新增失败"
                                });
                            }
                        }
                        //新增收货地址
                        Hi.Model.BD_DisAddr addr = new Hi.Model.BD_DisAddr();
                        addr.Province     = disModel.Province;
                        addr.City         = disModel.City;
                        addr.Area         = disModel.Area;
                        addr.DisID        = DisID;
                        addr.Principal    = disModel.Principal;
                        addr.Phone        = disModel.Phone;
                        addr.Address      = disModel.Province + disModel.City + disModel.Area + disModel.Address;
                        addr.IsDefault    = 1;
                        addr.ts           = DateTime.Now;
                        addr.CreateDate   = DateTime.Now;
                        addr.CreateUserID = one.ID;
                        addr.modifyuser   = one.ID;
                        int addrid = new Hi.BLL.BD_DisAddr().Add(addr, mytran);
                        //判断所有表是否都插入成功了吗
                        if (Roid <= 0 || AddUserid <= 0 || compuserid <= 0 || roleuserid <= 0 || addrid <= 0)
                        {
                            mytran.Rollback();
                            return(new ReseltResellerEdit()
                            {
                                Result = "F", Description = "新增失败"
                            });
                        }
                    }
                    else
                    {
                        mytran.Rollback();
                        return(new ReseltResellerEdit()
                        {
                            Result = "F", Description = "新增失败"
                        });
                    }
                }
                else
                {
                    mytran.Rollback();
                    return(new ReseltResellerEdit()
                    {
                        Result = "F", Description = "新增失败"
                    });
                }
                mytran.Commit();
            }
            catch (Exception ex)
            {
                mytran.Rollback();
                Common.CatchInfo(ex.Message + ":" + ex.StackTrace, "AddReseller:" + JSon);
                return(new ReseltResellerEdit()
                {
                    Result = "F", Description = "新增失败"
                });
            }
            finally
            {
                conn.Close();
                mytran.Dispose();
            }
            return(new ReseltResellerEdit()
            {
                Result = "T", Description = "新增成功"
            });
        }
        catch (Exception ex)
        {
            Common.CatchInfo(ex.Message + ":" + ex.StackTrace, "AddReseller:" + JSon);
            return(new ReseltResellerEdit()
            {
                Result = "F", Description = "新增失败"
            });
        }
    }
Ejemplo n.º 12
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.º 13
0
    public static string Edit(string KeyID, string Remark, string DisAreaID, string CompID, string UserID)
    {
        Common.ResultMessage   Msg     = new Common.ResultMessage();
        Hi.Model.YZT_FirstCamp fcmodel = new Hi.BLL.YZT_FirstCamp().GetModel(KeyID.ToInt(0));

        List <Hi.Model.YZT_Annex> annlist = new Hi.BLL.YZT_Annex().GetList("", " fcID=" + KeyID + " and type=2 and fileAlias='2' ", "");

        if (annlist != null && annlist.Count <= 0)
        {
            Msg.code = "请先上传授权书";
        }
        else
        {
            if (fcmodel != null)
            {
                //判断是否是该厂商的代理商
                List <Hi.Model.SYS_CompUser> compulist = new Hi.BLL.SYS_CompUser().GetList("", " UserID=" + fcmodel.CreateUserID + " and CompID=" + CompID + " and DisID=" + fcmodel.DisID + "", "");

                Hi.Model.BD_Company comp = new Hi.BLL.BD_Company().GetModel(CompID.ToInt(0));
                string compName          = comp == null ? "" : comp.CompName;

                SqlTransaction Tran = DBUtility.SqlHelper.CreateStoreTranSaction();

                fcmodel.AreaID = DisAreaID.ToInt(0);
                fcmodel.Remark = Remark;
                fcmodel.State  = 2;
                fcmodel.ts     = DateTime.Now;

                if (new Hi.BLL.YZT_FirstCamp().Update(fcmodel, Tran))
                {
                    if (compulist != null && compulist.Count <= 0)
                    {
                        Hi.Model.SYS_Users usersModel = new Hi.BLL.SYS_Users().GetModel(fcmodel.CreateUserID);
                        string             Phone      = usersModel == null ? "" : usersModel.Phone;
                        string             UserName   = usersModel == null ? "" : usersModel.UserName;

                        Hi.Model.SYS_CompUser compuser = new Hi.Model.SYS_CompUser();
                        compuser.UserID       = fcmodel.CreateUserID;
                        compuser.CompID       = CompID.ToInt(0);
                        compuser.DisID        = fcmodel.DisID;
                        compuser.AreaID       = DisAreaID.ToInt(0);
                        compuser.RoleID       = usersModel == null ? 0 : usersModel.RoleID;
                        compuser.CType        = 2;
                        compuser.UType        = 5;
                        compuser.IsAudit      = 2;
                        compuser.IsEnabled    = 1;
                        compuser.ts           = DateTime.Now;
                        compuser.CreateUserID = UserID.ToInt(0);
                        compuser.modifyuser   = UserID.ToInt(0);
                        compuser.CreateDate   = DateTime.Now;

                        if (new Hi.BLL.SYS_CompUser().Add(compuser, Tran) > 0)
                        {
                            Tran.Commit();
                            Msg.result = true;

                            GetPhoneCode pc = new GetPhoneCode();
                            pc.SendConfirm(Phone, compName, UserName);
                        }
                        else
                        {
                            Tran.Rollback();
                            Msg.code = "用户信息添加失败";
                        }
                    }
                    else
                    {
                        Hi.Model.SYS_CompUser compuser = compulist[0];
                        compuser.IsAudit    = 2;
                        compuser.AreaID     = DisAreaID.ToInt(0);
                        compuser.ts         = DateTime.Now;
                        compuser.modifyuser = UserID.ToInt(0);

                        if (new Hi.BLL.SYS_CompUser().Update(compuser, Tran))
                        {
                            Tran.Commit();
                            Msg.result = true;

                            Hi.Model.SYS_Users usersModel = new Hi.BLL.SYS_Users().GetModel(compulist[0].UserID);
                            string             Phone      = usersModel == null ? "" : usersModel.Phone;
                            string             UserName   = usersModel == null ? "" : usersModel.UserName;

                            GetPhoneCode pc = new GetPhoneCode();
                            pc.SendConfirm(Phone, compName, UserName);
                        }
                        else
                        {
                            Tran.Rollback();
                            Msg.code = "用户信息添加失败";
                        }
                    }
                }
                else
                {
                    Tran.Rollback();
                    Msg.code = "通过失败";
                }
            }
            else
            {
                Msg.code = "未查找到数据";
            }
        }
        return(new JavaScriptSerializer().Serialize(Msg));
    }
Ejemplo n.º 14
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        #region 没有优化岗位权限前的代码
        //SqlTransaction Tran = DBUtility.SqlHelper.CreateStoreTranSaction();
        //Hi.Model.SYS_Users User = null;
        //if (KeyID != 0)
        //{
        //    //修改
        //    int userid = KeyID;
        //    User = new Hi.BLL.SYS_Users().GetModel(userid);
        //    if (Common.GetUserExists("UserName", txtUserName.Value.Trim(), userid.ToString()))
        //    {
        //        JScript.AlertMsgOne(this, "该登录帐号已存在!", JScript.IconOption.错误);
        //        return;
        //    }
        //    if (Common.GetUserExists("Phone", txtPhone.Value.Trim(), userid.ToString()))
        //    {
        //        JScript.AlertMsgOne(this, "该手机号码已存在!", JScript.IconOption.错误);
        //        return;
        //    }
        //    if (txtPwd.Text.Trim() != txtUserPwd.Text.Trim())
        //    {
        //        JScript.AlertMsgOne(this, "确认密码填写不一致!", JScript.IconOption.错误);
        //        return;
        //    }

        //    List<Hi.Model.SYS_CompUser> ListCompUser = new Hi.BLL.SYS_CompUser().GetList("", " CompID="+CompID+" AND UserID="+KeyID+" AND dr=0 AND IsEnabled=1 ", "");
        //    if (ListCompUser.Count == 0)
        //    {
        //        JScript.AlertMethod(this, "员工帐号信息有误!", JScript.IconOption.错误, "function (){ history.go(-1) ; }");
        //        return;
        //    }
        //    if (ListCompUser[0].UType != 4)
        //    {
        //        User.UserName = txtUserName.Value.Trim();
        //        User.Phone = txtPhone.Value.Trim();
        //    }
        //    if (rdEnabledNo.Checked)
        //    {
        //        if (ListCompUser[0].UType == 4)
        //        {
        //            JScript.AlertMsgOne(this, "用户为系统管理员,不可禁用!", JScript.IconOption.错误);
        //            return;
        //        }
        //    }
        //    User.TrueName = txtTrueName.Value.Trim();
        //    User.Identitys = txtIdentitys.Value.Trim();
        //    User.Address = txtAddress.Value.Trim();
        //    User.Email = txtEmail.Value.Trim();
        //    ListCompUser[0].IsEnabled = rdEnabledYes.Checked ? 1 : 0;
        //    ListCompUser[0].ts = DateTime.Now;
        //    ListCompUser[0].modifyuser = UserID;
        //    if (txtUserPwd.Text.Trim() != Util.md5("123456"))
        //    {
        //        User.UserPwd = Util.md5(txtUserPwd.Text.Trim());
        //    }
        //    User.ts = DateTime.Now;
        //    User.modifyuser = UserID;
        //    List<Hi.Model.SYS_RoleUser> list = new Hi.BLL.SYS_RoleUser().GetList("", " dr=0 and IsEnabled=1 and UserID=" + KeyID + "", "");
        //    if (list.Count > 0)
        //    {
        //        for (int i = 0; i < list.Count; i++)
        //        {
        //            Hi.Model.SYS_RoleUser roleu = new Hi.Model.SYS_RoleUser();
        //            roleu.ID = list[0].ID;
        //            roleu.FunType = list[0].FunType;
        //            roleu.UserID = list[0].UserID;
        //            roleu.RoleID = list[0].RoleID;
        //            roleu.IsEnabled = true;//禁用
        //            roleu.CreateUser = list[0].CreateUser;
        //            roleu.CreateDate = list[0].CreateDate;
        //            roleu.ts = DateTime.Now;
        //            roleu.dr = list[0].dr;
        //            bool sss = new Hi.BLL.SYS_RoleUser().Update(roleu);
        //        }
        //    }
        //    else
        //    {
        //        //岗位权限表
        //        if (hidMyRole.Value != "")
        //        {
        //            string[] rolestr = hidMyRole.Value.Split(',');
        //            Hi.BLL.SYS_RoleUser RoleUserService = new Hi.BLL.SYS_RoleUser();
        //            Hi.Model.SYS_RoleUser RoleUser = null;
        //            foreach (string str in rolestr)
        //            {
        //                if (str != "" && Convert.ToInt32(str) > 0)
        //                {
        //                    RoleUser = new Hi.Model.SYS_RoleUser();
        //                    RoleUser.FunType = 1;
        //                    RoleUser.UserID = userid;
        //                    RoleUser.RoleID = Convert.ToInt32(str);
        //                    RoleUser.IsEnabled = true;
        //                    RoleUser.CreateUser = this.UserID.ToString();
        //                    RoleUser.CreateDate = DateTime.Now;
        //                    RoleUser.ts = DateTime.Now;
        //                    RoleUser.dr = 0;
        //                    RoleUserService.Add(RoleUser, Tran);
        //                }
        //            }
        //        }
        //    }
        //    new Hi.BLL.SYS_Users().Update(User, Tran);
        //    new Hi.BLL.SYS_CompUser().Update(ListCompUser[0], Tran);
        //    Tran.Commit();
        //    JScript.AlertMethod(this, "操作成功!", JScript.IconOption.正确, "UserInfo.aspx?KeyId="+KeyID);
        //}
        //else
        //{
        //    //新增
        //    if (Common.GetUserExists("UserName", txtUserName.Value.Trim()))
        //    {
        //        JScript.AlertMsgOne(this, "该登录帐号已存在!", JScript.IconOption.错误);
        //        return;
        //    }
        //    if (Common.GetUserExists("Phone", txtPhone.Value.Trim()))
        //    {
        //        JScript.AlertMsgOne(this, "该手机号码已存在!", JScript.IconOption.错误);
        //        return;
        //    }
        //    if (txtPwd.Text.Trim() != txtUserPwd.Text.Trim())
        //    {
        //        JScript.AlertMsgOne(this, "确认密码填写不一致!", JScript.IconOption.错误);
        //        return;
        //    }
        //    User = new Hi.Model.SYS_Users();
        //    User.CompID = CompID;//厂商ID
        //    User.DisID = 0;
        //    User.Type = 3;
        //    User.AuditState = 2;
        //    User.UserName = txtUserName.Value.Trim();
        //    User.UserPwd = Util.md5(txtUserPwd.Text.Trim());
        //    User.TrueName = txtTrueName.Value.Trim();
        //    User.Phone = txtPhone.Value.Trim();
        //    User.Identitys = txtIdentitys.Value.Trim();
        //    User.Address = txtAddress.Value.Trim();
        //    User.Email = txtEmail.Value.Trim();
        //    User.IsEnabled = rdEnabledYes.Checked ? 1 : 0;
        //    User.IsFirst = 0;
        //    User.CreateDate = DateTime.Now;
        //    User.CreateUserID = UserID;
        //    User.AuditUser = UserID.ToString();
        //    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 = CompID;
        //    CompUser.DisID = 0;
        //    CompUser.CreateDate = DateTime.Now;
        //    CompUser.CreateUserID = UserID;
        //    CompUser.modifyuser = UserID;
        //    CompUser.CType = 1;
        //    CompUser.UType = 3;
        //    CompUser.RoleID = 0;//权限屏蔽掉
        //    CompUser.IsEnabled = rdEnabledYes.Checked ? 1 : 0;
        //    CompUser.IsAudit = 2;
        //    CompUser.ts = DateTime.Now;
        //    CompUser.dr = 0;
        //    CompUser.UserID = userid;
        //    new Hi.BLL.SYS_CompUser().Add(CompUser, Tran);
        //    //岗位权限表
        //    if (hidMyRole.Value != "")
        //    {
        //        string[] rolestr = hidMyRole.Value.Split(',');
        //        Hi.BLL.SYS_RoleUser RoleUserService = new Hi.BLL.SYS_RoleUser();
        //        Hi.Model.SYS_RoleUser RoleUser = null;
        //        foreach (string str in rolestr)
        //        {
        //            if (str != "" && Convert.ToInt32(str) > 0)
        //            {
        //                RoleUser = new Hi.Model.SYS_RoleUser();
        //                RoleUser.FunType = 1;
        //                RoleUser.UserID = userid;
        //                RoleUser.RoleID = Convert.ToInt32(str);
        //                RoleUser.IsEnabled = true;
        //                RoleUser.CreateUser = this.UserID.ToString();
        //                RoleUser.CreateDate = DateTime.Now;
        //                RoleUser.ts = DateTime.Now;
        //                RoleUser.dr = 0;
        //                RoleUserService.Add(RoleUser, Tran);
        //            }
        //        }
        //    }
        //    Tran.Commit();
        //    //this.Page.ClientScript.RegisterStartupScript(Page.GetType(), "msg", "<script>cancel()</script>");
        //    Response.Redirect("UserInfo.aspx?KeyId=" + userid);
        //}
        #endregion
        Hi.Model.SYS_Users    User            = null;
        Hi.Model.SYS_CompUser CompUser        = null;
        Hi.Model.SYS_RoleUser RoleUser        = null;
        Hi.BLL.SYS_RoleUser   RoleUserService = new Hi.BLL.SYS_RoleUser();
        if (KeyID != 0)
        {
            SqlTransaction Tran = DBUtility.SqlHelper.CreateStoreTranSaction();
            //修改
            User     = new Hi.BLL.SYS_Users().GetModel(KeyID);
            CompUser = new Hi.Model.SYS_CompUser();
            if (User.UserName != txtUserName.Value.Trim())
            {
                if (Common.GetUserExists("UserName", txtUserName.Value.Trim()))
                {
                    JScript.AlertMsgOne(this, "该登录帐号已存在!", JScript.IconOption.错误);
                    return;
                }
            }
            if (User.Phone != txtPhone.Value.Trim())
            {
                if (txtPhone.Value.Trim() == "")
                {
                    JScript.AlertMsgOne(this, "手机号码不能为空!", JScript.IconOption.错误);
                    return;
                }
                if (Common.GetUserExists("Phone", txtPhone.Value.Trim()))
                {
                    JScript.AlertMsgOne(this, "该手机号码已存在!", JScript.IconOption.错误);
                    return;
                }
            }
            if (txtPwd.Text.Trim() != txtUserPwd.Text.Trim())
            {
                JScript.AlertMsgOne(this, "确认密码填写不一致!", JScript.IconOption.错误);
                return;
            }
            List <Hi.Model.SYS_CompUser> ListCompUser = new Hi.BLL.SYS_CompUser().GetList("*", " CompID=" + CompID + " AND UserID=" + KeyID + " AND dr=0 AND IsEnabled=1 ", "");
            CompUser = ListCompUser[0];
            //禁用时判断
            if (rdEnabledNo.Checked)
            {
                if (ListCompUser[0].UType == 4)
                {
                    JScript.AlertMsgOne(this, "用户为管理员,不可禁用!", JScript.IconOption.错误);
                    return;
                }
                else
                {
                    User.IsEnabled     = 0;
                    CompUser.IsEnabled = 0;
                    List <Hi.Model.SYS_RoleUser> roleusers = new Hi.BLL.SYS_RoleUser().GetList("", " UserID=" + KeyID + " AND dr=0 ", "");
                    if (roleusers.Count > 0)
                    {
                        for (int i = 0; i < roleusers.Count; i++)
                        {
                            roleusers[i].IsEnabled = false;
                        }
                    }
                }
            }
            if (rdEnabledYes.Checked)
            {
                User.IsEnabled     = 1;
                CompUser.IsEnabled = 1;
            }
            User.UserName  = Common.NoHTML(txtUserName.Value.Trim());
            User.TrueName  = Common.NoHTML(txtTrueName.Value.Trim());
            User.Identitys = Common.NoHTML(txtIdentitys.Value.Trim());
            if (txtPwd.Text.Trim() != User.UserPwd)
            {
                User.UserPwd = Util.md5(txtUserPwd.Text.Trim());
            }
            User.Address    = Common.NoHTML(txtAddress.Value.Trim());
            User.Email      = Common.NoHTML(txtEmail.Value.Trim());
            User.Type       = 3;
            User.ts         = DateTime.Now;
            User.modifyuser = UserID;
            if (DisSalesManID.Value != "0")
            {
                if (CompUser.UType == 4)
                {
                    JScript.AlertMsgOne(this, "用户为管理员,不可修改类型!", JScript.IconOption.错误);
                    return;
                }
                CompUser.UType         = 6;
                CompUser.DisSalesManID = Convert.ToInt32(DisSalesManID.Value);
            }
            else
            {
                if (CompUser.UType == 4)
                {
                    CompUser.UType = 4;
                }
                else
                {
                    CompUser.UType = 3;
                }

                CompUser.DisSalesManID = 0;
            }


            //岗位权限表
            List <Hi.Model.SYS_RoleUser> roleuser = new Hi.BLL.SYS_RoleUser().GetList("", "  UserID=" + KeyID + "  AND dr=0 ", "");
            for (int i = 0; i < roleuser.Count; i++)
            {
                roleuser[i].IsEnabled = false;
                roleuser[i].ts        = DateTime.Now;
                RoleUserService.Update(roleuser[i]);
            }
            if (hidMyRole.Value != "")
            {
                string[] rolestr = hidMyRole.Value.Substring(0, hidMyRole.Value.Length - 1).Split(',');
                for (int i = 0; i < rolestr.Length; i++)
                {
                    List <Hi.Model.SYS_RoleUser> rolenew = new Hi.BLL.SYS_RoleUser().GetList("", "  UserID=" + KeyID + " AND dr=0 AND RoleID=" + rolestr[i].ToInt(0) + " ", "");
                    if (rolenew.Count > 0)
                    {
                        rolenew[0].IsEnabled = true;
                        rolenew[0].ts        = DateTime.Now;
                        RoleUserService.Update(rolenew[0]);
                    }
                    else
                    {
                        RoleUser            = new Hi.Model.SYS_RoleUser();
                        RoleUser.FunType    = 1;
                        RoleUser.UserID     = KeyID;
                        RoleUser.RoleID     = rolestr[i].ToInt(0);
                        RoleUser.IsEnabled  = true;
                        RoleUser.CreateUser = this.UserID.ToString();
                        RoleUser.CreateDate = DateTime.Now;
                        RoleUser.ts         = DateTime.Now;
                        RoleUser.dr         = 0;
                        RoleUserService.Add(RoleUser, Tran);
                    }
                }
            }
            new Hi.BLL.SYS_Users().Update(User, Tran);
            new Hi.BLL.SYS_CompUser().Update(CompUser, Tran);
            Tran.Commit();
            Response.Redirect("UserInfo.aspx?KeyId=" + Common.DesEncrypt(KeyID.ToString(), Common.EncryptKey));
        }
        else
        {
            SqlTransaction Tran = DBUtility.SqlHelper.CreateStoreTranSaction();
            //新增
            if (Common.GetUserExists("UserName", txtUserName.Value.Trim()))
            {
                JScript.AlertMsgOne(this, "该登录帐号已存在!", JScript.IconOption.错误);
                return;
            }
            if (txtPhone.Value.Trim() == "")
            {
                JScript.AlertMsgOne(this, "手机号码不能为空!", JScript.IconOption.错误);
                return;
            }
            if (Common.GetUserExists("Phone", txtPhone.Value.Trim()))
            {
                JScript.AlertMsgOne(this, "该手机号码已存在!", JScript.IconOption.错误);
                return;
            }
            if (txtPwd.Text.Trim() != txtUserPwd.Text.Trim())
            {
                JScript.AlertMsgOne(this, "确认密码填写不一致!", JScript.IconOption.错误);
                return;
            }
            User              = new Hi.Model.SYS_Users();
            User.CompID       = CompID;//厂商ID
            User.DisID        = 0;
            User.AuditState   = 2;
            User.UserName     = Common.NoHTML(txtUserName.Value.Trim());
            User.UserPwd      = Util.md5(txtUserPwd.Text.Trim());
            User.TrueName     = Common.NoHTML(txtTrueName.Value.Trim());
            User.Phone        = Common.NoHTML(txtPhone.Value.Trim());
            User.Identitys    = Common.NoHTML(txtIdentitys.Value.Trim());
            User.Address      = Common.NoHTML(txtAddress.Value.Trim());
            User.Email        = Common.NoHTML(txtEmail.Value.Trim());
            User.IsEnabled    = rdEnabledYes.Checked ? 1 : 0;
            User.IsFirst      = 0;
            User.CreateDate   = DateTime.Now;
            User.CreateUserID = UserID;
            User.AuditUser    = UserID.ToString();
            User.ts           = DateTime.Now;
            User.modifyuser   = UserID;
            int userid = new Hi.BLL.SYS_Users().Add(User, Tran);
            //多角色表
            CompUser              = new Hi.Model.SYS_CompUser();
            CompUser.CompID       = CompID;
            CompUser.DisID        = 0;
            CompUser.CreateDate   = DateTime.Now;
            CompUser.CreateUserID = UserID;
            CompUser.modifyuser   = UserID;
            CompUser.CType        = 1;
            if (DisSalesManID.Value != "0")
            {
                CompUser.UType         = 6;
                CompUser.DisSalesManID = Convert.ToInt32(DisSalesManID.Value);
            }
            else
            {
                CompUser.UType = 3;
            }
            CompUser.RoleID    = 0;//权限屏蔽掉
            CompUser.IsEnabled = rdEnabledYes.Checked ? 1 : 0;
            CompUser.IsAudit   = 2;
            CompUser.ts        = DateTime.Now;
            CompUser.dr        = 0;
            CompUser.UserID    = userid;
            new Hi.BLL.SYS_CompUser().Add(CompUser, Tran);
            //岗位权限表
            if (hidMyRole.Value != "")
            {
                string[] rolestr = hidMyRole.Value.Split(',');
                foreach (string str in rolestr)
                {
                    if (str != "" && Convert.ToInt32(str) > 0)
                    {
                        RoleUser            = new Hi.Model.SYS_RoleUser();
                        RoleUser.FunType    = 1;
                        RoleUser.UserID     = userid;
                        RoleUser.RoleID     = Convert.ToInt32(str);
                        RoleUser.IsEnabled  = true;
                        RoleUser.CreateUser = this.UserID.ToString();
                        RoleUser.CreateDate = DateTime.Now;
                        RoleUser.ts         = DateTime.Now;
                        RoleUser.dr         = 0;
                        RoleUserService.Add(RoleUser, Tran);
                    }
                }
            }
            Tran.Commit();
            Response.Redirect("UserInfo.aspx?KeyId=" + Common.DesEncrypt(userid.ToString(), Common.EncryptKey));
        }
    }
Ejemplo n.º 15
0
    private bool RegisterDistributor(string distributorName, string phone, string password, SqlTransaction Tran)
    {
        try
        {
            int Compid = 0;
            int UserID = 0;

            Hi.Model.BD_Distributor Distributor = new Hi.Model.BD_Distributor();
            Distributor.CompID       = Compid;
            Distributor.DisName      = distributorName;
            Distributor.IsEnabled    = 1;
            Distributor.Paypwd       = new GetPhoneCode().md5(password);
            Distributor.Phone        = phone;
            Distributor.AuditState   = 2;
            Distributor.CreateDate   = DateTime.Now;
            Distributor.CreateUserID = UserID;
            Distributor.ts           = DateTime.Now;
            Distributor.modifyuser   = UserID;
            Distributor.IsCheck      = 0;
            Distributor.CreditType   = 0;

            int DistributorID = 0;

            if ((DistributorID = new Hi.BLL.BD_Distributor().Add(Distributor, Tran)) > 0)
            {
                int Roid = 0;

                //新增角色(企业管理员)
                Hi.Model.SYS_Role role = new Hi.Model.SYS_Role();
                role.CompID       = Compid;
                role.DisID        = DistributorID;
                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;
                Roid = new Hi.BLL.SYS_Role().Add(role, Tran);

                //新增角色权限表
                Hi.Model.SYS_RoleSysFun    rolesys = null;
                List <Hi.Model.SYS_SysFun> funList = new Hi.BLL.SYS_SysFun().GetList("FunCode,FunName", " Type=2", "");
                foreach (Hi.Model.SYS_SysFun sys in funList)
                {
                    rolesys              = new Hi.Model.SYS_RoleSysFun();
                    rolesys.CompID       = Compid;
                    rolesys.DisID        = DistributorID;
                    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.SYS_Users user = new Hi.Model.SYS_Users();
                user.UserName     = phone;
                user.TrueName     = phone;
                user.DisID        = DistributorID;
                user.TrueName     = "";
                user.UserPwd      = new GetPhoneCode().md5(password);
                user.IsEnabled    = 1;
                user.Phone        = phone;
                user.CreateDate   = DateTime.Now;
                user.CreateUserID = UserID;
                user.ts           = DateTime.Now;
                user.modifyuser   = UserID;
                user.AuditState   = 2;
                int userid = 0;
                userid = new Hi.BLL.SYS_Users().Add(user, Tran);

                ///用户明细表
                Hi.Model.SYS_CompUser CompUser = new Hi.Model.SYS_CompUser();
                CompUser.CompID       = Compid;
                CompUser.DisID        = DistributorID;
                CompUser.CreateDate   = DateTime.Now;
                CompUser.CreateUserID = UserID;
                CompUser.modifyuser   = UserID;
                CompUser.CType        = 2;
                CompUser.UType        = 5;
                //CompUser.IsEnabled = 1;
                CompUser.IsAudit   = 2;
                CompUser.RoleID    = Roid;
                CompUser.ts        = DateTime.Now;
                CompUser.dr        = 0;
                CompUser.UserID    = userid;
                CompUser.IsEnabled = 1;
                new Hi.BLL.SYS_CompUser().Add(CompUser, Tran);
            }
            else
            {
                return(false);
            }
            Tran.Commit();
            return(true);
        }
        catch (Exception)
        {
            if (Tran != null && Tran.Connection != null)
            {
                Tran.Rollback();
            }
            return(false);
        }
        finally
        {
            if (Tran != null && Tran.Connection != null)
            {
                Tran.Rollback();
            }
        }
    }
Ejemplo n.º 16
0
    //public string GetPhoto()
    //{
    //    try
    //    {
    //        string code = CreateVerifyCode();
    //        Bitmap photo = CreateImageCode(code);
    //        byte[] b_photo = null;
    //        MemoryStream stream = new MemoryStream();
    //        using (photo)
    //        {
    //            photo.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
    //        }
    //        photo.Dispose();
    //        using (stream)
    //        {
    //            b_photo = stream.GetBuffer();
    //        }
    //        //stream.Dispose();
    //        stream.Close();
    //        string PhotoUrl = Convert.ToBase64String(b_photo, 0, b_photo.Length);
    //        return PhotoUrl;

    //    }
    //    catch (Exception ex)
    //    {
    //        return ex.ToString();
    //    }
    //}

    //public void write()
    //{
    //    string PhotoUrl = GetPhoto();
    //    byte[] b = Convert.FromBase64String(PhotoUrl);
    //    FileStream fs = new FileStream(@"F:/QQ文件/IMG_14.JPG",FileMode.Create,FileAccess.Write);
    //    fs.Write(b,0,b.Length);
    //    fs.Flush();
    //    fs.Close();
    //}


    //核心企业提交入驻申请
    #region
    public ResultCompEnter SendEnterRequest(string JSon, string version)
    {
        string PhoneNumb   = string.Empty;
        string LoginName   = string.Empty;
        string PassWord    = string.Empty;
        string CompanyName = string.Empty;
        string Captcha     = string.Empty;
        string SendId      = string.Empty;
        string Type        = string.Empty;
        int    compid      = 0;

        try
        {
            #region//JSon取值
            JsonData JInfo = JsonMapper.ToObject(JSon);
            if (JInfo.Count > 0 && JInfo["PhoneNumb"].ToString().Trim() != "" && JInfo["LoginName"].ToString().Trim() != "" && JInfo["Captcha"].ToString().Trim() != "" &&
                JInfo["PassWord"].ToString().Trim() != "" && JInfo["CompanyName"].ToString().Trim() != "" && JInfo["SendId"].ToString().Trim() != "" &&
                JInfo["Type"].ToString().Trim() != "")
            {
                PhoneNumb = Common.NoHTML(JInfo["PhoneNumb"].ToString());
                LoginName = Common.NoHTML(JInfo["LoginName"].ToString());
                if (LoginName != JInfo["LoginName"].ToString())
                {
                    return new ResultCompEnter()
                           {
                               Result = "F", Description = "用户名存在非法字符串"
                           }
                }
                ;
                PassWord    = JInfo["PassWord"].ToString();
                CompanyName = Common.NoHTML(JInfo["CompanyName"].ToString());
                Captcha     = JInfo["Captcha"].ToString();
                SendId      = JInfo["SendId"].ToString();
                Type        = JInfo["Type"].ToString();
            }
            else
            {
                return(new ResultCompEnter()
                {
                    Result = "F", Description = "参数异常"
                });
            }
            #endregion
            #region//验证验证码是否有效
            Hi.Model.SYS_PhoneCode code = new Hi.BLL.SYS_PhoneCode().GetModel(int.Parse(SendId));
            if (code != null && code.dr == 0)
            {
                if (code.ts.AddMinutes(30) < DateTime.Now || code.IsPast == 1)
                {
                    return new ResultCompEnter()
                           {
                               Result = "F", Description = "验证码过期"
                           }
                }
                ;

                if (code.PhoneCode != Captcha)
                {
                    return new ResultCompEnter()
                           {
                               Result = "F", Description = "验证码错误"
                           }
                }
                ;
            }
            else
            {
                return(new ResultCompEnter()
                {
                    Result = "F", Description = "验证码不可用"
                });
            }
            code.IsPast     = 1;
            code.ts         = DateTime.Now;
            code.modifyuser = 0;
            SqlConnection conn = new SqlConnection(SqlHelper.LocalSqlServer);
            if (conn.State.ToString().ToLower() != "open")
            {
                conn.Open();
            }
            SqlTransaction mytran = conn.BeginTransaction();

            #endregion
            //如果验证码正确的话,修改验证码状态
            try
            {
                if (new Hi.BLL.SYS_PhoneCode().Update(code, mytran))//验证码状态修改成功的话,开始进行注册流程
                {
                    if (Type == "distributor")
                    {
                        Boolean result = RegisterDistributor(CompanyName, PhoneNumb, PassWord, mytran);
                        if (result)
                        {
                            return(new ResultCompEnter()
                            {
                                Result = "T", Description = "注册成功"
                            });
                        }
                        else
                        {
                            return(new ResultCompEnter()
                            {
                                Result = "F", Description = "注册用户失败"
                            });
                        }
                    }
                    else
                    {
                        //首先在bd_company表中新增一条数据
                        Hi.Model.BD_Company comp = new Hi.Model.BD_Company();
                        comp.CompName     = CompanyName;
                        comp.LegalTel     = PhoneNumb;
                        comp.Phone        = PhoneNumb;
                        comp.AuditState   = 0;
                        comp.IsEnabled    = 1;
                        comp.FirstShow    = 1;
                        comp.Erptype      = 0;
                        comp.SortIndex    = "001";
                        comp.HotShow      = 1;
                        comp.CreateDate   = DateTime.Now;
                        comp.CreateUserID = 0;
                        comp.ts           = DateTime.Now;
                        comp.modifyuser   = 0;
                        compid            = new Hi.BLL.BD_Company().Add(comp, mytran);
                        //bd_company表中数据新增成功后,在sys_users表中新增一条数据
                        if (compid <= 0)
                        {
                            mytran.Rollback();
                            conn.Close();
                            return(new ResultCompEnter()
                            {
                                Result = "F", Description = "注册核心企业失败"
                            });
                        }
                        //在表sys_users表中新增一条数据
                        Hi.Model.SYS_Users user = new Hi.Model.SYS_Users();
                        user.UserName     = LoginName;
                        user.TrueName     = "";
                        user.UserPwd      = new GetPhoneCode().md5(PassWord);
                        user.Phone        = PhoneNumb;
                        user.CreateDate   = DateTime.Now;
                        user.CreateUserID = 0;
                        user.ts           = DateTime.Now;
                        user.modifyuser   = 0;
                        user.AuditState   = 2;
                        user.IsEnabled    = 1;
                        int userid = new Hi.BLL.SYS_Users().Add(user, mytran);
                        if (userid <= 0)
                        {
                            mytran.Rollback();
                            conn.Close();
                            return(new ResultCompEnter()
                            {
                                Result = "F", Description = "注册用户失败"
                            });
                        }

                        //sys_users新增成功的话,在sys_compuser表中新增一条数据
                        Hi.Model.SYS_CompUser compuser = new Hi.Model.SYS_CompUser();
                        compuser.CompID       = compid;
                        compuser.DisID        = 0;
                        compuser.CreateDate   = DateTime.Now;
                        compuser.CreateUserID = 0;
                        compuser.ts           = DateTime.Now;
                        compuser.modifyuser   = 0;
                        compuser.CType        = 1;
                        compuser.UType        = 4;
                        compuser.dr           = 0;
                        compuser.IsAudit      = 0;
                        compuser.IsEnabled    = 1;
                        compuser.UserID       = userid;
                        int compuserid = new Hi.BLL.SYS_CompUser().Add(compuser, mytran);
                        if (compuserid <= 0)
                        {
                            mytran.Rollback();
                            conn.Close();
                            return(new ResultCompEnter()
                            {
                                Result = "F", Description = "用户与核心企业关联失败"
                            });
                        }
                        else
                        {
                            // 通知运营
                            string   SendRegiPhone = System.Configuration.ConfigurationManager.AppSettings["SendTels"].ToString();
                            string[] Phones        = SendRegiPhone.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                            foreach (string tel in Phones)
                            {
                                GetPhoneCode phoneCode = new GetPhoneCode();
                                phoneCode.GetUser(
                                    System.Configuration.ConfigurationManager.AppSettings["PhoneCodeAccount"].ToString(),
                                    System.Configuration.ConfigurationManager.AppSettings["PhoneCodePwd"].ToString());
                                phoneCode.ReturnComp(tel, comp.CompName);
                            }
                        }
                    }
                }
                else
                {
                    mytran.Rollback();

                    conn.Close();
                    return(new ResultCompEnter()
                    {
                        Result = "F", Description = "验证码异常"
                    });
                }
            }
            catch
            {
                mytran.Rollback();
                conn.Close();
            }
            mytran.Commit();
            conn.Close();


            return(new ResultCompEnter()
            {
                Result = "T", Description = "注册成功", CompID = compid.ToString()
            });
        }
        catch (Exception ex)
        {
            Common.CatchInfo(ex.Message + ":" + ex.StackTrace, "SendEnterRequest" + JSon);
            return(new ResultCompEnter()
            {
                Result = "F", Description = "参数异常"
            });
        }
    }