コード例 #1
0
    /// <summary>
    /// 保存个人信息
    /// </summary>
    /// <param name="data"></param>
    /// <returns></returns>
    private long Save_Personal(dynamic data)
    {
        var         s_personal = JsonConvert.SerializeObject(data.personal);
        CT_All_User personal   = JsonConvert.DeserializeObject <CT_All_User>(s_personal);

        if (!string.IsNullOrWhiteSpace(personal.AU_Username))
        {
            if (CT_All_User.Exists("AU_Code != @0 and AU_Username = @1", personal.AU_Code, personal.AU_Username))
            {
                throw new Exception(Interna ? "User account already exists!" : "用户账号已存在!");
            }
        }

        long au_code = personal.AU_Code;

        personal.AU_Update_dt = DateTime.Now;

        if (!string.IsNullOrWhiteSpace(personal.AU_Password))
        {
            personal.AU_Password = ShInfoTech.Common.Security.Md5(personal.AU_Password);
        }

        if (personal.AU_Code > 0)
        {
            var cols = new string[] {
                "AU_Update_dt",
                "AU_Name",
                "AU_Username",
                "AU_Married",
                "AU_Dr_Lic",
                "AU_Gender",
                "AU_ID_Type",
                "AU_ID_No",
                "AU_Education",
                "AU_Type",
                "AU_UG_Code",
                "AU_Active_tag",
                //"AU_Occupation",
                //"AU_Industry",
                "AU_B_date"
            };
            var listCols = cols.ToList <string>();
            if (!string.IsNullOrWhiteSpace(personal.AU_Password))
            {
                listCols.Add("AU_Password");
            }

            personal.Update(listCols);
        }
        else
        {
            au_code = (long)personal.Insert();
        }

        return(au_code);
    }
コード例 #2
0
    /// <summary>
    /// 保存个人信息
    /// </summary>
    /// <param name="data"></param>
    /// <returns></returns>
    private long Save_Personal(dynamic data)
    {
        var s_personal = JsonConvert.SerializeObject(data.personal);

        CRMTree.Model.CT_All_Users personal = JsonConvert.DeserializeObject <CRMTree.Model.CT_All_Users>(s_personal);

        CRMTree.Model.CT_Drivers_List_New drivermodel = JsonConvert.DeserializeObject <CRMTree.Model.CT_Drivers_List_New>(s_personal);
        if (!string.IsNullOrWhiteSpace(personal.AU_Username))
        {
            if (CT_All_User.Exists("AU_Code != @0 and AU_Username = @1", personal.AU_Code, personal.AU_Username))
            {
                throw new Exception(Interna ? "User account already exists!" : "用户账号已存在!");
            }
        }
        if (string.IsNullOrWhiteSpace(personal.AU_Name))
        {
            throw new Exception(Interna ? "NOT NULL!" : "姓名不能为空!");
        }
        long?au_code = data.AU_Code;

        personal.AU_Update_dt = DateTime.Now;

        //更新个人资料
        CRMTree.BLL.BL_UserEntity bll = new CRMTree.BLL.BL_UserEntity();
        if (!string.IsNullOrWhiteSpace(personal.AU_Password))
        {
            if (!bll.ExistsPwd(personal.AU_Password, personal.AU_Username))
            {
                personal.AU_Password = ShInfoTech.Common.Security.Md5(personal.AU_Password);
            }
        }

        int isSuccess = 0;


        if (au_code != null) //添加
        {
            bll.Update_CT_All_Users(personal);
            drivermodel.MAU_Code = data.MAU_Code;
        }

        isSuccess = bll.add_personal(drivermodel);
        if (isSuccess > 0)
        {
            if (au_code == null)
            {
                au_code = bll.getMaxAU_Code();
            }
            return((long)au_code);
        }

        else
        {
            return(isSuccess);
        }
    }