Ejemplo n.º 1
0
        /// <summary>
        /// 获取登陆用户的员工信息
        /// </summary>
        /// <param name="DE_AU_Code"></param>
        /// <returns></returns>
        public CT_Dealer_Empl getEmpl(long DE_AU_Code)
        {
            string         strSql = string.Format("select * from CT_Dealer_Empl with(nolock) where DE_AU_Code={0};", DE_AU_Code);
            CT_Dealer_Empl Empl   = DataHelper.ConvertToObject <CT_Dealer_Empl>(strSql);

            return(Empl);
        }
Ejemplo n.º 2
0
        public string GetAdviserName(string DE_Code)
        {
            CT_Dealer_Empl _de = GetAdviser(DE_Code);

            if (_de == null)
            {
                return("");
            }
            return(_de.AU_Name);
        }
Ejemplo n.º 3
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));
    }
Ejemplo n.º 4
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);
                }
            }
        }
    }