private void DoBatchDelete() { IList <object> idList = RequestData.GetList <object>("IdList"); if (idList != null && idList.Count > 0) { // SurveyQuestion.DoBatchDelete(idList.ToArray()); for (var v = 0; v < idList.Count; v++) { // 人员 问卷 QuestionItem[] Qent = QuestionItem.FindAllByProperties(QuestionItem.Prop_SurveyId, idList[v].ToString()); QuestionAnswerItem[] Aent = QuestionAnswerItem.FindAllByProperties(QuestionAnswerItem.Prop_SurveyId, idList[v].ToString()); SurveyFinallyUsr[] FuEnt = SurveyFinallyUsr.FindAllByProperties(SurveyFinallyUsr.Prop_SurveyId, idList[v].ToString()); SurveyCanReaderUsr[] Ruent = SurveyCanReaderUsr.FindAllByProperties(SurveyCanReaderUsr.Prop_SurveyId, idList[v].ToString()); SurveyedObj[] SoEnt = SurveyedObj.FindAllByProperties(SurveyedObj.Prop_SurveyId, idList[v].ToString()); SurveyReaderObj[] RoEnt = SurveyReaderObj.FindAllByProperties(SurveyReaderObj.Prop_SurveyId, idList[v].ToString()); foreach (var ent in Qent) { ent.DoDelete(); } foreach (var ent in Aent) { ent.DoDelete(); } foreach (var ent in FuEnt) { ent.DoDelete(); } foreach (var ent in Ruent) { ent.DoDelete(); } foreach (var ent in SoEnt) { ent.DoDelete(); } foreach (var ent in RoEnt) { ent.DoDelete(); } } SurveyQuestion.DoBatchDelete(idList.ToArray()); } }
//string sql = @" select * from FL_Culture..QuestionAnswerItem where SurveyId='{0}' and QuestionItemId='{1}' order by SortIndex "; // sql = string.Format(sql, SurveyId, QuestionItemId); // this.PageState.Add("DataList", DataHelper.QueryDictList(sql)); /// <summary> /// 问卷保存 /// </summary> private void SurveyOneSave() { string SurveyId = RequestData.Get("SurveyId") + ""; string SurveyTypeId = RequestData.Get("SurveyTypeId") + ""; string SurveyTypeName = RequestData.Get("SurveyTypeName") + ""; string NoticeWay = RequestData.Get("NoticeWay") + ""; string TypeCode = RequestData.Get("TypeCode") + ""; string SurveyTitile = RequestData.Get("SurveyTitile") + ""; string Description = RequestData.Get("Description") + ""; string StartTime = RequestData.Get("StartTime") + ""; string EndTime = RequestData.Get("EndTime") + ""; string CompanyName = RequestData.Get("CompanyName") + ""; string CompanyId = RequestData.Get("CompanyId") + ""; string DeptName = RequestData.Get("DeptName") + ""; string DeptId = RequestData.Get("DeptId") + ""; string AddFilesName = RequestData.Get("AddFilesName") + ""; string Score = RequestData.Get("Score") + ""; string SetTimeout = RequestData.Get("SetTimeout") + ""; string ReaderObj = RequestData.Get("ReaderObj") + ""; string RemindWay = RequestData.Get("RemindWay") + ""; //提醒方式 string RecyleDay = RequestData.Get("RecyleDay") + ""; //提醒天数 string TimePoint = RequestData.Get("TimePoint") + ""; //提醒时间点 SurveyQuestion ent = SurveyQuestion.Find(SurveyId); if (string.IsNullOrEmpty(ent.State)) { ent.State = "0"; //"0" 表示创建 } ent.SurveyTypeId = SurveyTypeId; ent.SurveyTypeName = SurveyTypeName; ent.NoticeWay = NoticeWay; ent.TypeCode = TypeCode; ent.SurveyTitile = SurveyTitile; ent.Description = Description; if (!string.IsNullOrEmpty(StartTime)) { ent.StartTime = DateTime.Parse(StartTime); } if (!string.IsNullOrEmpty(EndTime)) { ent.EndTime = DateTime.Parse(EndTime); } if (!string.IsNullOrEmpty(TimePoint)) { ent.TimePoint = TimePoint; } if (!string.IsNullOrEmpty(RecyleDay)) { ent.RecyleDay = int.Parse(RecyleDay); } if (!string.IsNullOrEmpty(CompanyName)) { ent.CompanyName = CompanyName; } if (!string.IsNullOrEmpty(CompanyId)) { ent.CompanyId = CompanyId; } ent.DeptName = DeptName; ent.DeptId = DeptId; ent.AddFilesName = AddFilesName; ent.RemindWay = RemindWay; if (!string.IsNullOrEmpty(Score)) { ent.Score = int.Parse(Score); } if (!string.IsNullOrEmpty(SetTimeout)) { ent.SetTimeout = DateTime.Parse(SetTimeout); } ent.ReaderObj = ReaderObj; ent.DoUpdate(); string sql = " delete from FL_Culture..SurveyReaderObj where SurveyId='{0}' ;"; sql = string.Format(sql, SurveyId); DataHelper.ExecSql(sql); string ReadObj = ent.ReaderObj; if (ReadObj.Contains("joiner")) { ReadObj = "joiner"; } else { ReadObj = "sender"; } SurveyReaderObj ReadEnt = new SurveyReaderObj(); ReadEnt.SurveyId = SurveyId; ReadEnt.ReaderWay = ReadObj; ReadEnt.DoCreate(); }
/// <summary> /// 移除关系错误的人员 /// </summary> private void RemoveEnableUsr(string surveyId) { if (!string.IsNullOrEmpty(surveyId)) { //调查对象 var Ent = SurveyedObj.FindFirstByProperties(SurveyedObj.Prop_SurveyId, surveyId); if (Ent == null) { return; } var Arr = Ent.OrgIds.ToString().Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); if (Arr.Length <= 0) { return; } string OrgIds = "("; for (int i = 0; i < Arr.Length; i++) { if (i > 0) { OrgIds += ","; } OrgIds += "'" + Arr[i] + "'"; } OrgIds += ")"; string sql = @" With GetTree As ( select * from sysgroup where type=2 and GroupID in {0} union All select A.* from sysgroup AS A join GetTree AS B on B.ParentID=A.GroupID ) select GroupID from GetTree where Name like '%公司%'"; sql = string.Format(sql, OrgIds); DataTable tmpDt = DataHelper.QueryDataTable(sql); if (tmpDt.Rows.Count <= 0) { return; } string CorpIds = " ("; for (int i = 0; i < tmpDt.Rows.Count; i++) { if (i > 0) { CorpIds += ","; } CorpIds += "'" + tmpDt.Rows[i][0] + "'"; } CorpIds += " ) "; //CreateWay='1' 系统生成 0 导入方式 sql = @"delete from FL_Culture..SurveyFinallyUsr where SurveyId='{1}' and CreateWay='1' and WorkNo not in ( select psncode from HR_OA_MiddleDB..fld_ryxx where pk_corp in {0} )"; sql = string.Format(sql, CorpIds, surveyId); sql = sql.Replace("HR_OA_MiddleDB", Global.HR_OA_MiddleDB); DataHelper.ExecSql(sql); //查看对象 SurveyReaderObj Ent1 = SurveyReaderObj.FindFirstByProperties(SurveyReaderObj.Prop_SurveyId, surveyId); //if (Ent1 == null) return; if (Ent1 == null || string.IsNullOrEmpty(Ent1.OrgIds)) { return; //Change By WGM 9-30 } var Arr1 = Ent1.OrgIds.ToString().Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); if (Arr1.Length <= 0) { return; } OrgIds = "("; for (int i = 0; i < Arr1.Length; i++) { if (i > 0) { OrgIds += ","; } OrgIds += "'" + Arr1[i] + "'"; } OrgIds += ")"; sql = @" With GetTree As ( select * from sysgroup where type=2 and GroupID in {0} union All select A.* from sysgroup AS A join GetTree AS B on B.ParentID=A.GroupID ) select GroupID from GetTree where Name like '%公司%'"; sql = string.Format(sql, OrgIds); DataTable tmpDt1 = DataHelper.QueryDataTable(sql); CorpIds = " ("; for (int i = 0; i < tmpDt1.Rows.Count; i++) { if (i > 0) { CorpIds += ","; } CorpIds += "'" + tmpDt1.Rows[i][0] + "'"; } CorpIds += " ) "; sql = @"delete from FL_Culture..SurveyCanReaderUsr where SurveyId='{1}' and WorkNo not in ( select psncode from HR_OA_MiddleDB..fld_ryxx where pk_corp in {0} )"; sql = string.Format(sql, CorpIds, surveyId); sql = sql.Replace("HR_OA_MiddleDB", Global.HR_OA_MiddleDB); DataHelper.ExecSql(sql); } }
/// <summary> /// SaveSurveyedObj /// </summary> private void SaveSurveyedObj() { string SurveyId = RequestData.Get("SurveyId") + ""; //first delete string sql = " delete from FL_Culture..SurveyedObj where SurveyId='{0}' ;"; sql += " delete from FL_Culture..SurveyReaderObj where SurveyId='{0}' ;"; sql = string.Format(sql, SurveyId); DataHelper.ExecSql(sql); string OrgIds = RequestData.Get("OrgIds") + ""; string OrgNames = RequestData.Get("OrgNames") + ""; string PostionIds = RequestData.Get("PostionIds") + ""; string PostionNames = RequestData.Get("PostionNames") + ""; string BornAddr = RequestData.Get("BornAddr") + ""; string StartWorkTime = RequestData.Get("StartWorkTime") + ""; string UntileWorkTime = RequestData.Get("UntileWorkTime") + ""; string Sex = RequestData.Get("Sex") + ""; string StartAge = RequestData.Get("StartAge") + ""; string EndAge = RequestData.Get("EndAge") + ""; string WorkAge = RequestData.Get("WorkAge") + ""; string Major = RequestData.Get("Major") + ""; string PersonType = RequestData.Get("PersonType") + ""; string PositionDegree1 = RequestData.Get("PositionDegree1") + ""; string PositionDegree0 = RequestData.Get("PositionDegree0") + ""; string CruxPositon = RequestData.Get("CruxPositon") + ""; //关键岗位 string PositionSeq = RequestData.Get("PositionSeq") + ""; //岗位序列 SurveyedObj Ent = new SurveyedObj(); Ent.SurveyId = SurveyId; //* Ent.OrgIds = OrgIds; Ent.OrgNames = OrgNames; Ent.PostionIds = PostionIds; Ent.PostionNames = PostionNames; Ent.Sex = Sex; Ent.WorkAge = WorkAge; if (!string.IsNullOrEmpty(StartWorkTime)) { Ent.StartWorkTime = DateTime.Parse(StartWorkTime); } if (!string.IsNullOrEmpty(UntileWorkTime)) { Ent.UntileWorkTime = DateTime.Parse(UntileWorkTime); } if (!string.IsNullOrEmpty(CruxPositon)) { Ent.CruxPositon = CruxPositon; } if (!string.IsNullOrEmpty(PositionSeq)) { Ent.PositionSeq = PositionSeq; //岗位序列 } Ent.Major = Major; //学历 Ent.PersonType = PersonType; Ent.BornAddr = BornAddr; //年龄范围 if (!string.IsNullOrEmpty(StartAge)) { Ent.StartAge = DateTime.Parse(StartAge); } if (!string.IsNullOrEmpty(EndAge)) { Ent.EndAge = DateTime.Parse(EndAge); } //StartAge EndAge(年龄范围) BornAddr 籍贯 Ent.PositionDegree0 = PositionDegree0; Ent.PositionDegree1 = PositionDegree1; Ent.DoCreate(); SurveyQuestion SEnt = SurveyQuestion.Find(SurveyId); string ReadObj = SEnt.ReaderObj; if (ReadObj.Contains("joiner")) { ReadObj = "joiner"; } else { ReadObj = "sender"; } SurveyReaderObj ReadEnt = new SurveyReaderObj(); ReadEnt.SurveyId = SurveyId; ReadEnt.ReaderWay = ReadObj; ReadEnt.DoCreate(); this.PageState.Add("State", "1"); }
/// <summary> /// 生成查看人员 /// </summary> /// <param name="SurveyId"></param> /// <returns></returns> public bool CreateReadUser(string SurveyId) { SurveyReaderObj SrEnt = SurveyReaderObj.FindFirstByProperties(SurveyReaderObj.Prop_SurveyId, SurveyId); //组织下的人员 string RdSQL = this.ReadSQL; if (string.IsNullOrEmpty(SrEnt.OrgIds) || string.IsNullOrEmpty(SrEnt.OrgNames)) { RdSQL = RdSQL.Replace("##Query##", " and 1<>1 "); //组织为空情况 RdSQL = string.Format(RdSQL, SurveyId); } else { RdSQL = RdSQL.Replace("##Query##", " "); RdSQL = string.Format(RdSQL, SurveyId); } DataTable FilterUsrDt = DataHelper.QueryDataTable(RdSQL); // 添加的人员 string SQL = @"with SurObjUsr As ( select CA.* from FL_Culture..SurveyReaderObj As A cross apply( select Filed As UsrID from FL_Culture..GetTblByJson(A.AllowUser,'Id') ) As CA where SurveyId='{0}' ), UserInfo As ( select T.UserID,T.Name, T.WorkNo from SurObjUsr As A left join FL_PortalHR..Sysuser As T on A.UsrID=T.UserID ) select distinct * from UserInfo "; SQL = "select '' where 1<>1 "; //Change BY WGM 9-30 SQL = SQL.Replace("FL_PortalHR", Global.AimPortalDB); SQL = string.Format(SQL, SurveyId); DataTable AddUsrDt = DataHelper.QueryDataTable(SQL); //排除的人员 string ReMoveSQL = @" select CA.* from FL_Culture..SurveyReaderObj As A cross apply( select Filed As UserID from FL_Culture..GetTblByJson(A.NoAllowUser,'Id') ) As CA where SurveyId='{0}'"; ReMoveSQL = string.Format(ReMoveSQL, SurveyId); ReMoveSQL = "select '' where 1<>1 "; //Change BY WGM 9-30 DataTable RemoveDt = DataHelper.QueryDataTable(ReMoveSQL); //排除人员 if (RemoveDt.Rows.Count > 0) { for (int i = 0; i < FilterUsrDt.Rows.Count; i++) { for (int j = 0; j < RemoveDt.Rows.Count; j++) { if (FilterUsrDt.Rows[i]["UserID"].ToString() == RemoveDt.Rows[j]["UserID"].ToString()) { FilterUsrDt.Rows.Remove(FilterUsrDt.Rows[i]); } } } } // 合并 DataTable FinalDt = new DataTable(); DataColumn Dc_UserId = new DataColumn("UserId"); FinalDt.Columns.Add(Dc_UserId); DataColumn Dc_UserName = new DataColumn("UserName"); FinalDt.Columns.Add(Dc_UserName); DataColumn Dc_DeptId = new DataColumn("DeptId"); FinalDt.Columns.Add(Dc_DeptId); DataColumn Dc_DeptName = new DataColumn("DeptName"); FinalDt.Columns.Add(Dc_DeptName); DataColumn Dc_WorkNo = new DataColumn("WorkNo"); FinalDt.Columns.Add(Dc_WorkNo); for (int i = 0; i < FilterUsrDt.Rows.Count; i++) { DataRow dr = FinalDt.NewRow(); //dr["DeptId"] = FilterUsrDt.Rows[i]["GroupId"]; //dr["DeptName"] = FilterUsrDt.Rows[i]["GroupName"]; string FullDept = WFHelper.getZzjg(FilterUsrDt.Rows[i]["UserID"].ToString(), true); dr["DeptName"] = FullDept; dr["WorkNo"] = FilterUsrDt.Rows[i]["WorkNo"]; dr["UserId"] = FilterUsrDt.Rows[i]["UserID"]; //* dr["UserName"] = FilterUsrDt.Rows[i]["UserName"]; //* FinalDt.Rows.Add(dr); } //Add for (int i = 0; i < AddUsrDt.Rows.Count; i++) { DataRow dr = FinalDt.NewRow(); //dr["DeptId"] = AddUsrDt.Rows[i]["GroupID"]; //dr["DeptName"] = AddUsrDt.Rows[i]["GroupName"]; string FullDept = WFHelper.getZzjg(AddUsrDt.Rows[i]["UserID"].ToString(), true); dr["DeptName"] = FullDept; dr["WorkNo"] = AddUsrDt.Rows[i]["WorkNo"]; dr["UserId"] = AddUsrDt.Rows[i]["UserID"]; //* dr["UserName"] = AddUsrDt.Rows[i]["Name"]; //* FinalDt.Rows.Add(dr); } SurveyQuestion Ent = SurveyQuestion.Find(SurveyId); if (Ent != null) { //添加问卷创建者 DataRow CreateRow = FinalDt.NewRow(); CreateRow["UserId"] = Ent.CreateId; CreateRow["UserName"] = Ent.CreateName; FinalDt.Rows.Add(CreateRow); } //--------------------------------------------------------------- //生成调查用户 for (int i = 0; i < FinalDt.Rows.Count; i++) { SurveyCanReaderUsr UserEnt = new SurveyCanReaderUsr(); UserEnt.CreateWay = "1"; //1 表示生成的用户而非创建 UserEnt.SurveyId = SurveyId; UserEnt.DeptName = FinalDt.Rows[i]["DeptName"].ToString(); //UserEnt.DeptId = FinalDt.Rows[i]["DeptId"].ToString(); UserEnt.UserId = FinalDt.Rows[i]["UserId"].ToString(); UserEnt.UserName = FinalDt.Rows[i]["UserName"].ToString(); UserEnt.WorkNo = FinalDt.Rows[i]["WorkNo"].ToString(); UserEnt.DoCreate(); } return(true); }
string type = String.Empty; // 对象类型 protected void Page_Load(object sender, EventArgs e) { op = RequestData.Get <string>("op"); SurveyId = RequestData.Get <string>("SurveyId"); type = RequestData.Get <string>("type"); string AllowUser = RequestData.Get("AllowUser") + ""; // 允许人员 string NoAllowUser = RequestData.Get("NoAllowUser") + ""; // 排除人员 SurveyReaderObj ent = null; switch (this.RequestAction) { case RequestActionEnum.Update: ent = this.GetMergedData <SurveyReaderObj>(); if (!string.IsNullOrEmpty(AllowUser)) { ent.AllowUser = AllowUser; } if (!string.IsNullOrEmpty(NoAllowUser)) { ent.NoAllowUser = NoAllowUser; } ent.DoUpdate(); break; case RequestActionEnum.Insert: case RequestActionEnum.Create: ent = this.GetPostedData <SurveyReaderObj>(); if (!string.IsNullOrEmpty(AllowUser)) { ent.AllowUser = AllowUser; } if (!string.IsNullOrEmpty(NoAllowUser)) { ent.NoAllowUser = NoAllowUser; } ent.DoCreate(); this.PageState.Add("Id", ent.Id); //回写ID break; case RequestActionEnum.Delete: ent = this.GetTargetData <SurveyReaderObj>(); ent.DoDelete(); break; } if (op != "c" && op != "cs") { if (!String.IsNullOrEmpty(SurveyId)) { ent = SurveyReaderObj.FindFirstByProperties(SurveyedObj.Prop_SurveyId, SurveyId); if (ent != null) { this.PageState.Add("DataList", ent.AllowUser); this.PageState.Add("DataList1", ent.NoAllowUser); } } this.SetFormData(ent); } }