Пример #1
0
    private void BindDropDown()
    {
        MCSTreeControl tr_OfficialCity = (MCSTreeControl)pl_detail.FindControl("CM_Client_OfficialCity");

        if (tr_OfficialCity != null)
        {
            if ((int)Session["OwnerType"] == 2 && (int)Session["OwnerClient"] > 0)
            {
                CM_Client c = new CM_ClientBLL((int)Session["OwnerClient"]).Model;
                if (c != null)
                {
                    int prov = TreeTableBLL.GetSuperIDByLevel("MCS_SYS.dbo.Addr_OfficialCity", c.OfficialCity, 1);
                    tr_OfficialCity.RootValue = prov.ToString();
                }
            }
        }

        if ((int)Session["OwnerType"] == 2 && (int)Session["OrganizeCity"] > 1)
        {
            DropDownList ddl_VisitRoute = (DropDownList)pl_detail.FindControl("CM_ClientManufactInfo_VisitRoute");
            if (ddl_VisitRoute != null)
            {
                ddl_VisitRoute.DataValueField = "ID";
                ddl_VisitRoute.DataTextField  = "Name";

                ddl_VisitRoute.DataSource = VST_RouteBLL.GetByOrganizeCity((int)Session["OrganizeCity"]);
                ddl_VisitRoute.DataBind();
                ddl_VisitRoute.Items.Insert(0, new ListItem("请选择...", "0"));
            }
        }
    }
Пример #2
0
 public VisitRoute(int RouteID)
 {
     if (RouteID > 0)
     {
         VST_Route r = new VST_RouteBLL(RouteID).Model;
         if (r != null) FillModel(r);
     }
 }
Пример #3
0
    private void BindData()
    {
        VST_Route m = new VST_RouteBLL((int)ViewState["ID"]).Model;

        if (m != null)
        {
            pl_detail.BindData(m);

            tr_OrganizeCity_Selected(null, null);
        }
    }
Пример #4
0
 public VisitRoute(int RouteID)
 {
     if (RouteID > 0)
     {
         VST_Route r = new VST_RouteBLL(RouteID).Model;
         if (r != null)
         {
             FillModel(r);
         }
     }
 }
    private void CreateRoute(string name, int organizecity)
    {
        VST_RouteBLL routebll = new VST_RouteBLL();

        routebll.Model.Code         = "R" + ViewState["ID"].ToString();
        routebll.Model.Name         = "线路-" + name;
        routebll.Model.RelateStaff  = (int)ViewState["ID"];
        routebll.Model.OrganizeCity = organizecity;
        routebll.Model.OwnerClient  = (int)Session["OwnerClient"];
        routebll.Model.OwnerType    = (int)Session["OwnerType"];
        routebll.Model.ApproveFlag  = 1;
        routebll.Model.EnableFlag   = "Y";
        routebll.Model.InsertStaff  = (int)Session["UserID"];
        routebll.Add();
    }
Пример #6
0
    void BindVisitRoute(int city)
    {
        if (city > 0)
        {
            DropDownList ddl_VisitRoute = (DropDownList)pl_detail.FindControl("CM_ClientManufactInfo_VisitRoute");
            if (ddl_VisitRoute != null)
            {
                ddl_VisitRoute.DataValueField = "ID";
                ddl_VisitRoute.DataTextField  = "Name";

                ddl_VisitRoute.DataSource = VST_RouteBLL.GetByOrganizeCity(city);
                ddl_VisitRoute.DataBind();
                ddl_VisitRoute.Items.Insert(0, new ListItem("请选择...", "0"));
            }
        }
    }
Пример #7
0
    protected void bt_OK_Click(object sender, EventArgs e)
    {
        VST_RouteBLL _bll;

        if ((int)ViewState["ID"] != 0)
        {
            //修改
            _bll = new VST_RouteBLL((int)ViewState["ID"]);
        }
        else
        {
            //新增
            _bll = new VST_RouteBLL();
            _bll.Model.OwnerType   = (int)Session["OwnerType"];
            _bll.Model.OwnerClient = (int)Session["OwnerClient"];
            _bll.Model.ApproveFlag = 1;
        }

        pl_detail.GetData(_bll.Model);

        #region 判断必填项

        #endregion
        if ((int)ViewState["ID"] != 0)
        {
            //修改
            _bll.Model.UpdateStaff = (int)Session["UserID"];
            if (_bll.Update() == 0)
            {
                MessageBox.ShowAndRedirect(this, "修改成功!", "RouteList.aspx");
            }
        }
        else
        {
            //新增
            _bll.Model.InsertStaff = (int)Session["UserID"];
            ViewState["ID"]        = _bll.Add();
            if ((int)ViewState["ID"] > 0)
            {
                MessageBox.ShowAndRedirect(this, "新增成功!", "RouteList.aspx");
            }
        }
    }
    protected void bt_OK_Click(object sender, EventArgs e)
    {
        VST_RouteBLL _bll;
        if ((int)ViewState["ID"] != 0)
        {
            //修改
            _bll = new VST_RouteBLL((int)ViewState["ID"]);
        }
        else
        {
            //新增
            _bll = new VST_RouteBLL();
            _bll.Model.OwnerType = (int)Session["OwnerType"];
            _bll.Model.OwnerClient = (int)Session["OwnerClient"];
            _bll.Model.ApproveFlag = 1;
        }

        pl_detail.GetData(_bll.Model);

        #region 判断必填项

        #endregion
        if ((int)ViewState["ID"] != 0)
        {
            //修改
            _bll.Model.UpdateStaff = (int)Session["UserID"];
            if (_bll.Update() == 0)
            {
                MessageBox.ShowAndRedirect(this, "修改成功!", "RouteList.aspx");
            }
        }
        else
        {
            //新增
            _bll.Model.InsertStaff = (int)Session["UserID"];
            ViewState["ID"] = _bll.Add();
            if ((int)ViewState["ID"] > 0)
            {
                MessageBox.ShowAndRedirect(this, "新增成功!", "RouteList.aspx");
            }
        }
    }
Пример #9
0
    void tr_OrganizeCity_Selected(object sender, SelectedEventArgs e)
    {
        if (tr_OrganizeCity == null)
        {
            return;
        }

        int city = 0;

        int.TryParse(tr_OrganizeCity.SelectValue, out city);
        if (city > 0)
        {
            DropDownList ddl_VisitRoute = (DropDownList)pl_detail.FindControl("CM_ClientManufactInfo_VisitRoute");
            if (ddl_VisitRoute != null)
            {
                ddl_VisitRoute.DataValueField = "ID";
                ddl_VisitRoute.DataTextField  = "Name";

                ddl_VisitRoute.DataSource = VST_RouteBLL.GetByOrganizeCity(city);
                ddl_VisitRoute.DataBind();
                ddl_VisitRoute.Items.Insert(0, new ListItem("请选择...", "0"));
            }

            #region 设置营业所编码
            Addr_OrganizeCity citymodel  = new Addr_OrganizeCityBLL(city).Model;
            TextBox           tbx_OUTLOC = (TextBox)pl_detail.FindControl("CM_ClientManufactInfo_OUTLOC");
            if (citymodel != null && tbx_OUTLOC != null)
            {
                tbx_OUTLOC.Text = citymodel.Code;
            }

            citymodel = new Addr_OrganizeCityBLL(citymodel.SuperID).Model;
            TextBox tbx_SALGRP = (TextBox)pl_detail.FindControl("CM_ClientManufactInfo_SALGRP");
            if (citymodel != null && tbx_SALGRP != null)
            {
                tbx_SALGRP.Text = citymodel.Code;
            }
            #endregion
        }
    }
Пример #10
0
        private void FillModel(int ID)
        {
            VST_VisitPlanBLL bll = new VST_VisitPlanBLL(ID);

            if (bll.Model == null)
            {
                return;
            }

            VST_VisitPlan m = bll.Model;

            ID                  = m.ID;
            Route               = m.Route;
            RelateStaff         = m.RelateStaff;
            PlanVisitDate       = m.PlanVisitDate;
            IsMustSequenceVisit = m.IsMustSequenceVisit;
            Remark              = m.Remark;
            ApproveFlag         = m.ApproveFlag;

            Items = new List <VisitPlanDetail>(bll.Items.Count);
            foreach (var item in bll.Items)
            {
                Items.Add(new VisitPlanDetail(item));
            }

            if (m.Route > 0)
            {
                VST_Route r = new VST_RouteBLL(m.Route).Model;
                if (r != null)
                {
                    RouteName = r.Name;
                }

                Org_Staff s = new Org_StaffBLL(m.RelateStaff).Model;
                if (s != null)
                {
                    RelateStaffName = s.RealName;
                }
            }
        }
    private void BindData()
    {
        VST_Route m = new VST_RouteBLL((int)ViewState["ID"]).Model;
        if (m != null)
        {
            pl_detail.BindData(m);

            tr_OrganizeCity_Selected(null, null);
        }
    }
Пример #12
0
        private void FillClientInfo(CM_Client m, int TDP)
        {
            if (m == null)
            {
                return;
            }

            CM_ClientBLL ClientBLL = new CM_ClientBLL(m.ID);

            if (ClientBLL.Model == null)
            {
                return;
            }

            #region 绑定基本资料
            ID           = m.ID;
            Code         = m.Code;
            FullName     = m.FullName == "" ? m.ShortName : m.FullName;
            ShortName    = m.ShortName;
            OfficialCity = m.OfficialCity;
            Address      = m.Address;
            ClientType   = m.ClientType;
            LinkManName  = m.LinkManName;
            TeleNum      = m.TeleNum;
            Mobile       = m.Mobile == "" ? m.TeleNum : m.Mobile;

            OfficialCityName = TreeTableBLL.GetFullPathName("MCS_SYS.dbo.Addr_OfficialCity", m.OfficialCity).Replace("->", " ");
            #endregion

            #region 绑定供货信息
            CM_ClientSupplierInfo SupplierInfo = ClientBLL.GetSupplierInfo(TDP);
            if (SupplierInfo != null)
            {
                CodeBySupplier = SupplierInfo.Code;
                Supplier       = SupplierInfo.Supplier;
                StandardPrice  = SupplierInfo.StandardPrice;
                TDPChannel     = SupplierInfo.TDPChannel;
                TDPSalesArea   = SupplierInfo.TDPSalesArea;
                VisitRoute     = SupplierInfo.VisitRoute;
                VisitSequence  = SupplierInfo.VisitSequence;
                VisitTemplate  = SupplierInfo.VisitTemplate;

                #region 获取供货商名称
                CM_Client s = new CM_ClientBLL(Supplier).Model;
                if (s != null)
                {
                    SupplierName = s.ShortName == "" ? s.ShortName : s.FullName;
                }
                #endregion

                #region 获取价表名称
                if (StandardPrice != 0)
                {
                    PDT_StandardPrice price = new PDT_StandardPriceBLL(StandardPrice).Model;
                    if (price != null)
                    {
                        StandardPriceName = price.Name;
                    }
                }
                #endregion

                #region 获取渠道名称
                if (TDPChannel > 0)
                {
                    CM_RTChannel_TDP channel = new CM_RTChannel_TDPBLL(TDPChannel).Model;
                    if (channel != null)
                    {
                        TDPChannelName = channel.Name;
                    }
                }
                #endregion

                #region 获取区域名称
                if (TDPSalesArea > 0)
                {
                    CM_RTSalesArea_TDP area = new CM_RTSalesArea_TDPBLL(TDPSalesArea).Model;
                    if (area != null)
                    {
                        TDPSalesAreaName = area.Name;
                    }
                }
                #endregion

                #region 获取路线及拜访模板名称
                if (VisitRoute != 0)
                {
                    VST_Route r = new VST_RouteBLL(VisitRoute).Model;
                    if (r != null)
                    {
                        VisitRouteName = r.Name;
                    }
                }

                if (VisitTemplate != 0)
                {
                    VST_VisitTemplate t = new VST_VisitTemplateBLL(VisitTemplate).Model;
                    if (t != null)
                    {
                        VisitTemplateName = t.Name;
                    }
                }
                #endregion

                #region 获取销售员名称
                if (Salesman != 0)
                {
                    Org_Staff staff = new Org_StaffBLL(Salesman).Model;
                    if (staff != null)
                    {
                        SalesmanName = staff.RealName;
                    }
                }
                #endregion
            }
            #endregion

            #region 绑定厂商管理信息
            int manufacturer = 0;           //归属厂商
            if (m.ClientType == 3)
            {
                //门店的归属厂商为当前TDP所归属的厂商
                CM_Client supplier = new CM_ClientBLL(TDP).Model;
                if (supplier != null)
                {
                    manufacturer = supplier.OwnerClient;
                }
            }
            else if (m.ClientType == 2)
            {
                //TDP经销商的归属厂商
                manufacturer = m.OwnerClient;
            }

            CM_ClientManufactInfo ManufactInfo = ClientBLL.GetManufactInfo(manufacturer);
            if (ManufactInfo != null)
            {
                CodeByManufaturer = ManufactInfo.Code;
            }
            #endregion

            #region 绑定客户定位信息
            CM_ClientGeoInfo geo = CM_ClientGeoInfoBLL.GetGeoInfoByClient(m.ID);
            if (geo != null)
            {
                Latitude  = (float)geo.Latitude;
                Longitude = (float)geo.Longitude;
            }
            #endregion

            #region 绑定客户供货产品目录
            ClientProductLists = new List <ProductList>();
            foreach (CM_ClientProductList item in CM_ClientProductListBLL.GetModelList
                         ("Client=" + m.ID.ToString() + (TDP == 0 ? "" : " AND Supplier=" + TDP.ToString())))
            {
                ClientProductLists.Add(new ProductList(item));
            }
            #endregion

            #region 查询预收款余额
            AC_CurrentAccount ac = AC_CurrentAccountBLL.GetByTradeClient(TDP, m.ID);
            if (ac != null)
            {
                ARBalance = ac.PreReceivedAmount - ac.AR;
            }
            #endregion

            #region 获取附件明细
            IList <ATMT_Attachment> atts = ATMT_AttachmentBLL.GetAttachmentList(30, m.ID, DateTime.Today.AddMonths(-3), new DateTime(2100, 1, 1));
            Atts = new List <Attachment>(atts.Count);
            foreach (ATMT_Attachment item in atts.OrderByDescending(p => p.UploadTime))
            {
                Atts.Add(new Attachment(item));
            }
            #endregion
        }
    public void BindDropDown()
    {
        #region 业务人员
        DropDownList ddlSalesMan = pl_detail.FindControl("CM_ClientSupplierInfo_Salesman") as DropDownList;
        if (ddlSalesMan != null)
        {
            ddlSalesMan.DataTextField  = "RealName";
            ddlSalesMan.DataValueField = "ID";
            IList <Org_Staff> listStaff = Org_StaffBLL.GetStaffList("Dimission=1 AND Position=1030 AND OwnerClient= " + Session["OwnerClient"].ToString());
            if (listStaff == null)
            {
                listStaff = new List <Org_Staff>(1);
            }
            listStaff.Insert(0, new Org_Staff {
                RealName = "请选择", ID = 0
            });
            ddlSalesMan.DataSource = listStaff;
            ddlSalesMan.DataBind();
        }
        #endregion

        #region 经销商自分渠道
        DropDownList ddlTDPChannel = pl_detail.FindControl("CM_ClientSupplierInfo_TDPChannel") as DropDownList;
        if (ddlTDPChannel != null)
        {
            ddlTDPChannel.DataTextField  = "Name";
            ddlTDPChannel.DataValueField = "ID";
            IList <CM_RTChannel_TDP> listChannel = CM_RTChannel_TDPBLL.GetModelList("OwnerClient= " + Session["OwnerClient"].ToString());
            if (listChannel == null)
            {
                listChannel = new List <CM_RTChannel_TDP>(1);
            }
            listChannel.Insert(0, new CM_RTChannel_TDP {
                Name = "请选择", ID = 0
            });
            ddlTDPChannel.DataSource = listChannel;
            ddlTDPChannel.DataBind();
        }
        #endregion

        #region 经销商所属区域
        DropDownList ddlTDPSalesArea = pl_detail.FindControl("CM_ClientSupplierInfo_TDPSalesArea") as DropDownList;
        if (ddlTDPSalesArea != null)
        {
            ddlTDPSalesArea.DataTextField  = "Name";
            ddlTDPSalesArea.DataValueField = "ID";
            IList <CM_RTSalesArea_TDP> listSalesArea = CM_RTSalesArea_TDPBLL.GetModelList("OwnerClient= " + Session["OwnerClient"].ToString());
            if (listSalesArea == null)
            {
                listSalesArea = new List <CM_RTSalesArea_TDP>(1);
            }
            listSalesArea.Insert(0, new CM_RTSalesArea_TDP {
                Name = "请选择", ID = 0
            });
            ddlTDPSalesArea.DataSource = listSalesArea;
            ddlTDPSalesArea.DataBind();
        }
        #endregion

        #region 经销商价表
        DropDownList ddlStandardPrice = pl_detail.FindControl("CM_ClientSupplierInfo_StandardPrice") as DropDownList;
        if (ddlStandardPrice != null)
        {
            ddlStandardPrice.DataTextField  = "Name";
            ddlStandardPrice.DataValueField = "ID";
            IList <PDT_StandardPrice> listPrice = PDT_StandardPriceBLL.GetAllPrice_BySupplier((int)Session["OwnerClient"]);
            if (listPrice == null)
            {
                listPrice = new List <PDT_StandardPrice>(1);
            }
            listPrice.Insert(0, new PDT_StandardPrice {
                Name = "请选择", ID = 0
            });
            ddlStandardPrice.DataSource = listPrice;
            ddlStandardPrice.DataBind();
        }
        #endregion

        #region 经销商自营路线
        DropDownList ddlVisitRoute = pl_detail.FindControl("CM_ClientSupplierInfo_VisitRoute") as DropDownList;
        if (ddlVisitRoute != null)
        {
            ddlVisitRoute.DataTextField  = "Name";
            ddlVisitRoute.DataValueField = "ID";
            IList <VST_Route> listRoute = VST_RouteBLL.GetRouteListByTDP((int)Session["OwnerClient"]);
            listRoute.Insert(0, new VST_Route {
                Name = "请选择", ID = 0
            });
            ddlVisitRoute.DataSource = listRoute;
            ddlVisitRoute.DataBind();
        }
        #endregion

        #region 行政城市默认为厂商所在省份
        MCSTreeControl tr_OfficialCity = (MCSTreeControl)pl_detail.FindControl("CM_Client_OfficialCity");
        if (tr_OfficialCity != null)
        {
            if ((int)Session["Manufacturer"] > 0)
            {
                CM_Client c = new CM_ClientBLL((int)Session["Manufacturer"]).Model;
                if (c != null)
                {
                    int prov = TreeTableBLL.GetSuperIDByLevel("MCS_SYS.dbo.Addr_OfficialCity", c.OfficialCity, 1);
                    tr_OfficialCity.RootValue = prov.ToString();
                }
            }
        }
        #endregion
    }
Пример #14
0
        private void FillModel(int WorkListID)
        {
            VST_WorkListBLL bll = new VST_WorkListBLL(WorkListID);
            if (bll.Model == null) return;

            ID = bll.Model.ID;
            RelateStaff = bll.Model.RelateStaff;
            Route = bll.Model.Route;
            Client = bll.Model.Client;
            VisitTemplate = bll.Model.Template;
            WorkingClassify = bll.Model.WorkingClassify;
            IsComplete = bll.Model.IsComplete.ToUpper() == "Y";
            BeginTime = bll.Model.BeginTime;
            EndTime = bll.Model.EndTime;
            PlanID = bll.Model.PlanID;
            Remark = bll.Model.Remark;
            InsertTime = bll.Model.InsertTime;

            //详细工作项目
            Items = new List<VisitWorkItem>(bll.Items.Count);
            foreach (VST_WorkItem item in bll.Items)
            {
                Items.Add(new VisitWorkItem(item));
            }

            #region ID转名称
            try
            {
                if (RelateStaff != 0)
                {
                    Org_Staff s = new Org_StaffBLL(RelateStaff).Model;
                    if (s != null) RelateStaffName = s.RealName;
                }

                if (Route != 0)
                {
                    VST_Route r = new VST_RouteBLL(Route).Model;
                    if (r != null) RouteName = r.Name;
                }

                if (Client != 0)
                {
                    CM_Client c = new CM_ClientBLL(Client).Model;
                    if (c != null) ClientName = c.FullName;
                }

                if (VisitTemplate != 0)
                {
                    VST_VisitTemplate t = new VST_VisitTemplateBLL(VisitTemplate).Model;
                    if (t != null) VisitTemplateName = t.Name;
                }

                if (WorkingClassify != 0)
                {
                    Dictionary_Data dic = DictionaryBLL.GetDicCollections("VST_WorkingClassify")[WorkingClassify.ToString()];
                    if (dic != null) WorkingClassifyName = dic.Name;
                }
            }
            catch { }
            #endregion
        }
Пример #15
0
        /**
         *返回状态 3:成功 4:失败 5:部分成功
         */

        #region 1.导入员工资料,废弃不用
        /// <summary>
        /// 导入员工资料
        /// </summary>
        /// <param name="TemplateID"></param>
        /// <param name="Staff"></param>
        /// <param name="StaffSheet"></param>
        /// <param name="State">3:成功 4:失败 5:部分成功</param>
        /// <returns></returns>
        //public string DoImportStaff(int TemplateID, int Client, ISheet StaffSheet, out int State)
        public string DoImportStaff(int TemplateID, int Client, ISheet Sheet, out int State)
        {
            string ImportInfo = "【员工资料】Excel表:";

            State = 0;
            IPT_UploadTemplateBLL _template = new IPT_UploadTemplateBLL(TemplateID);

            List <string> listPDT = new List <string>()
            {
                "序号", "姓名", "职务", "手机号码", "关联车号", "身份证号"
            };

            DataTable dt   = null;
            bool      flag = VertifySheet(Sheet, listPDT, out dt, ref ImportInfo);

            if (!flag)
            {
                State = 4; return(ImportInfo);
            }

            foreach (DataRow dr in dt.Rows)//循环导入数据
            {
                try
                {
                    string _staffName = dr["姓名"].ToString();

                    IList <Org_Staff> _listStaff = Org_StaffBLL.GetStaffList("  Dimission=1 AND OwnerClient=" + _template.Model.ClientID.ToString() + " AND RealName='" + _staffName + "'");
                    if (_listStaff != null && _listStaff.Count > 0)
                    {
                        ImportInfo += string.Format("导入序列号为{0},名字为{1}的数据行时与现有员工名字重复,跳过此行\r\n", dr["序号"].ToString(), _staffName);
                        continue;
                    }

                    int    _staffPosition = 0; string _strStaffPosition = dr["职务"].ToString();
                    string _staffPhone  = dr["手机号码"].ToString();
                    string _staffIDCode = dr["身份证号"].ToString();
                    if (!string.IsNullOrEmpty(_strStaffPosition))//无职位默认为业代
                    {
                        IList <Org_Position> _listPosition = Org_PositionBLL.GetModelList(" Name='" + _strStaffPosition + "'");
                        if (_listPosition != null && _listPosition.Count > 0)
                        {
                            _staffPosition = _listPosition[0].ID;
                        }
                    }
                    else
                    {
                        _staffPosition = 1030;
                    }

                    Org_StaffBLL          _bllStaff    = new Org_StaffBLL();
                    CM_ClientBLL          c            = new CM_ClientBLL(_template.Model.ClientID);
                    CM_ClientManufactInfo manufactinfo = c.GetManufactInfo();
                    if (c != null && manufactinfo != null)
                    {
                        _bllStaff.Model.OrganizeCity = manufactinfo.OrganizeCity;
                        _bllStaff.Model.OfficialCity = c.Model.OfficialCity;
                    }
                    _bllStaff.Model.RealName    = _staffName;
                    _bllStaff.Model.Position    = _staffPosition;
                    _bllStaff.Model.Mobile      = _staffPhone;
                    _bllStaff.Model.TeleNum     = _staffPhone;
                    _bllStaff.Model.IDCode      = _staffIDCode;
                    _bllStaff.Model.InsertStaff = _template.Model.InsertStaff;
                    _bllStaff.Model.OwnerClient = _template.Model.ClientID;
                    _bllStaff.Model.OwnerType   = 3;
                    _bllStaff.Model.Dimission   = 1;
                    _bllStaff.Model.ApproveFlag = 1;
                    int _ClientID = _bllStaff.Add();//当前员工ID
                    //创建默认员工线路
                    if (_ClientID > 0)
                    {
                        if (_bllStaff.Model.Position == 1030)//业待创建默认路线
                        {
                            VST_RouteBLL routebll = new VST_RouteBLL();
                            routebll.Model.Code         = "R" + _ClientID.ToString();
                            routebll.Model.Name         = "线路-" + _bllStaff.Model.RealName;
                            routebll.Model.RelateStaff  = _ClientID;
                            routebll.Model.OrganizeCity = _bllStaff.Model.OrganizeCity;
                            routebll.Model.OwnerClient  = _template.Model.ClientID;
                            routebll.Model.OwnerType    = 3;
                            routebll.Model.ApproveFlag  = 1;
                            routebll.Model.EnableFlag   = "Y";
                            routebll.Model.InsertStaff  = _template.Model.InsertStaff;
                            routebll.Add();
                        }
                        if (_bllStaff.Model.Position == 1030 || _bllStaff.Model.Position == 1050)//只有业待和司机能关联车号
                        {
                            #region 获取车号ID
                            int _staffCar = 0; string _strStaffCar = dr["关联车号"].ToString();
                            if (!string.IsNullOrEmpty(_strStaffCar))
                            {
                                IList <CM_Vehicle> _listVehicles = CM_VehicleBLL.GetModelList("Client=" + _template.Model.ClientID + " AND VehicleNo='" + _strStaffPosition + "' ");
                                if (_listVehicles != null && _listVehicles.Count > 0)
                                {
                                    _staffCar = _listVehicles[0].ID;
                                }
                                else
                                {
                                    CM_VehicleBLL vehicle = new CM_VehicleBLL();
                                    vehicle.Model.Client          = _template.Model.ClientID;
                                    vehicle.Model.VehicleNo       = _strStaffCar;
                                    vehicle.Model.State           = 1;
                                    vehicle.Model.Remark          = "新导入未确认";
                                    vehicle.Model.VehicleClassify = 2;
                                    _staffCar = vehicle.Add();
                                }
                            }
                            #endregion
                            if (_staffCar > 0)//关联车号
                            {
                                IList <CM_VehicleInStaff> _listVehicleInStaff = CM_VehicleInStaffBLL.GetModelList("Vehicle=" + _staffCar.ToString() + " AND Staff=" + _ClientID.ToString());
                                if (_listVehicleInStaff == null || _listVehicleInStaff.Count == 0)
                                {
                                    CM_VehicleInStaffBLL vehicle_staff = new CM_VehicleInStaffBLL();
                                    vehicle_staff.Model.Staff       = _ClientID;
                                    vehicle_staff.Model.Vehicle     = _staffCar;
                                    vehicle_staff.Model.InsertStaff = _template.Model.InsertStaff;
                                    vehicle_staff.Add();
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    ImportInfo += "导入序列号为" + dr["序号"].ToString() + "的数据行时出现错误,错误说明:" + ex.Message + "\r\n";
                    State       = 5;
                    continue;
                }
            }
            if (State == 0)
            {
                State = 3;
            }
            ImportInfo += (State == 3 ? "导入完成!\r\n" : "");
            IPT_UploadTemplateMessageBLL _bllUploadTemplateMessage = new IPT_UploadTemplateMessageBLL();
            _bllUploadTemplateMessage.Model.TemplateID  = TemplateID;
            _bllUploadTemplateMessage.Model.MessageType = State;
            _bllUploadTemplateMessage.Model.Content     = ImportInfo;
            _bllUploadTemplateMessage.Add();
            return(ImportInfo);
        }
Пример #16
0
        private void FillModel(int ID)
        {
            VST_VisitPlanBLL bll = new VST_VisitPlanBLL(ID);
            if (bll.Model == null) return;

            VST_VisitPlan m = bll.Model;

            ID = m.ID;
            Route = m.Route;
            RelateStaff = m.RelateStaff;
            PlanVisitDate = m.PlanVisitDate;
            IsMustSequenceVisit = m.IsMustSequenceVisit;
            Remark = m.Remark;
            ApproveFlag = m.ApproveFlag;

            Items = new List<VisitPlanDetail>(bll.Items.Count);
            foreach (var item in bll.Items)
            {
                Items.Add(new VisitPlanDetail(item));
            }

            if (m.Route > 0)
            {
                VST_Route r = new VST_RouteBLL(m.Route).Model;
                if (r != null) RouteName = r.Name;

                Org_Staff s = new Org_StaffBLL(m.RelateStaff).Model;
                if (s != null) RelateStaffName = s.RealName;
            }
        }
Пример #17
0
        private void FillModel(int WorkListID)
        {
            VST_WorkListBLL bll = new VST_WorkListBLL(WorkListID);

            if (bll.Model == null)
            {
                return;
            }

            ID              = bll.Model.ID;
            RelateStaff     = bll.Model.RelateStaff;
            Route           = bll.Model.Route;
            Client          = bll.Model.Client;
            VisitTemplate   = bll.Model.Template;
            WorkingClassify = bll.Model.WorkingClassify;
            IsComplete      = bll.Model.IsComplete.ToUpper() == "Y";
            BeginTime       = bll.Model.BeginTime;
            EndTime         = bll.Model.EndTime;
            PlanID          = bll.Model.PlanID;
            Remark          = bll.Model.Remark;
            InsertTime      = bll.Model.InsertTime;

            //详细工作项目
            Items = new List <VisitWorkItem>(bll.Items.Count);
            foreach (VST_WorkItem item in bll.Items)
            {
                Items.Add(new VisitWorkItem(item));
            }

            #region ID转名称
            try
            {
                if (RelateStaff != 0)
                {
                    Org_Staff s = new Org_StaffBLL(RelateStaff).Model;
                    if (s != null)
                    {
                        RelateStaffName = s.RealName;
                    }
                }

                if (Route != 0)
                {
                    VST_Route r = new VST_RouteBLL(Route).Model;
                    if (r != null)
                    {
                        RouteName = r.Name;
                    }
                }

                if (Client != 0)
                {
                    CM_Client c = new CM_ClientBLL(Client).Model;
                    if (c != null)
                    {
                        ClientName = c.FullName;
                    }
                }

                if (VisitTemplate != 0)
                {
                    VST_VisitTemplate t = new VST_VisitTemplateBLL(VisitTemplate).Model;
                    if (t != null)
                    {
                        VisitTemplateName = t.Name;
                    }
                }

                if (WorkingClassify != 0)
                {
                    Dictionary_Data dic = DictionaryBLL.GetDicCollections("VST_WorkingClassify")[WorkingClassify.ToString()];
                    if (dic != null)
                    {
                        WorkingClassifyName = dic.Name;
                    }
                }
            }
            catch { }
            #endregion
        }
Пример #18
0
    protected void bt_OK_Click(object sender, EventArgs e)
    {
        Org_StaffBLL _bll;

        if ((int)ViewState["ID"] != 0)
        {
            //修改
            _bll = new Org_StaffBLL((int)ViewState["ID"]);
        }
        else
        {
            //新增
            _bll = new Org_StaffBLL();
        }

        pl_detail.GetData(_bll.Model);

        #region 判断必填项
        if (_bll.Model.Position == 0 || _bll.Model.Position == 1000)
        {
            MessageBox.Show(this, "请选择员工所属的职位!");
            return;
        }
        #endregion

        #region 判断在职标志
        if (_bll.Model.Dimission == 1)
        {
            if (_bll.Model.BeginWorkTime.Year == 1900)
            {
                _bll.Model.BeginWorkTime = DateTime.Today;
            }
            if (_bll.Model.EndWorkTime.Year != 1900)
            {
                _bll.Model.EndWorkTime = new DateTime(1900, 1, 1);
            }
        }
        else if (_bll.Model.Dimission == 2)
        {
            if (_bll.Model.EndWorkTime.Year == 1900)
            {
                _bll.Model.EndWorkTime = DateTime.Today;
            }
        }
        #endregion

        #region 判断手机号码有效性
        if (_bll.Model.Mobile.StartsWith("01"))
        {
            _bll.Model.Mobile = _bll.Model.Mobile.Substring(1);
        }
        if (Org_StaffBLL.GetStaffList("Dimission=1 AND Mobile='" + _bll.Model.Mobile + "' AND ID <> " + _bll.Model.ID.ToString()).Count > 0)
        {
            MessageBox.Show(this, "手机号码和系统中其他员工的手机号码重复,请检查是否正确!");
            return;
        }
        #endregion


        if ((int)ViewState["ID"] != 0)
        {
            //修改
            _bll.Model.UpdateStaff = (int)Session["UserID"];
            if (_bll.Update() == 0)
            {
                #region 创建默认职位为业务员的线路
                if (_bll.Model.Position == 1030 && VST_RouteBLL.GetRouteListByStaff(_bll.Model.ID).Count == 0)
                {
                    CreateRoute(_bll.Model.RealName, _bll.Model.OrganizeCity);
                }
                #endregion

                MessageBox.ShowAndRedirect(this, "保存成功!", "StaffDetail.aspx?ID=" + ViewState["ID"].ToString());
            }
        }
        else
        {
            //新增

            CM_ClientBLL          c            = new CM_ClientBLL((int)Session["OwnerClient"]);
            CM_ClientManufactInfo manufactinfo = c.GetManufactInfo();
            if (c != null && manufactinfo != null)
            {
                _bll.Model.OrganizeCity = manufactinfo.OrganizeCity;
                _bll.Model.OfficialCity = c.Model.OfficialCity;
            }

            _bll.Model.InsertStaff = (int)Session["UserID"];
            _bll.Model.OwnerClient = (int)Session["OwnerClient"];
            _bll.Model.OwnerType   = (int)Session["OwnerType"];
            if (_bll.Model.Dimission == 0)
            {
                _bll.Model.Dimission = 1;
            }

            _bll.Model.ApproveFlag = 1;
            ViewState["ID"]        = _bll.Add();

            if ((int)ViewState["ID"] > 0)
            {
                #region 创建默认职位为业务员的线路
                if (_bll.Model.Position == 1030)
                {
                    CreateRoute(_bll.Model.RealName, _bll.Model.OrganizeCity);
                }
                #endregion

                Response.Redirect("StaffDetail.aspx?ID=" + ViewState["ID"].ToString());
            }
        }
    }
Пример #19
0
        /// <summary>
        /// 导入员工资料
        /// </summary>
        /// <param name="TemplateID"></param>
        /// <param name="Staff"></param>
        /// <param name="StaffSheet"></param>
        /// <param name="State">3:成功 4:失败 5:部分成功</param>
        /// <returns></returns>
        //public string DoImportStaff(int TemplateID, int Client, ISheet StaffSheet, out int State)
        public string DoImportStaff(int TemplateID, int Client, ISheet Sheet, out int State)
        {
            string ImportInfo = "【员工资料】Excel表:";
            State = 0;
            IPT_UploadTemplateBLL _template = new IPT_UploadTemplateBLL(TemplateID);

            List<string> listPDT = new List<string>() { "序号", "姓名", "职务", "手机号码", "关联车号", "身份证号" };

            DataTable dt = null;
            bool flag = VertifySheet(Sheet, listPDT, out dt, ref ImportInfo);
            if (!flag) { State = 4; return ImportInfo; }

            foreach (DataRow dr in dt.Rows)//循环导入数据
            {
                try
                {
                    string _staffName = dr["姓名"].ToString();

                    IList<Org_Staff> _listStaff = Org_StaffBLL.GetStaffList("  Dimission=1 AND OwnerClient=" + _template.Model.ClientID.ToString() + " AND RealName='" + _staffName + "'");
                    if (_listStaff != null && _listStaff.Count > 0)
                    {
                        ImportInfo += string.Format("导入序列号为{0},名字为{1}的数据行时与现有员工名字重复,跳过此行\r\n", dr["序号"].ToString(), _staffName);
                        continue;
                    }

                    int _staffPosition = 0; string _strStaffPosition = dr["职务"].ToString();
                    string _staffPhone = dr["手机号码"].ToString();
                    string _staffIDCode = dr["身份证号"].ToString();
                    if (!string.IsNullOrEmpty(_strStaffPosition))//无职位默认为业代
                    {
                        IList<Org_Position> _listPosition = Org_PositionBLL.GetModelList(" Name='" + _strStaffPosition + "'");
                        if (_listPosition != null && _listPosition.Count > 0) _staffPosition = _listPosition[0].ID;
                    }
                    else { _staffPosition = 1030; }

                    Org_StaffBLL _bllStaff = new Org_StaffBLL();
                    CM_ClientBLL c = new CM_ClientBLL(_template.Model.ClientID);
                    CM_ClientManufactInfo manufactinfo = c.GetManufactInfo();
                    if (c != null && manufactinfo != null)
                    {
                        _bllStaff.Model.OrganizeCity = manufactinfo.OrganizeCity;
                        _bllStaff.Model.OfficialCity = c.Model.OfficialCity;
                    }
                    _bllStaff.Model.RealName = _staffName;
                    _bllStaff.Model.Position = _staffPosition;
                    _bllStaff.Model.Mobile = _staffPhone;
                    _bllStaff.Model.TeleNum = _staffPhone;
                    _bllStaff.Model.IDCode = _staffIDCode;
                    _bllStaff.Model.InsertStaff = _template.Model.InsertStaff;
                    _bllStaff.Model.OwnerClient = _template.Model.ClientID;
                    _bllStaff.Model.OwnerType = 3;
                    _bllStaff.Model.Dimission = 1;
                    _bllStaff.Model.ApproveFlag = 1;
                    int _ClientID = _bllStaff.Add();//当前员工ID
                    //创建默认员工线路
                    if (_ClientID > 0)
                    {
                        if (_bllStaff.Model.Position == 1030)//业待创建默认路线
                        {
                            VST_RouteBLL routebll = new VST_RouteBLL();
                            routebll.Model.Code = "R" + _ClientID.ToString();
                            routebll.Model.Name = "线路-" + _bllStaff.Model.RealName;
                            routebll.Model.RelateStaff = _ClientID;
                            routebll.Model.OrganizeCity = _bllStaff.Model.OrganizeCity;
                            routebll.Model.OwnerClient = _template.Model.ClientID;
                            routebll.Model.OwnerType = 3;
                            routebll.Model.ApproveFlag = 1;
                            routebll.Model.EnableFlag = "Y";
                            routebll.Model.InsertStaff = _template.Model.InsertStaff;
                            routebll.Add();
                        }
                        if (_bllStaff.Model.Position == 1030 || _bllStaff.Model.Position == 1050)//只有业待和司机能关联车号
                        {
                            #region 获取车号ID
                            int _staffCar = 0; string _strStaffCar = dr["关联车号"].ToString();
                            if (!string.IsNullOrEmpty(_strStaffCar))
                            {
                                IList<CM_Vehicle> _listVehicles = CM_VehicleBLL.GetModelList("Client=" + _template.Model.ClientID + " AND VehicleNo='" + _strStaffPosition + "' ");
                                if (_listVehicles != null && _listVehicles.Count > 0) _staffCar = _listVehicles[0].ID;
                                else
                                {
                                    CM_VehicleBLL vehicle = new CM_VehicleBLL();
                                    vehicle.Model.Client = _template.Model.ClientID;
                                    vehicle.Model.VehicleNo = _strStaffCar;
                                    vehicle.Model.State = 1;
                                    vehicle.Model.Remark = "新导入未确认";
                                    vehicle.Model.VehicleClassify = 2;
                                    _staffCar = vehicle.Add();
                                }
                            }
                            #endregion
                            if (_staffCar > 0)//关联车号
                            {
                                IList<CM_VehicleInStaff> _listVehicleInStaff = CM_VehicleInStaffBLL.GetModelList("Vehicle=" + _staffCar.ToString() + " AND Staff=" + _ClientID.ToString());
                                if (_listVehicleInStaff == null || _listVehicleInStaff.Count == 0)
                                {
                                    CM_VehicleInStaffBLL vehicle_staff = new CM_VehicleInStaffBLL();
                                    vehicle_staff.Model.Staff = _ClientID;
                                    vehicle_staff.Model.Vehicle = _staffCar;
                                    vehicle_staff.Model.InsertStaff = _template.Model.InsertStaff;
                                    vehicle_staff.Add();
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    ImportInfo += "导入序列号为" + dr["序号"].ToString() + "的数据行时出现错误,错误说明:" + ex.Message + "\r\n";
                    State = 5;
                    continue;
                }
            }
            if (State == 0) State = 3;
            ImportInfo += (State == 3 ? "导入完成!\r\n" : "");
            IPT_UploadTemplateMessageBLL _bllUploadTemplateMessage = new IPT_UploadTemplateMessageBLL();
            _bllUploadTemplateMessage.Model.TemplateID = TemplateID;
            _bllUploadTemplateMessage.Model.MessageType = State;
            _bllUploadTemplateMessage.Model.Content = ImportInfo;
            _bllUploadTemplateMessage.Add();
            return ImportInfo;
        }
Пример #20
0
        private void FillClientInfo(CM_Client m, int TDP)
        {
            if (m == null) return;

            CM_ClientBLL ClientBLL = new CM_ClientBLL(m.ID);
            if (ClientBLL.Model == null) return;

            #region 绑定基本资料
            ID = m.ID;
            Code = m.Code;
            FullName = m.FullName == "" ? m.ShortName : m.FullName;
            ShortName = m.ShortName;
            OfficialCity = m.OfficialCity;
            Address = m.Address;
            ClientType = m.ClientType;
            LinkManName = m.LinkManName;
            TeleNum = m.TeleNum;
            Mobile = m.Mobile == "" ? m.TeleNum : m.Mobile;

            OfficialCityName = TreeTableBLL.GetFullPathName("MCS_SYS.dbo.Addr_OfficialCity", m.OfficialCity).Replace("->", " ");
            #endregion

            #region 绑定供货信息
            CM_ClientSupplierInfo SupplierInfo = ClientBLL.GetSupplierInfo(TDP);
            if (SupplierInfo != null)
            {
                CodeBySupplier = SupplierInfo.Code;
                Supplier = SupplierInfo.Supplier;
                StandardPrice = SupplierInfo.StandardPrice;
                TDPChannel = SupplierInfo.TDPChannel;
                TDPSalesArea = SupplierInfo.TDPSalesArea;
                VisitRoute = SupplierInfo.VisitRoute;
                VisitSequence = SupplierInfo.VisitSequence;
                VisitTemplate = SupplierInfo.VisitTemplate;

                #region 获取供货商名称
                CM_Client s = new CM_ClientBLL(Supplier).Model;
                if (s != null)
                {
                    SupplierName = s.ShortName == "" ? s.ShortName : s.FullName;
                }
                #endregion

                #region 获取价表名称
                if (StandardPrice != 0)
                {
                    PDT_StandardPrice price = new PDT_StandardPriceBLL(StandardPrice).Model;
                    if (price != null)
                    {
                        StandardPriceName = price.Name;
                    }
                }
                #endregion

                #region 获取渠道名称
                if (TDPChannel > 0)
                {
                    CM_RTChannel_TDP channel = new CM_RTChannel_TDPBLL(TDPChannel).Model;
                    if (channel != null) TDPChannelName = channel.Name;
                }
                #endregion

                #region 获取区域名称
                if (TDPSalesArea > 0)
                {
                    CM_RTSalesArea_TDP area = new CM_RTSalesArea_TDPBLL(TDPSalesArea).Model;
                    if (area != null) TDPSalesAreaName = area.Name;
                }
                #endregion

                #region 获取路线及拜访模板名称
                if (VisitRoute != 0)
                {
                    VST_Route r = new VST_RouteBLL(VisitRoute).Model;
                    if (r != null) VisitRouteName = r.Name;
                }

                if (VisitTemplate != 0)
                {
                    VST_VisitTemplate t = new VST_VisitTemplateBLL(VisitTemplate).Model;
                    if (t != null) VisitTemplateName = t.Name;
                }
                #endregion

                #region 获取销售员名称
                if (Salesman != 0)
                {
                    Org_Staff staff = new Org_StaffBLL(Salesman).Model;
                    if (staff != null) SalesmanName = staff.RealName;
                }
                #endregion

            }
            #endregion

            #region 绑定厂商管理信息
            int manufacturer = 0;           //归属厂商
            if (m.ClientType == 3)
            {
                //门店的归属厂商为当前TDP所归属的厂商
                CM_Client supplier = new CM_ClientBLL(TDP).Model;
                if (supplier != null) manufacturer = supplier.OwnerClient;
            }
            else if (m.ClientType == 2)
            {
                //TDP经销商的归属厂商
                manufacturer = m.OwnerClient;
            }

            CM_ClientManufactInfo ManufactInfo = ClientBLL.GetManufactInfo(manufacturer);
            if (ManufactInfo != null)
            {
                CodeByManufaturer = ManufactInfo.Code;
            }
            #endregion

            #region 绑定客户定位信息
            CM_ClientGeoInfo geo = CM_ClientGeoInfoBLL.GetGeoInfoByClient(m.ID);
            if (geo != null)
            {
                Latitude = (float)geo.Latitude;
                Longitude = (float)geo.Longitude;
            }
            #endregion

            #region 绑定客户供货产品目录
            ClientProductLists = new List<ProductList>();
            foreach (CM_ClientProductList item in CM_ClientProductListBLL.GetModelList
                ("Client=" + m.ID.ToString() + (TDP == 0 ? "" : " AND Supplier=" + TDP.ToString())))
            {
                ClientProductLists.Add(new ProductList(item));
            }
            #endregion

            #region 查询预收款余额
            AC_CurrentAccount ac = AC_CurrentAccountBLL.GetByTradeClient(TDP, m.ID);
            if (ac != null) ARBalance = ac.PreReceivedAmount - ac.AR;
            #endregion

            #region 获取附件明细
            IList<ATMT_Attachment> atts = ATMT_AttachmentBLL.GetAttachmentList(30, m.ID, DateTime.Today.AddMonths(-3), new DateTime(2100, 1, 1));
            Atts = new List<Attachment>(atts.Count);
            foreach (ATMT_Attachment item in atts.OrderByDescending(p => p.UploadTime))
            {
                Atts.Add(new Attachment(item));
            }
            #endregion
        }
Пример #21
0
        public string DoImportClient(int TemplateID, int Client, ISheet Sheet, out int State)
        {
            string ImportInfo = "【客户资料】Excel表:";

            State = 0;
            IPT_UploadTemplateBLL _template = new IPT_UploadTemplateBLL(TemplateID);

            List <string> listClient = new List <string>()
            {
                "序号", "区域", "渠道", "客户编号", "客户名称", "联系人", "地址", "电话", "手机", "销售线路", "备注"
            };

            DataTable dt   = null;
            bool      flag = VertifySheet(Sheet, listClient, out dt, ref ImportInfo);

            if (!flag)
            {
                State = 4; return(ImportInfo);
            }

            foreach (DataRow dr in dt.Rows)//循环导入数据
            {
                try
                {
                    string _ClientCode = dr["客户编号"].ToString();//客户自编码
                    string _ClientName = dr["客户名称"].ToString();

                    if (string.IsNullOrEmpty(_ClientCode))                                        // && string.IsNullOrEmpty(_ClientName)
                    {
                        ImportInfo += "导入序列号为" + dr["序号"].ToString() + "的数据行时找不到门店编码,跳过此行记录\r\n"; //门店名称和
                        continue;
                    }
                    IList <CM_Client> _listClient = CM_ClientBLL.GetModelList(" ApproveFlag=1 AND ClientType=3 AND OwnerType=3 AND OwnerClient=" + _template.Model.ClientID + "AND EXISTS(SELECT 1 FROM MCS_CM.dbo.CM_ClientSupplierInfo WHERE Supplier=" + _template.Model.ClientID + " AND Client= CM_Client.id  AND Code=" + _ClientCode + " ) ");
                    if (_listClient != null && _listClient.Count > 0)
                    {
                        ImportInfo += "导入序列号为" + dr["序号"].ToString() + "的数据行时找到相同编码的门店,跳过此行记录\r\n";
                        continue;
                    }

                    string _ClientLinkMan = dr["联系人"].ToString();
                    string _ClientAddress = dr["地址"].ToString();
                    string _ClientTel     = dr["电话"].ToString();
                    string _ClientMobile  = dr["手机"].ToString();
                    #region 获取线路
                    string    _strClientVisitRoute = dr["销售线路"].ToString();                                                                //业务拜访模板Code
                    VST_Route _route = null;
                    if (!string.IsNullOrEmpty(_strClientVisitRoute))                                                                       //优先匹配厂商级的拜访记录
                    {
                        _route = VST_RouteBLL.GetModelList(" OwnerType IN(1,2) AND Code='" + _strClientVisitRoute + "'").FirstOrDefault(); //IList<VST_Route>_listRoute
                        if (_route == null)                                                                                                //找不到厂商级的线路找经销商级别的
                        {
                            _route = VST_RouteBLL.GetModelList(" OwnerType=3 AND OwnerClient=" + _template.Model.ClientID + " AND Code='" + _strClientVisitRoute + "'").FirstOrDefault();
                        }
                    }

                    /*模板中存在负责业务时获取门店业代和拜访记录代码
                     * int _ClientSalesMan = 0;//负责业务
                     * int _ClientVisitRoute = 0;//业务拜访模板ID
                     * string _strClientSalesMan = dr["负责业务"].ToString();
                     * if (!string.IsNullOrEmpty(_strClientSalesMan))
                     * {
                     *  IList<Org_Staff> _listStaff = Org_StaffBLL.GetStaffList(" OwnerClient=" + _template.Model.ClientID + " AND OwnerType=3 AND RealName='" + _strClientSalesMan + "'");
                     *  if (_listStaff != null && _listStaff.Count > 0)
                     *  {
                     *      _ClientSalesMan = _listStaff[0].ID;
                     *      IList<VST_Route> _listRoute = VST_RouteBLL.GetModelList(" OwnerClient=" + _template.Model.ClientID + " AND RelateStaff=" + _ClientSalesMan);
                     *      if (_listRoute != null && _listRoute.Count > 0) _ClientVisitRoute = _listRoute[0].ID;
                     *  }
                     *  else
                     *  {
                     *      Org_StaffBLL _bllStaff = new Org_StaffBLL();
                     *      CM_ClientBLL c = new CM_ClientBLL(_template.Model.ClientID);
                     *      CM_ClientManufactInfo manufactinfo = c.GetManufactInfo();
                     *      if (c != null && manufactinfo != null)
                     *      {
                     *          _bllStaff.Model.OrganizeCity = manufactinfo.OrganizeCity;
                     *          _bllStaff.Model.OfficialCity = c.Model.OfficialCity;
                     *      }
                     *      _bllStaff.Model.RealName = _strClientSalesMan;
                     *      _bllStaff.Model.Position = 1030;//默认为业务员
                     *      _bllStaff.Model.InsertStaff = _template.Model.InsertStaff;
                     *      _bllStaff.Model.OwnerClient = _template.Model.ClientID;
                     *      _bllStaff.Model.OwnerType = 3;
                     *      _bllStaff.Model.Dimission = 1;
                     *      _bllStaff.Model.ApproveFlag = 1;
                     *      _ClientSalesMan = _bllStaff.Add();
                     *      //创建默认员工线路
                     *      if (_ClientSalesMan > 0)
                     *      {
                     *          if (_bllStaff.Model.Position == 1030)
                     *          {
                     *              VST_RouteBLL routebll = new VST_RouteBLL();
                     *              routebll.Model.Code = "R" + _ClientSalesMan.ToString();
                     *              routebll.Model.Name = "线路-" + _bllStaff.Model.RealName;
                     *              routebll.Model.RelateStaff = _ClientSalesMan;
                     *              routebll.Model.OrganizeCity = _bllStaff.Model.OrganizeCity;
                     *              routebll.Model.OwnerClient = _template.Model.ClientID;
                     *              routebll.Model.OwnerType = 3;
                     *              routebll.Model.ApproveFlag = 1;
                     *              routebll.Model.EnableFlag = "Y";
                     *              routebll.Model.InsertStaff = _template.Model.InsertStaff;
                     *              _ClientVisitRoute = routebll.Add();
                     *          }
                     *      }
                     *  }
                     * }*/
                    #endregion
                    string _ClientRemark = dr["备注"].ToString();

                    int _OwnerClient = _template.Model.ClientID;

                    #region 获取所在区域
                    int    _SalesArea    = 0;//区域
                    string _strSalesArea = dr["区域"].ToString();
                    if (!string.IsNullOrEmpty(_strSalesArea))
                    {
                        IList <CM_RTSalesArea_TDP> _listSalesArea = CM_RTSalesArea_TDPBLL.GetModelList(" OwnerClient= " + _OwnerClient.ToString() + " AND Name='" + _strSalesArea + "' ");
                        if (_listSalesArea != null && _listSalesArea.Count > 0)
                        {
                            _SalesArea = _listSalesArea[0].ID;
                        }
                        else
                        {
                            CM_RTSalesArea_TDPBLL _bllRTSalesArea_TDPBLL = new CM_RTSalesArea_TDPBLL();
                            _bllRTSalesArea_TDPBLL.Model.Name        = _strSalesArea;
                            _bllRTSalesArea_TDPBLL.Model.OwnerClient = _OwnerClient;
                            _bllRTSalesArea_TDPBLL.Model.Remark      = "Excel批量导入";
                            _bllRTSalesArea_TDPBLL.Model.InsertStaff = _template.Model.InsertStaff;
                            _bllRTSalesArea_TDPBLL.Model.InsertTime  = DateTime.Now;
                            _SalesArea = _bllRTSalesArea_TDPBLL.Add();
                        }
                    }
                    #endregion
                    #region 获取所在渠道
                    int    _RTChannel    = 0;//渠道
                    string _strRTChannel = dr["渠道"].ToString();
                    if (!string.IsNullOrEmpty(_strRTChannel))
                    {
                        IList <CM_RTChannel_TDP> _listRTChannel = CM_RTChannel_TDPBLL.GetModelList(" OwnerClient= " + _OwnerClient.ToString() + " AND Name='" + _strRTChannel + "' ");
                        if (_listRTChannel != null && _listRTChannel.Count > 0)
                        {
                            _RTChannel = _listRTChannel[0].ID;
                        }
                        else
                        {
                            CM_RTChannel_TDPBLL _bllRTSalesArea_TDPBLL = new CM_RTChannel_TDPBLL();
                            _bllRTSalesArea_TDPBLL.Model.Name        = _strRTChannel;
                            _bllRTSalesArea_TDPBLL.Model.OwnerClient = _OwnerClient;
                            _bllRTSalesArea_TDPBLL.Model.Remark      = "Excel批量导入";
                            _bllRTSalesArea_TDPBLL.Model.InsertStaff = _template.Model.InsertStaff;
                            _bllRTSalesArea_TDPBLL.Model.InsertTime  = DateTime.Now;
                            _RTChannel = _bllRTSalesArea_TDPBLL.Add();
                        }
                    }
                    #endregion

                    CM_ClientBLL _bll = new CM_ClientBLL();//Client表Code字段暂不启用,以FactoryCode作为厂商编码。经销商对门店的编码存于CM_ClientSupplierInfo表的Code字段
                    _bll.Model.FullName    = _ClientName;
                    _bll.Model.ShortName   = _ClientName;
                    _bll.Model.LinkManName = _ClientLinkMan;
                    _bll.Model.Address     = _ClientAddress;
                    _bll.Model.TeleNum     = _ClientTel;
                    _bll.Model.Mobile      = _ClientMobile;
                    _bll.Model.Remark      = string.IsNullOrEmpty(_ClientRemark) ? "Excel批量导入" : _ClientRemark;
                    _bll.Model.ClientType  = 3;
                    _bll.Model.ApproveFlag = 1;
                    _bll.Model.InsertStaff = _template.Model.InsertStaff;
                    _bll.Model.OwnerType   = 3;         //所属经销商
                    _bll.Model.OwnerClient = _OwnerClient;
                    int _ClientID = _bll.Add();
                    if (_ClientID > 0)
                    {
                        CM_ClientSupplierInfo _Supplierinfo = _bll.GetSupplierInfo(_OwnerClient);
                        if (_Supplierinfo == null)
                        {
                            _Supplierinfo          = new CM_ClientSupplierInfo();
                            _Supplierinfo.Supplier = _OwnerClient;
                        }
                        _Supplierinfo.TDPChannel   = _RTChannel;
                        _Supplierinfo.TDPSalesArea = _SalesArea;
                        _Supplierinfo.Code         = _ClientCode;
                        _Supplierinfo.Remark       = _ClientRemark;

                        CM_ClientBLL          s             = new CM_ClientBLL(_OwnerClient);
                        CM_ClientManufactInfo _manufactinfo = _bll.GetManufactInfo(s.Model.OwnerClient);
                        if (_manufactinfo == null)
                        {
                            _manufactinfo = new CM_ClientManufactInfo();
                            //门店所属区域为经销商对应区域
                            _manufactinfo.Manufacturer = s.Model.OwnerClient;
                            _manufactinfo.OrganizeCity = s.GetManufactInfo().OrganizeCity;
                        }

                        if (_route != null && _route.OwnerType == 3)//线路为经销商级别的存放在经销商表中
                        {
                            _Supplierinfo.VisitRoute = _route.ID;
                        }
                        else if (_route != null && (_route.OwnerType == 1 || _route.OwnerType == 2))//线路为厂商级别的存放在经销商表中
                        {
                            _manufactinfo.VisitRoute = _route.ID;
                        }

                        _bll.SetSupplierInfo(_Supplierinfo);
                        _bll.SetManufactInfo(_manufactinfo);
                    }
                }
                catch (Exception ex)
                {
                    ImportInfo += "导入序列号为" + dr["序号"].ToString() + "的数据行时出现错误,错误说明:" + ex.Message + "\r\n";
                    State       = 5;
                    continue;
                }
            }
            if (State == 0)
            {
                State = 3;
            }
            ImportInfo += (State == 3 ? "导入完成!\r\n" : "");
            IPT_UploadTemplateMessageBLL _bllUploadTemplateMessage = new IPT_UploadTemplateMessageBLL();
            _bllUploadTemplateMessage.Model.TemplateID  = TemplateID;
            _bllUploadTemplateMessage.Model.MessageType = State;
            _bllUploadTemplateMessage.Model.Content     = ImportInfo;
            _bllUploadTemplateMessage.Add();
            return(ImportInfo);
        }
 private void CreateRoute(string name, int organizecity)
 {
     VST_RouteBLL routebll = new VST_RouteBLL();
     routebll.Model.Code = "R" + ViewState["ID"].ToString();
     routebll.Model.Name = "线路-" + name;
     routebll.Model.RelateStaff = (int)ViewState["ID"];
     routebll.Model.OrganizeCity = organizecity;
     routebll.Model.OwnerClient = (int)Session["OwnerClient"];
     routebll.Model.OwnerType = (int)Session["OwnerType"];
     routebll.Model.ApproveFlag = 1;
     routebll.Model.EnableFlag = "Y";
     routebll.Model.InsertStaff = (int)Session["UserID"];
     routebll.Add();
 }