/// <summary> /// 删除事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btn_Delete_Click(object sender, EventArgs e) { string ids = hf_CheckIDS.Value.ToString(); try { ids = ids.TrimEnd(',').TrimStart(','); using (IFMPDBContext db = new IFMPDBContext()) { try { foreach (string id in ids.Split(',')) { int selid = Convert.ToInt32(id); NoScoreUser NoScoreUser = db.NoScoreUser.FirstOrDefault(t => t.ID == selid); if (NoScoreUser != null) { List <NoScoreUserDepartment> NoScoreUserDepartmentList = db.NoScoreUserDepartment.Where(t => t.NoScoreUserID == NoScoreUser.ID).ToList(); db.NoScoreUserDepartment.RemoveRange(NoScoreUserDepartmentList); } db.NoScoreUser.Remove(NoScoreUser); db.SaveChanges(); new SysLogDAO().AddLog(LogType.操作日志_删除, "删除不排名人员信息", UserID); ShowMessage("删除成功"); DataBindList(); this.hf_CheckIDS.Value = ""; } } catch { ShowMessage("删除失败"); return; } } } catch (Exception ex) { new SysLogDAO().AddLog(LogType.系统日志, ex.Message, UserID); ShowMessage(ex.Message); return; } }
public void BindInfo() { using (IFMPDBContext db = new IFMPDBContext()) { NoScoreUser NoScoreUser = db.NoScoreUser.FirstOrDefault(t => t.ID == NoScoreUserID); if (NoScoreUser != null) { //this.hf_CID.Value = NoScoreUser.ID.ToString(); //this.txt_SysID.Text = db.User.FirstOrDefault(t => t.ID == NoScoreUser.UserID).RealName; this.txt_SysID.Text = NoScoreUser.UserID.ToString(); List <NoScoreUserDepartment> NoScoreUserDepartmentList = db.NoScoreUserDepartment.Where(t => t.NoScoreUserID == NoScoreUser.ID).ToList(); foreach (NoScoreUserDepartment NoScoreUserDepartment in NoScoreUserDepartmentList) { for (int i = 0; i < this.ckl_Groups.Items.Count; i++) { if (NoScoreUserDepartment.DepartmentID.ToString() == ckl_Groups.Items[i].Value) { ckl_Groups.Items[i].Selected = true; } } } } } //NoPMUserGroupEntity model = NoPMUserGroupBLL.GetObjByID(NoScoreUserID); //if (model != null) //{ // this.hf_CID.Value = model.SysID; // this.txt_SysID.Text = model.SysIDName; // string[] arr = model.Groups.Split(','); // for (int i = 0; i < arr.Length; i++) // { // for (int j = 0; j < this.ckl_Groups.Items.Count; j++) // { // if (arr[i] == ckl_Groups.Items[j].Value) // { // ckl_Groups.Items[j].Selected = true; // break; // } // } // } //} }
/// <summary> /// 页面初始化 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //获取该用户的组别 using (IFMPDBContext db = new IFMPDBContext()) { NoScoreUser NoScoreUser = db.NoScoreUser.FirstOrDefault(t => t.UserID == UserID); if (NoScoreUser != null) { List <Department> DepartmentList = db.Department.Where(t => t.IsDel != true && db.NoScoreUserDepartment.Where(m => m.NoScoreUserID == NoScoreUser.ID).Select(m => m.DepartmentID).Contains(t.ID)).ToList(); this.ddl_Group.DataSource = DepartmentList; this.ddl_Group.DataValueField = "ID"; this.ddl_Group.DataTextField = "Name"; this.ddl_Group.DataBind(); this.ddl_Group.Items.Add(new ListItem("--请选择--", "-1")); this.ddl_Group.SelectedValue = "-1"; } else { List <Department> DepartmentList = db.Department.Where(t => t.IsDel != true && db.DepartmentUser.Where(m => m.UserID == UserID).Select(m => m.DepartmentID).Contains(t.ID)).ToList(); this.ddl_Group.DataSource = DepartmentList; this.ddl_Group.DataValueField = "ID"; this.ddl_Group.DataTextField = "Name"; this.ddl_Group.DataBind(); this.ddl_Group.Items.Add(new ListItem("--请选择--", "-1")); this.ddl_Group.SelectedValue = "-1"; } this.ltl_M1.Visible = this.ddl_Month.Visible = this.ddl_Year.Visible = false; } this.ltl_M1.Visible = this.ddl_Month.Visible = this.ddl_Year.Visible = false; GetYear(); GetMonth(); GetCondition(); DataBindList(); } }
protected void btn_Sumbit_Click(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(this.txt_SysID.Text.ToString())) { ShowMessage("请至少选择一名人员!!"); return; } using (IFMPDBContext db = new IFMPDBContext()) { NoScoreUser NoScoreUser = db.NoScoreUser.FirstOrDefault(t => t.ID == NoScoreUserID); string message = ""; if (NoScoreUser == null) { foreach (string id in this.txt_SysID.Text.ToString().TrimEnd(',').Split(',')) { int selid = Convert.ToInt32(id); NoScoreUser = new NoScoreUser(); NoScoreUser.UserID = selid; if (db.NoScoreUser.FirstOrDefault(t => t.UserID == NoScoreUser.UserID) == null) { db.NoScoreUser.Add(NoScoreUser); db.SaveChanges(); } else { NoScoreUser = db.NoScoreUser.FirstOrDefault(t => t.UserID == selid); } for (int i = 0; i < this.ckl_Groups.Items.Count; i++) { if (ckl_Groups.Items[i].Selected) { int departmentid = Convert.ToInt32(ckl_Groups.Items[i].Value); NoScoreUserDepartment NoScoreUserDepartment = db.NoScoreUserDepartment.FirstOrDefault(t => t.NoScoreUserID == NoScoreUser.ID && t.DepartmentID == departmentid); if (NoScoreUserDepartment == null) { NoScoreUserDepartment = new NoScoreUserDepartment(); NoScoreUserDepartment.NoScoreUserID = NoScoreUser.ID; NoScoreUserDepartment.DepartmentID = departmentid; db.NoScoreUserDepartment.Add(NoScoreUserDepartment); } } } db.SaveChanges(); } message = "添加不排名分组人员"; new SysLogDAO().AddLog(LogType.操作日志_添加, message, UserID); } else { //这里应该是要默认的静止选人的功能 List <NoScoreUserDepartment> NoScoreUserDepartmentList = db.NoScoreUserDepartment.Where(t => t.NoScoreUserID == NoScoreUser.ID).ToList(); db.NoScoreUserDepartment.RemoveRange(NoScoreUserDepartmentList); db.SaveChanges(); for (int i = 0; i < this.ckl_Groups.Items.Count; i++) { if (ckl_Groups.Items[i].Selected) { NoScoreUserDepartment NoScoreUserDepartment = new NoScoreUserDepartment(); NoScoreUserDepartment.NoScoreUserID = NoScoreUser.ID; NoScoreUserDepartment.DepartmentID = Convert.ToInt32(ckl_Groups.Items[i].Value); db.NoScoreUserDepartment.Add(NoScoreUserDepartment); } } db.SaveChanges(); } message = "修改不排名分组人员"; new SysLogDAO().AddLog(LogType.操作日志_修改, message, UserID); } ShowMessage(); } catch (Exception ex) { new SysLogDAO().AddLog(LogType.系统日志, ex.Message, UserID); ShowMessage(ex.Message); return; } }