예제 #1
0
    private void BindData()
    {
        CM_Vehicle m = new CM_VehicleBLL((int)ViewState["ID"]).Model;

        if (m != null)
        {
            if (m.Client != (int)Session["OwnerClient"])
            {
                Response.Redirect("~/SubModule/Desktop.aspx");
            }

            pl_detail.BindData(m);
            if (m.ApproveFlag == 1)
            {
                bt_Approve.Visible = false;
            }

            foreach (Org_Staff staff in CM_VehicleInStaffBLL.GetStaffByVehicle(m.ID))
            {
                ListItem item = cbx_Staff.Items.FindByValue(staff.ID.ToString());
                if (item != null)
                {
                    item.Selected = true;
                }
            }
        }
    }
    protected void ddl_DeliveryMan_SelectedIndexChanged(object sender, EventArgs e)
    {
        int staff = 0;

        int.TryParse(ddl_DeliveryMan.SelectedValue, out staff);

        if (staff != 0)
        {
            ddl_DeliveryVehicle.DataSource = CM_VehicleInStaffBLL.GetVehicleByStaff(staff);
            ddl_DeliveryVehicle.DataBind();
            ddl_DeliveryVehicle_SelectedIndexChanged(null, null);
        }
    }
예제 #3
0
    protected void bt_OK_Click(object sender, EventArgs e)
    {
        CM_VehicleBLL _bll;

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

        pl_detail.GetData(_bll.Model);

        #region 判断必填项
        if (_bll.Model.VehicleClassify == 0)
        {
            MessageBox.Show(Page, "车辆类别必选");
            return;
        }
        if (_bll.Model.State == 0)
        {
            MessageBox.Show(Page, "车牌状态必选");
            return;
        }

        #endregion
        if ((int)ViewState["ID"] != 0)
        {
            //修改
            _bll.Model.UpdateStaff = (int)Session["UserID"];
            if (_bll.Update() == 0)
            {
            }
        }
        else
        {
            //新增
            _bll.Model.InsertStaff = (int)Session["UserID"];
            _bll.Model.Client      = (int)Session["OwnerClient"];
            _bll.Model.ApproveFlag = 2;
            ViewState["ID"]        = _bll.Add();

            if ((int)ViewState["ID"] > 0)
            {
            }
        }

        if (_bll.Model.RelateStaff > 0)
        {
            ListItem item = cbx_Staff.Items.FindByValue(_bll.Model.RelateStaff.ToString());
            if (item != null && !item.Selected)
            {
                item.Selected = true;
            }
        }

        foreach (ListItem item in cbx_Staff.Items)
        {
            IList <CM_VehicleInStaff> lists = CM_VehicleInStaffBLL.GetModelList("Vehicle=" + ViewState["ID"].ToString() + " AND Staff=" + item.Value);
            if (item.Selected)
            {
                if (lists.Count == 0)
                {
                    CM_VehicleInStaffBLL b = new CM_VehicleInStaffBLL();
                    b.Model.Vehicle     = (int)ViewState["ID"];
                    b.Model.Staff       = int.Parse(item.Value);
                    b.Model.InsertStaff = (int)Session["UserID"];
                    b.Add();
                }
            }
            else
            {
                if (lists.Count > 0)
                {
                    CM_VehicleInStaffBLL b = new CM_VehicleInStaffBLL(lists[0].ID);
                    b.Delete();
                }
            }
        }

        if (_bll.Model.ApproveFlag == 2)
        {
            Response.Redirect("VehicleDetail.aspx?ID=" + ViewState["ID"].ToString());
        }
        else
        {
            Response.Redirect("VehicleList.aspx");
        }
    }
    protected void bt_OK_Click(object sender, EventArgs e)
    {
        CM_VehicleBLL _bll;
        if ((int)ViewState["ID"] != 0)
        {
            //修改
            _bll = new CM_VehicleBLL((int)ViewState["ID"]);
        }
        else
        {
            //新增
            _bll = new CM_VehicleBLL();
        }

        pl_detail.GetData(_bll.Model);

        #region 判断必填项
        if (_bll.Model.VehicleClassify == 0)
        {
            MessageBox.Show(Page, "车辆类别必选");
            return;
        }
        if (_bll.Model.State == 0)
        {
            MessageBox.Show(Page, "车牌状态必选");
            return;
        }

        #endregion
        if ((int)ViewState["ID"] != 0)
        {
            //修改
            _bll.Model.UpdateStaff = (int)Session["UserID"];
            if (_bll.Update() == 0)
            {

            }
        }
        else
        {
            //新增
            _bll.Model.InsertStaff = (int)Session["UserID"];
            _bll.Model.Client = (int)Session["OwnerClient"];
            _bll.Model.ApproveFlag = 2;
            ViewState["ID"] = _bll.Add();

            if ((int)ViewState["ID"] > 0)
            {

            }
        }

        if (_bll.Model.RelateStaff > 0)
        {
            ListItem item = cbx_Staff.Items.FindByValue(_bll.Model.RelateStaff.ToString());
            if (item != null && !item.Selected) item.Selected = true;
        }

        foreach (ListItem item in cbx_Staff.Items)
        {
            IList<CM_VehicleInStaff> lists = CM_VehicleInStaffBLL.GetModelList("Vehicle=" + ViewState["ID"].ToString() + " AND Staff=" + item.Value);
            if (item.Selected)
            {
                if (lists.Count == 0)
                {
                    CM_VehicleInStaffBLL b = new CM_VehicleInStaffBLL();
                    b.Model.Vehicle = (int)ViewState["ID"];
                    b.Model.Staff = int.Parse(item.Value);
                    b.Model.InsertStaff = (int)Session["UserID"];
                    b.Add();
                }
            }
            else
            {
                if (lists.Count > 0)
                {
                    CM_VehicleInStaffBLL b = new CM_VehicleInStaffBLL(lists[0].ID);
                    b.Delete();
                }
            }
        }

        if (_bll.Model.ApproveFlag == 2)
            Response.Redirect("VehicleDetail.aspx?ID=" + ViewState["ID"].ToString());
        else
            Response.Redirect("VehicleList.aspx");
    }
예제 #5
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;
        }
예제 #6
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);
        }