private void BindTree(TreeNodeCollection TNC, int SuperID) { IList <Org_Position> _positionlist = Org_PositionBLL.GetModelList("SuperID=" + SuperID.ToString()); foreach (Org_Position _position in _positionlist) { TreeNode tn = new TreeNode(); tn.Text = _position.Name + "(" + _position.ID.ToString() + ")"; tn.Value = _position.ID.ToString(); TNC.Add(tn); BindTree(tn.ChildNodes, _position.ID); } }
private void BindDropDown() { Org_StaffBLL staff = new Org_StaffBLL((int)Session["UserID"]); string condition = "ApproveFlag=1"; #region 绑定考核方案 switch ((int)ViewState["CheckType"]) { case 0: // Response.Redirect("~/SubModule/desktop.aspx"); break; case 1: condition += " and RelatePosition=" + staff.Model.Position.ToString() + " AND ID IN (SELECT Scheme FROM MCS_OA.dbo.KPI_SchemeDetail WHERE AllowSelfcheck=1)"; gv_List.Columns[gv_List.Columns.Count - 4].Visible = false; gv_List.Columns[gv_List.Columns.Count - 3].Visible = false; gv_List.Columns[gv_List.Columns.Count - 2].Visible = false; break; case 2: condition += " AND ID IN (SELECT Scheme FROM MCS_OA.dbo.KPI_SchemeDetail WHERE CheckPosition=" + staff.Model.Position.ToString() + ")"; gv_List.Columns[gv_List.Columns.Count - 3].Visible = false; gv_List.Columns[gv_List.Columns.Count - 2].Visible = false; break; case 3: condition += " AND ID IN (SELECT Scheme FROM MCS_OA.dbo.KPI_SchemeDetail WHERE ApprovePosition=" + staff.Model.Position.ToString() + ")"; break; } ddl_KPI_Scheme.DataSource = KPI_SchemeBLL.GetModelList(condition); ddl_KPI_Scheme.DataBind(); ddl_KPI_Scheme.Items.Insert(0, new ListItem("请选择", "0")); #endregion #region ddl_Position.DataSource = Org_PositionBLL.GetModelList("ID IN(Select RelatePosition FROM MCS_OA.dbo.KPI_Scheme WHERE Cycle=1)"); ddl_Position.DataBind(); ddl_Position.Items.Insert(0, new ListItem("请选择", "0")); #endregion #region 绑定用户可管辖的片区 ViewState["Position"] = staff.Model.Position; tr_OrganizeCity.DataSource = staff.GetStaffOrganizeCity(); if (tr_OrganizeCity.DataSource.Select("ID = 1").Length > 0) { tr_OrganizeCity.RootValue = "0"; tr_OrganizeCity.SelectValue = "1"; } else { tr_OrganizeCity.RootValue = new Addr_OrganizeCityBLL(staff.Model.OrganizeCity).Model.SuperID.ToString(); tr_OrganizeCity.SelectValue = staff.Model.OrganizeCity.ToString(); } #endregion ddl_AccountMonth.DataSource = AC_AccountMonthBLL.GetModelList(""); ddl_AccountMonth.DataBind(); ddl_AccountMonth.SelectedValue = (AC_AccountMonthBLL.GetCurrentMonth() - 1).ToString(); ddl_ApproveFlag.DataSource = DictionaryBLL.GetDicCollections("PUB_ApproveFlag"); ddl_ApproveFlag.DataBind(); ddl_ApproveFlag.Items.Insert(0, new ListItem("所有", "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); }