コード例 #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);
        }
    }
コード例 #3
0
    private void Save_CustomerByName(dynamic data)
    {
        CT_All_User user = new CT_All_User();

        user.AU_Name       = (string)data.AU_Name;
        user.AU_Update_dt  = DateTime.Now;
        user.AU_Active_tag = 1;

        var au_code = (long)user.Insert();

        Response.Write(JsonConvert.SerializeObject(new { AU_Code = au_code, AU_Name = user.AU_Name }));
    }
コード例 #4
0
    /// <summary>
    /// 获得员工信息
    /// </summary>
    /// <param name="data"></param>
    private void Get_EmployeeInfo(dynamic data)
    {
        dynamic o         = new ExpandoObject();
        int     Empl_Code = (int)data.Empl_Code;

        if (Empl_Code > 0)
        {
            //var empl = CT_Dealer_Empl.SingleOrDefault(Empl_Code);
            //o.dealerEmpl = new {
            //    DE_Code = empl.DE_Code,
            //    DE_ID = empl.DE_ID,
            //    DE_Type = empl.DE_Type,
            //    DE_Picture_FN_Temp = empl.DE_Picture_FN,
            //    DE_Picture_FN = empl.DE_Picture_FN
            //};
            var empl = CT_Dealer_Empl.SingleOrDefault(Empl_Code);
            empl.EX_DE_Activate_dt = empl.DE_Activate_dt.HasValue ? empl.DE_Activate_dt.Value.ToString(Interna ? "MM/dd/yyyy" : "yyyy-MM-dd") : "";
            empl.EX_DE_Vacation_St = empl.DE_Vacation_St.HasValue ? empl.DE_Vacation_St.Value.ToString(Interna ? "MM/dd/yyyy" : "yyyy-MM-dd") : "";
            empl.EX_DE_Vacation_En = empl.DE_Vacation_En.HasValue ? empl.DE_Vacation_En.Value.ToString(Interna ? "MM/dd/yyyy" : "yyyy-MM-dd") : "";
            o.dealerEmpl           = empl;
            var AU_Code = empl.DE_AU_Code;
            if (AU_Code > 0)
            {
                #region personal
                o.personal = CT_All_User.SingleOrDefault(@"select 
                AU_Code,
                AU_Active_tag,
                AU_Name,
                AU_Username,
                AU_Dr_Lic,
                AU_Gender,
                AU_ID_Type,
                AU_ID_No,
                AU_Education,
                AU_Married,
                AU_Type,
                AU_UG_Code,
                --AU_Occupation,
                --AU_Industry,
                AU_B_date 
                from CT_All_Users
                where AU_Code=@0", AU_Code);
                #endregion

                #region contacts
                o.contacts = new ExpandoObject();
                var db            = DBCRMTree.GetInstance();
                var sql_text_part = Interna ? "[text_en]" : "[text_cn]";
                var sql           = string.Format(@"Select AL_Code,AL_Type,AL_Add1,AL_Add2,AL_District,AL_City
                ,AL_State,AL_Zip,AL_Pref as [pref]
                ,(select {0} from words where p_id = 55 and [value] = al_type) as AL_Type_Text
                FROM CT_Address_List 
                WHERE AL_AU_AD_Code=@0 and isnull(AL_Active,1) = 1
                ", sql_text_part);
                o.contacts.address = db.Query <dynamic>(sql, AU_Code);

                sql = string.Format(@"Select PL_Code,PL_Type,PL_Number,PL_pref as [pref] 
                ,(select {0} from words where p_id = 47 and [value] = pl_type) as PL_Type_Text
                from CT_Phone_List 
                WHERE PL_AU_AD_Code=@0 and isnull(PL_Active,1) = 1
                ", sql_text_part);
                o.contacts.phone = db.Query <dynamic>(sql, AU_Code);

                sql = string.Format(@"Select EL_Code,EL_Type,EL_Address,EL_Pref as [pref]
                ,(select {0} from words where p_id = 44 and [value] = el_type) as EL_Type_Text
                from CT_eMail_List 
                WHERE EL_AU_AD_Code=@0 and isnull(EL_Active,1) = 1
                ", sql_text_part);
                o.contacts.email = db.Query <dynamic>(sql, AU_Code);

                sql_text_part        = Interna ? "[MC_Name_EN]" : "[MC_Name_CN]";
                sql                  = string.Format(@"Select ML_MC_Code,ML_Code,ML_Handle,ML_Pref as [pref]
                ,(SELECT {0} FROM [CT_Messaging_Carriers] where MC_Code=[ML_MC_Code]) as ML_MC_Code_Text
                from CT_Messaging_List 
                WHERE ML_AU_AD_Code=@0 and isnull(ML_Active,1) = 1
                ", sql_text_part);
                o.contacts.messaging = db.Query <dynamic>(sql, AU_Code);
                #endregion

                #region summary
                var dealer_code = 0;
                var user        = HttpContext.Current.Session["PublicUser"] as MD_UserEntity;
                if (null != user && user.User.UG_UType == 1)
                {
                    dealer_code = user.DealerEmpl.DE_AD_OM_Code;
                }
                if (dealer_code > 0)
                {
                    db.EnableAutoSelect = false;
                    o.summary           = db.SingleOrDefault <dynamic>(
                        "exec [CT_GetCustomerSummary] @Dealer_code,@User_code,@IsEn"
                        , new { Dealer_code = dealer_code, User_code = AU_Code, IsEn = Interna }
                        );
                }
                #endregion

                o.schedule = Get_Schedule((int)data.DP_UType, (int)AU_Code);
            }
        }
        Response.Write(JsonConvert.SerializeObject(o));
    }
コード例 #5
0
    /// <summary>
    /// 保存经销商员工信息
    /// </summary>
    /// <param name="data"></param>
    /// <param name="au_code"></param>
    private void Save_Dealer_Emp(dynamic data, long au_code)
    {
        var s_personal = JsonConvert.SerializeObject(data.personal);

        if (string.IsNullOrWhiteSpace(s_personal))
        {
            return;
        }

        CT_All_User    empl        = JsonConvert.DeserializeObject <CT_All_User>(s_personal);
        CT_Dealer_Empl dealer_empl = JsonConvert.DeserializeObject <CT_Dealer_Empl>(s_personal);

        dealer_empl.DE_AU_Code = au_code;
        if (empl.AU_Active_tag == 1)
        {
            dealer_empl.DE_Activate_dt = DateTime.Now;
        }
        else
        {
            dealer_empl.DE_DActivate_dt = DateTime.Now;
        }
        if (!dealer_empl.DE_Ignore.Value)
        {
            dealer_empl.DE_Ignore = null;
        }


        dealer_empl.DE_Update_dt = DateTime.Now;
        if (dealer_empl.DE_Code > 0)
        {
            dealer_empl.Update(new string[] {
                //"DE_Type",
                "DE_ID"
                , "DE_Ignore"
                , "DE_Picture_FN"
                , "DE_Vacation_St"
                , "DE_Vacation_En"
                , "DE_Activate_dt"
                , "DE_DActivate_dt"
                , "DE_Update_dt"
            });
        }
        else
        {
            if (!dealer_empl.DE_UType.HasValue)
            {
                dealer_empl.DE_UType = (byte)UserSession.User.UG_UType;
            }
            if (!dealer_empl.DE_AD_OM_Code.HasValue)
            {
                dealer_empl.DE_AD_OM_Code = UserSession.DealerEmpl.DE_AD_OM_Code;
            }
            //switch (dealer_empl.DE_UType)
            //{
            //    case 1:
            //        dealer_empl.DE_AD_OM_Code = UserSession.Dealer.AD_Code;
            //        break;
            //    case 2:
            //        dealer_empl.DE_AD_OM_Code = UserSession.DealerGroup.DG_Code;
            //        break;
            //    case 3:
            //        dealer_empl.DE_AD_OM_Code = UserSession.OEM.OM_Code;
            //        break;
            //}
            dealer_empl.Insert();
        }

        if (dealer_empl.DE_Picture_FN != dealer_empl.DE_Picture_FN_Temp)
        {
            var path_save = Server.MapPath("~/images/Adviser/");
            //添加或更换图片
            if (!string.IsNullOrWhiteSpace(dealer_empl.DE_Picture_FN))
            {
                var path = System.Configuration.ConfigurationManager.AppSettings["PLUploadPath"];
                if (string.IsNullOrWhiteSpace(path))
                {
                    path = "~/plupload/";
                }
                path = Server.MapPath(path);
                var path_temp = path + "employee_temp/";
                if (!Directory.Exists(path_save))
                {
                    Directory.CreateDirectory(path_save);
                }
                if (File.Exists(path_temp + dealer_empl.DE_Picture_FN))
                {
                    File.Move(path_temp + dealer_empl.DE_Picture_FN, path_save + dealer_empl.DE_Picture_FN);
                }
            }

            if (!string.IsNullOrWhiteSpace(dealer_empl.DE_Picture_FN_Temp))
            {
                //删除图片
                var imgPath = path_save + dealer_empl.DE_Picture_FN_Temp;
                if (File.Exists(imgPath))
                {
                    File.Delete(imgPath);
                }
            }
        }
    }
コード例 #6
0
    private void Get_CustomerName(int AU_Code)
    {
        var au = CT_All_User.SingleOrDefault(AU_Code);

        Response.Write(au.AU_Name);
    }
コード例 #7
0
    /// <summary>
    /// 获得员工信息
    /// </summary>
    /// <param name="data"></param>
    private void Get_AsscInfo(dynamic data)
    {
        dynamic o = new ExpandoObject();
        //        int Empl_Code = (int)data.AU_Code;
        //        if (Empl_Code > 0)
        //        {
        //            var empl = CT_Dealer_Empl.SingleOrDefault(Empl_Code);
        //            empl.EX_DE_Activate_dt = empl.DE_Activate_dt.HasValue ? empl.DE_Activate_dt.Value.ToString(Interna ? "MM/dd/yyyy" : "yyyy-MM-dd") : "";
        //            o.dealerEmpl = empl;
        var AU_Code  = (int)data.AU_Code;
        var MAU_Code = (int)data.MAU_Code;

        if (AU_Code > 0)
        {
            #region personal
            o.personal = CT_All_User.SingleOrDefault(@"select 
                AU_Code,
                AU_Active_tag,
                AU_Name,
                AU_Username,
                AU_Password,
                AU_Dr_Lic,
                AU_Gender,
                AU_ID_Type,
                AU_ID_No,
                AU_Education,
                AU_Married,
                AU_Type,
                AU_UG_Code,
                AU_Occupation,
                AU_Industry,
                AU_B_date
                from CT_All_Users
                where AU_Code=@0", AU_Code);
            #endregion

            #region Categories
            o.Categories = CT_Drivers_ListNew.SingleOrDefault(@"select distinct DL_Access as DL_Acc,DL_Relation as DL_Rel,DL_type,[dbo].[f_GetDL_CI_CodesByMAUCodeANDAU_Code](@1,@0) AS DL_CI_Codes from CT_Drivers_List 
                where DL_AU_Code=@0 and DL_M_AU_Code=@1", AU_Code, MAU_Code);
            //            o.Categories = new ExpandoObject();
            var db = DBCRMTree.GetInstance();
            //            var sql = string.Format(@"select DL_Access,DL_Relation,DL_type, DL_CI_Code from CT_Drivers_List
            //                where DL_AU_Code=@0 and DL_M_AU_Code=@1");
            //            o.Categories = db.Query<dynamic>(sql, AU_Code, MAU_Code);

            #endregion

            #region contacts
            o.contacts = new ExpandoObject();
            var sql_text_part = Interna ? "[text_en]" : "[text_cn]";
            var sql           = string.Format(@"Select AL_Code,AL_Type,AL_Add1,AL_Add2,AL_District,AL_City
                ,AL_State,AL_Zip,AL_Pref as [pref]
                ,(select {0} from words where p_id = 55 and [value] = al_type) as AL_Type_Text
                FROM CT_Address_List 
                WHERE AL_AU_AD_Code=@0 and isnull(AL_Active,1) = 1
                ", sql_text_part);
            o.contacts.address = db.Query <dynamic>(sql, AU_Code);

            sql = string.Format(@"Select PL_Code,PL_Type,PL_Number,PL_pref as [pref] 
                ,(select {0} from words where p_id = 47 and [value] = pl_type) as PL_Type_Text
                from CT_Phone_List 
                WHERE PL_AU_AD_Code=@0 and isnull(PL_Active,1) = 1
                ", sql_text_part);
            o.contacts.phone = db.Query <dynamic>(sql, AU_Code);

            sql = string.Format(@"Select EL_Code,EL_Type,EL_Address,EL_Pref as [pref]
                ,(select {0} from words where p_id = 44 and [value] = el_type) as EL_Type_Text
                from CT_eMail_List 
                WHERE EL_AU_AD_Code=@0 and isnull(EL_Active,1) = 1
                ", sql_text_part);
            o.contacts.email = db.Query <dynamic>(sql, AU_Code);

            sql_text_part        = Interna ? "[MC_Name_EN]" : "[MC_Name_CN]";
            sql                  = string.Format(@"Select ML_Type as ML_MC_Code,ML_Code,ML_Handle,ML_Pref as [pref]
                ,ISNULL((SELECT {0} FROM [CT_Messaging_Carriers] where MC_Code=[ML_Type]),'') as ML_MC_Code_Text
                from CT_Messaging_List 
                WHERE ML_AU_AD_Code=@0 and isnull(ML_Active,1) = 1
                ", sql_text_part);
            o.contacts.messaging = db.Query <dynamic>(sql, AU_Code);
            #endregion
        }
        //        }
        Response.Write(JsonConvert.SerializeObject(o));
    }