Esempio n. 1
0
        /// <summary>
        /// 帐号登录
        /// </summary>
        /// <param name="UserName"></param>
        /// <param name="Password"></param>
        /// <returns></returns>
        private static int userlogin(string UserName, string Password, string DeviceCode, string ExtPropertys, out string AuthKey)
        {
            if (ConfigHelper.GetConfigBool("DebugMode"))
            {
                LogWriter.WriteLog("UserLogin.Login:UserName="******",Password="******"";
            if (Membership.ValidateUser(UserName, Password))
            {
                UserInfo User = new UserInfo(UserName);

                #region 判断门店状态是否可以登录
                //if (user.ClientID > 0 && user.ClientType == 3)
                //{
                //    CM_Client _c = new CM_ClientBLL(user.ClientID).Model;

                //    //会员店已中止合作
                //    if (_c == null || _c.ActiveFlag == 2) return -11;

                //    //会员店状态不为已启动、准备启动状态
                //    if (_c["IsRMSClient"] == "2" || _c["IsRMSClient"] == "8") return -12;

                //    //会员店为流通店
                //    //if (_c["RTClassify"] == "1") return -13;
                //}
                #endregion

                AuthKey         = Guid.NewGuid().ToString();
                User.DeviceCode = DeviceCode;

                string cachekey = "EBMIF_OnlineUser-" + AuthKey;
                DataCache.SetCache(cachekey, User, System.Web.Caching.Cache.NoAbsoluteExpiration, new TimeSpan(0, 20, 0));

                cachekey = "EBMIF_DeviceCryptKey-" + DeviceCode;
                DeviceCryptKey cryptkey = (DeviceCryptKey)DataCache.GetCache(cachekey);
                if (cryptkey != null)
                {
                    cryptkey.AuthKey = AuthKey;
                }

                HttpRequest Requst = HttpContext.Current.Request;
                string      IpAddr = Requst.UserHostAddress;

                UserBLL.LoginSuccess(UserName, AuthKey, IpAddr, DeviceCode, JsonConvert.SerializeObject(User), JsonConvert.SerializeObject(cryptkey), ExtPropertys);
                return(1);
            }
            else if (UserName.StartsWith("1") && UserName.Length == 11 && Membership.GetUser(UserName) == null)
            {
                IList <Org_Staff> staffs = Org_StaffBLL.GetStaffList("Mobile='" + UserName + "' AND Dimission=1 AND ApproveFlag=1");
                if (staffs.Count == 1)
                {
                    DataTable dt = new Org_StaffBLL(staffs[0].ID).GetUserList();
                    if (dt.Rows.Count > 0)
                    {
                        return(userlogin(dt.Rows[0]["UserName"].ToString(), Password, DeviceCode, ExtPropertys, out AuthKey));
                    }
                }
            }
            return(-2);
        }
 private void BindDropDown()
 {
     ddl_Salesman.DataSource = Org_StaffBLL.GetStaffList("Org_Staff.ID IN (SELECT SalesMan FROM MCS_PBM.dbo.PBM_Order WHERE Supplier=" + Session["OwnerClient"].ToString() +
                                                         " AND InsertTime>DATEADD(MONTH,-6,GETDATE()) ) AND Org_Staff.Dimission = 1");
     ddl_Salesman.DataBind();
     ddl_Salesman.Items.Insert(0, new ListItem("请选择...", "0"));
 }
 protected void ddl_Position_Selected(object sender, MCSControls.MCSWebControls.SelectedEventArgs e)
 {
     if (e.CurSelectIndex != 0)
     {
         int position = e.CurSelectIndex;
         ddl_Staff.DataSource = Org_StaffBLL.GetStaffList("Position=" + position.ToString());
         ddl_Staff.DataBind();
     }
 }
    private void BindDropDown()
    {
        ddl_SupplierWareHouse.DataSource = CM_WareHouseBLL.GetByClient((int)Session["OwnerClient"]).Where(p => p.Classify == 1);
        ddl_SupplierWareHouse.DataBind();

        ddl_Salesman.DataSource = Org_StaffBLL.GetStaffList("Org_Staff.OwnerClient=" + Session["OwnerClient"].ToString() + " AND Dimission=1");
        ddl_Salesman.DataBind();
        ddl_Salesman.Items.Insert(0, new ListItem("请选择", "0"));
    }
    private void BindDropDown()
    {
        ddl_Salesman.DataSource = Org_StaffBLL.GetStaffList("Org_Staff.OwnerClient=" + Session["OwnerClient"].ToString());
        ddl_Salesman.DataBind();
        ddl_Salesman.Items.Insert(0, new ListItem("请选择...", "0"));

        ddl_DeliveryMan.DataSource = Org_StaffBLL.GetStaffList("Org_Staff.OwnerClient=" + Session["OwnerClient"].ToString());
        ddl_DeliveryMan.DataBind();
        ddl_DeliveryMan.Items.Insert(0, new ListItem("请选择送货人员...", "0"));
    }
    private void BindDropDown()
    {
        ddl_SupplierWareHouse.DataSource = CM_WareHouseBLL.GetByClient((int)Session["OwnerClient"]);
        ddl_SupplierWareHouse.DataBind();
        ddl_SupplierWareHouse.Items.Insert(0, new ListItem("请选择...", "0"));

        ddl_ClientWareHouse.DataSource = CM_WareHouseBLL.GetByClient((int)Session["OwnerClient"]);
        ddl_ClientWareHouse.DataBind();
        ddl_ClientWareHouse.Items.Insert(0, new ListItem("请选择...", "0"));

        ddl_Salesman.DataSource = Org_StaffBLL.GetStaffList("Org_Staff.OwnerClient=" + Session["OwnerClient"].ToString());
        ddl_Salesman.DataBind();
        ddl_Salesman.SelectedValue = Session["UserID"].ToString();
    }
    private void BindDropDown()
    {
        ddl_Supplier.DataSource = CM_ClientBLL.GetSupplierByTDP((int)Session["OwnerClient"]).OrderBy(p => p.FullName);
        ddl_Supplier.DataBind();
        ddl_Supplier.Items.Insert(0, new ListItem("请选择...", "0"));

        //ddl_State.DataSource = DictionaryBLL.GetDicCollections("PBM_DeliveryState");
        //ddl_State.DataBind();
        //ddl_State.Items.Insert(0, new ListItem("请选择...", "0"));

        ddl_Salesman.DataSource = Org_StaffBLL.GetStaffList("Org_Staff.ID IN (SELECT SalesMan FROM MCS_PBM.dbo.PBM_Delivery WHERE Supplier=" + Session["OwnerClient"].ToString() +
                                                            " AND InsertTime>DATEADD(MONTH,-6,GETDATE()) ) AND Org_Staff.Dimission = 1");
        ddl_Salesman.DataBind();
        ddl_Salesman.Items.Insert(0, new ListItem("请选择...", "0"));
    }
    private void BindDropDown()
    {
        ddl_Supplier.DataSource = CM_ClientBLL.GetSupplierByTDP((int)Session["OwnerClient"]).OrderBy(p => p.FullName);
        ddl_Supplier.DataBind();

        CM_Client _c = new CM_ClientBLL((int)Session["OwnerClient"]).Model;

        if (_c != null && ddl_Supplier.Items.FindByValue(_c.OwnerClient.ToString()) != null)
        {
            ddl_Supplier.SelectedValue = _c.OwnerClient.ToString();
        }

        ddl_AgentStaff.DataSource = Org_StaffBLL.GetStaffList("Org_Staff.OwnerClient=" + Session["OwnerClient"].ToString() + " AND Org_Staff.Dimission=1");
        ddl_AgentStaff.DataBind();
        ddl_AgentStaff.Items.Insert(0, new ListItem("请选择", "0"));
    }
    private void BindDropDown()
    {
        ddl_Supplier.DataSource = CM_ClientBLL.GetSupplierByTDP((int)Session["OwnerClient"]).OrderBy(p => p.FullName);
        ddl_Supplier.DataBind();

        CM_Client _c = new CM_ClientBLL((int)Session["OwnerClient"]).Model;

        if (_c != null && ddl_Supplier.Items.FindByValue(_c.OwnerClient.ToString()) != null)
        {
            ddl_Supplier.SelectedValue = _c.OwnerClient.ToString();
        }

        ddl_ClientWareHouse.DataSource = CM_WareHouseBLL.GetByClient((int)Session["OwnerClient"]).Where(p => p.Classify == 1);
        ddl_ClientWareHouse.DataBind();

        ddl_Salesman.DataSource = Org_StaffBLL.GetStaffList("Org_Staff.OwnerClient=" + Session["OwnerClient"].ToString() + " AND Org_Staff.Dimission=1");
        ddl_Salesman.DataBind();
    }
Esempio n. 10
0
    protected void bt_OK_Click(object sender, EventArgs e)
    {
        Org_StaffBLL _staffbll = null;

        if ((int)ViewState["ID"] == 0)
        {
            _staffbll = new Org_StaffBLL();
        }
        else
        {
            _staffbll = new Org_StaffBLL((int)ViewState["ID"]);
        }

        int oldPosition     = _staffbll.Model.Position;
        int oldOrganizeCity = _staffbll.Model.OrganizeCity;

        panel1.GetData(_staffbll.Model);

        Org_Staff _staffM = new Org_StaffBLL((int)Session["UserID"]).Model;

        if ((int)ViewState["ID"] == 0)
        {
            #region 根据身份证号判断是否重复
            if (_staffbll.Model["IDCode"] != string.Empty &&
                Org_StaffBLL.GetStaffList("IDCode='" + _staffbll.Model["IDCode"] + "' AND Dimission=1").Count > 0)
            {
                MessageBox.Show(this, "对不起,该身份证号的员工已在系统中入职,请核实后再新增员工!");
                return;
            }
            #endregion

            _staffbll.Model.InsertStaff = (int)Session["UserID"];
            _staffbll.Model.InsertTime  = DateTime.Now;
            _staffbll.Model.ApproveFlag = 2;            //未审批
            _staffbll.Model.Dimission   = 1;            //在职
            ViewState["ID"]             = _staffbll.Add();
        }
        else
        {
            _staffbll.Model.UpdateStaff = (int)Session["UserID"];
            _staffbll.Update();
        }
        MessageBox.ShowAndRedirect(this, "保存成功", "StaffDetail.aspx?ID=" + ViewState["ID"].ToString());
    }
Esempio n. 11
0
    private void BindDropDown()
    {
        string condition = " Org_Staff.OwnerClient=" + Session["OwnerClient"].ToString() +
                           " AND Dimission=1 AND Position IN (1030,1050)";

        cbx_Staff.DataSource = Org_StaffBLL.GetStaffList(condition);
        cbx_Staff.DataBind();

        DropDownList ddl_RelateStaff = (DropDownList)pl_detail.FindControl("CM_Vehicle_RelateStaff");

        if (ddl_RelateStaff != null)
        {
            ddl_RelateStaff.DataTextField  = "RealName";
            ddl_RelateStaff.DataValueField = "ID";
            ddl_RelateStaff.DataSource     = Org_StaffBLL.GetStaffList(condition);
            ddl_RelateStaff.DataBind();
            ddl_RelateStaff.Items.Insert(0, new ListItem("请选择...", "0"));
        }
    }
Esempio n. 12
0
    void tr_OrganizeCity_Selected(object sender, SelectedEventArgs e)
    {
        int city = 0;

        if (tr_OrganizeCity != null)
        {
            int.TryParse(tr_OrganizeCity.SelectValue, out city);
        }

        if (city > 0 && ddl_RelateStaff != null)
        {
            #region 判断当前可查询的管理区域范围
            string orgcitys = "";
            if ((int)Session["OwnerType"] != 3 && tr_OrganizeCity.SelectValue != "1")
            {
                Addr_OrganizeCityBLL orgcity = new Addr_OrganizeCityBLL(int.Parse(tr_OrganizeCity.SelectValue), true);
                orgcitys = orgcity.GetAllChildNodeIDs();
                if (orgcitys != "")
                {
                    orgcitys += ",";
                }
                orgcitys += tr_OrganizeCity.SelectValue;

                if (orgcitys != "")
                {
                    string ConditionStr = " Org_Staff.OwnerClient=" + Session["OwnerClient"].ToString() + " AND Dimission=1";
                    ConditionStr += " AND Org_Staff.OrganizeCity IN (" + orgcitys + ") AND Org_Staff.OwnerType=" + Session["OwnerType"].ToString();

                    try
                    {
                        ddl_RelateStaff.DataTextField  = "RealName";
                        ddl_RelateStaff.DataValueField = "ID";
                        ddl_RelateStaff.DataSource     = Org_StaffBLL.GetStaffList(ConditionStr);
                        ddl_RelateStaff.DataBind();
                        ddl_RelateStaff.Items.Insert(0, new ListItem("请选择...", "0"));
                    }
                    catch { }
                }
            }
            #endregion
        }
    }
Esempio n. 13
0
 private void BindDropDown()
 {
     if ((int)Session["OwnerType"] == 3)
     {
         if (tr_OrganizeCity != null)
         {
             tr_OrganizeCity.Enabled = false;
         }
         if (ddl_RelateStaff != null)
         {
             ddl_RelateStaff.DataTextField  = "RealName";
             ddl_RelateStaff.DataValueField = "ID";
             ddl_RelateStaff.DataSource     = Org_StaffBLL.GetStaffList("Org_Staff.OwnerClient=" + Session["OwnerClient"].ToString() + " AND Dimission=1");
             ddl_RelateStaff.DataBind();
             ddl_RelateStaff.Items.Insert(0, new ListItem("请选择...", "0"));
         }
     }
     else
     {
     }
 }
    private void BindDropDown()
    {
        ddl_Position.DataSource = Org_PositionBLL.GetAllPostion();
        ddl_Position.DataBind();

        if (Request.QueryString["StaffID"] != null)
        {
            int       staffid = int.Parse(Request.QueryString["StaffID"]);
            Org_Staff staff   = new Org_StaffBLL(staffid).Model;
            if (staff != null)
            {
                ddl_Position.SelectValue = staff.Position.ToString();
                ddl_Staff.DataSource     = Org_StaffBLL.GetStaffList("Position=" + staff.Position.ToString());
                ddl_Staff.DataBind();
                ddl_Staff.SelectedValue = staff.ID.ToString();
            }
        }
        else
        {
            ddl_Staff.DataSource = Org_StaffBLL.GetStaffList("Position=" + ddl_Position.SelectValue);
            ddl_Staff.DataBind();
        }
    }
    protected void bt_OK_Click(object sender, EventArgs e)
    {
        Org_StaffBLL _staffbll = null;

        if ((int)ViewState["ID"] == 0)
        {
            _staffbll = new Org_StaffBLL();
        }
        else
        {
            _staffbll = new Org_StaffBLL((int)ViewState["ID"]);
        }

        int oldPosition     = _staffbll.Model.Position;
        int oldOrganizeCity = _staffbll.Model.OrganizeCity;

        panel1.GetData(_staffbll.Model);

        if ((int)ViewState["ID"] != 0 && (oldPosition != _staffbll.Model.Position || oldOrganizeCity != _staffbll.Model.OrganizeCity) &&
            EWF_Task_JobDecisionBLL.GetModelList("DecisionResult=1 AND RecipientStaff=" + ViewState["ID"].ToString()).Count > 0)
        {
            MessageBox.Show(this, "对不起,该人员还有未审批流程不能调整【职务】或【管理片区】信息!");
            return;
        }
        Addr_OfficialCityBLL citybll = new Addr_OfficialCityBLL(_staffbll.Model.OfficialCity);

        if (citybll != null && citybll.Model.Level < 2)
        {
            MessageBox.Show(this, "驻点所在城市必须选到市级!");
            return;
        }

        Org_Staff _staffM = new Org_StaffBLL((int)Session["UserID"]).Model;

        if (_staffM.Position == _staffbll.Model.Position && new Org_PositionBLL(_staffM.Position).Model.IsHeadOffice != "Y")
        {
            MessageBox.Show(this, "对不起,您没有权限新增职位与您相同的员工");
            return;
        }

        if (_staffbll.Model["OperateProperty"] == "0")
        {
            MessageBox.Show(this, "归属办事处类型必填!");
            return;
        }

        if ((int)ViewState["ID"] == 0)
        {
            #region 根据身份证号判断是否重复
            if (_staffbll.Model["IDCode"] != string.Empty &&
                Org_StaffBLL.GetStaffList("MCS_SYS.dbo.UF_Spilt(Org_Staff.ExtPropertys,'|',1)='" + _staffbll.Model["IDCode"] + "' AND Dimission=1").Count > 0)
            {
                MessageBox.Show(this, "对不起,该身份证号的员工已在系统中入职,请核实后再新增员工!");
                return;
            }
            #endregion

            if (Org_StaffNumberLimitBLL.CheckAllowAdd(_staffbll.Model.OrganizeCity, _staffbll.Model.Position) <= 0)
            {
                MessageBox.Show(this, "对不起当前城市该职位员工人数满额,要想继续新增请与人事经理联系");
                return;
            }
            _staffbll.Model.InsertStaff = (int)Session["UserID"];
            _staffbll.Model.InsertTime  = DateTime.Now;
            _staffbll.Model.ApproveFlag = 1;            //未审批
            _staffbll.Model.Dimission   = 1;            //在职
            ViewState["ID"]             = _staffbll.Add();
        }
        else
        {
            if (!Org_StaffNumberLimitBLL.IsSameLimit(oldOrganizeCity, _staffbll.Model.OrganizeCity, oldPosition, _staffbll.Model.Position) &&
                Org_StaffNumberLimitBLL.CheckAllowAdd(_staffbll.Model.OrganizeCity, _staffbll.Model.Position) <= 0)
            {
                MessageBox.Show(this, "对不起当前城市该职位员工人数满额,要想继续新增请与人事经理联系");
                return;
            }
            _staffbll.Model.UpdateStaff = (int)Session["UserID"];
            _staffbll.Update();
        }
        MessageBox.ShowAndRedirect(this, "保存成功", "StaffDetail.aspx?ID=" + ViewState["ID"].ToString());
    }
 private void BindDropDown()
 {
     ddl_AgentStaff.DataSource = Org_StaffBLL.GetStaffList("Org_Staff.OwnerClient=" + Session["OwnerClient"].ToString() + " AND Dimission=1");
     ddl_AgentStaff.DataBind();
     ddl_AgentStaff.Items.Insert(0, new ListItem("请选择", "0"));
 }
    protected void bt_Create_Click(object sender, EventArgs e)
    {
        DateTime begindate = DateTime.Parse(tbx_begindate.Text);
        DateTime enddate   = DateTime.Parse(tbx_enddate.Text);

        #region 规则校验
        if (select_PlanStaff.SelectValue == "")
        {
            MessageBox.Show(this, "请正确选择要填报计划的员工!");
            return;
        }
        if (begindate < DateTime.Today)
        {
            MessageBox.Show(this, "开始日期不能小于今天!");
            return;
        }

        if (enddate < begindate)
        {
            MessageBox.Show(this, "截止日期必须大于开始日期!");
            return;
        }

        if ((enddate - begindate).Days > 31)
        {
            MessageBox.Show(this, "日期范围不能超过一个月!");
            return;
        }

        if (JN_WorkingPlanBLL.GetModelList("Staff = " + select_PlanStaff.SelectValue +
                                           " AND ( (BeginDate BETWEEN '" + begindate.ToString("yyyy-MM-dd") + "' AND '" + enddate.ToString("yyyy-MM-dd") +
                                           "') OR ('" + begindate.ToString("yyyy-MM-dd") + "' BETWEEN BeginDate AND EndDate) )").Count > 0)
        {
            MessageBox.Show(this, "日期范围与系统中已填报的计划有日期重叠!");
            return;
        }
        #endregion

        InitGridView(begindate, enddate);
        DataTable dt = GenareateDataTable(begindate, enddate);

        #region 页面控件使能控制
        tr_adddetail.Visible     = true;
        tbx_begindate.Enabled    = false;
        tbx_enddate.Enabled      = false;
        select_PlanStaff.Enabled = false;
        tr_OrganizeCity.Enabled  = false;

        cbx_GenarateSynergetic.Visible = false;
        bt_Create.Visible = false;
        bt_Save.Visible   = true;
        #endregion

        #region 载入该操作员所有负责客户,加入客户拜访记录计划中
        IList <CM_Client> clients = CM_ClientBLL.GetModelList("ClientManager=" + select_PlanStaff.SelectValue + " AND ActiveFlag=1 AND ApproveFlag=1");

        foreach (CM_Client client in clients)
        {
            DataRow dr = dt.NewRow();

            dr["WorkingClassify"]     = "1";
            dr["WorkingClassifyName"] = DictionaryBLL.GetDicCollections("OA_WorkingClassify")["1"].Name;

            dr["RelateClient"]     = client.ID;
            dr["RelateClientName"] = client.FullName;

            dr["RelateStaff"]     = 0;
            dr["RelateStaffName"] = "";

            dr["OfficialCity"] = client.OfficalCity;
            if (client.OfficalCity > 0)
            {
                dr["OfficialCityName"] = TreeTableBLL.GetFullPathName("MCS_SYS.dbo.Addr_OfficialCity", client.OfficalCity).Replace("->", " ");
            }

            dt.Rows.Add(dr);
        }
        #endregion

        #region 加入协同拜访工作项,管理片区非总部员工,将所有下级员工加入
        if (cbx_GenarateSynergetic.Checked && int.Parse(tr_OrganizeCity.SelectValue) > 1)
        {
            #region 所有下级职位(不含本级职位)
            string    positions          = "";
            int       position           = new Org_StaffBLL(int.Parse(select_PlanStaff.SelectValue)).Model.Position;
            DataTable dtAllChilePosition = TreeTableBLL.GetAllChildByNodes("MCS_SYS.dbo.Org_Position", "ID", "SuperID", position.ToString());
            for (int i = 0; i < dtAllChilePosition.Rows.Count; i++)
            {
                positions += dtAllChilePosition.Rows[i]["ID"].ToString();
                if (i != dtAllChilePosition.Rows.Count - 1)
                {
                    positions += ",";
                }
            }
            #endregion

            #region 所有本级及下级管理片区
            string orgcitys = "";
            Addr_OrganizeCityBLL orgcity = new Addr_OrganizeCityBLL(int.Parse(tr_OrganizeCity.SelectValue), true);
            orgcitys = orgcity.GetAllChildNodeIDs();
            if (orgcitys != "")
            {
                orgcitys += ",";
            }
            orgcitys += tr_OrganizeCity.SelectValue;
            #endregion

            if (positions != "" && orgcitys != "")
            {
                IList <Org_Staff> staffs = Org_StaffBLL.GetStaffList("OrganizeCity IN (" + orgcitys + ") AND Position IN (" + positions + ") AND Dimission=1 AND ApproveFlag=1");

                foreach (Org_Staff staff in staffs)
                {
                    DataRow dr = dt.NewRow();

                    dr["WorkingClassify"]     = "2";
                    dr["WorkingClassifyName"] = DictionaryBLL.GetDicCollections("OA_WorkingClassify")["2"].Name;

                    dr["RelateClient"]     = 0;
                    dr["RelateClientName"] = "";

                    dr["RelateStaff"]     = staff.ID;
                    dr["RelateStaffName"] = staff.RealName;

                    dr["OfficialCity"] = staff.OfficialCity;
                    if (staff.OfficialCity > 0)
                    {
                        dr["OfficialCityName"] = TreeTableBLL.GetFullPathName("MCS_SYS.dbo.Addr_OfficialCity", staff.OfficialCity).Replace("->", " ");
                    }

                    dt.Rows.Add(dr);
                }
            }
        }
        #endregion

        #region 加入除客户拜访以外的工作项
        foreach (ListItem item in ddl_WorkingClassify.Items)
        {
            if (int.Parse(item.Value) >= 3)
            {
                DataRow dr = dt.NewRow();
                dr["WorkingClassify"]     = int.Parse(item.Value);
                dr["WorkingClassifyName"] = item.Text;
                dr["Description"]         = "";
                dr["RelateClient"]        = 0;
                dr["RelateClientName"]    = "";

                dr["RelateStaff"]     = 0;
                dr["RelateStaffName"] = "";

                dr["OfficialCity"] = (int)ViewState["StaffOfficialCity"];
                if (ViewState["StaffOfficialCity"] != null && (int)ViewState["StaffOfficialCity"] != 0)
                {
                    dr["OfficialCityName"] = new Addr_OfficialCityBLL((int)ViewState["StaffOfficialCity"]).Model.Name;
                }
                else
                {
                    dr["OfficialCity"] = 0;
                }

                dr["Cost1"] = 0;
                dr["Cost2"] = 0;
                dt.Rows.Add(dr);
            }
        }
        #endregion

        ViewState["WorkingPlanData"] = dt;
        ViewState["BeginDate"]       = begindate;
        ViewState["EndDate"]         = enddate;

        BindGrid();
    }
Esempio n. 18
0
 /// <summary>
 /// 获取车辆关联的员工
 /// </summary>
 /// <param name="Vehicle">车辆ID</param>
 /// <returns></returns>
 public static IList <Org_Staff> GetStaffByVehicle(int Vehicle)
 {
     return(Org_StaffBLL.GetStaffList("ID IN (SELECT Staff FROM MCS_CM.dbo.CM_VehicleInStaff WHERE Vehicle = " + Vehicle.ToString() + ") AND Dimission=1"));
 }
Esempio n. 19
0
 private void BindDropDown()
 {
     ddl_Salesman.DataSource = Org_StaffBLL.GetStaffList("Org_Staff.OwnerClient=" + Session["OwnerClient"].ToString());
     ddl_Salesman.DataBind();
 }
    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
    }
Esempio n. 21
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);
        }
    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());
            }
        }
    }