//更新用户社会兼职信息 public bool Update(SocialPartTime parttime) { try { if (parttime != null) { SocialPartTime newparttime = dbcontext.SocialPartTimeContext.Find(parttime.SocialPartTimeID); newparttime.UserInfoID = parttime.UserInfoID; newparttime.LevelName = parttime.LevelName; newparttime.PartTimeName = parttime.PartTimeName; newparttime.AwardDepartments = parttime.AwardDepartments; newparttime.Terms = parttime.Terms; newparttime.ApproveTime = parttime.ApproveTime; newparttime.Remark = parttime.Remark; newparttime.PartUnitName = parttime.PartUnitName; newparttime.SecrecyLevel = parttime.SecrecyLevel; newparttime.Sort = parttime.Sort; dbcontext.SaveChanges(); return(true); } else { return(false); } } catch (System.Data.SqlClient.SqlException e) { throw e; } }
public void BindData() { try { SocialPartTime social = bllSocial.FindBySocialID(Convert.ToInt32(Session["SocialPartTimeID"]), Convert.ToInt32(Session["SecrecyLevel"]), true); UserInfoName.Text = bllUser.FindByUserID(Convert.ToInt32(social.UserInfoID)); DropDownListLevelName.SelectedValue = social.LevelName; //LevelName.Text = social.LevelName; PartTimeName.Text = social.PartTimeName; PartTimeUnit.Text = social.PartUnitName; AwardDepartments.Text = social.AwardDepartments; Terms.Text = social.Terms; DatePickerApproveTime.SelectedDate = social.ApproveTime; tprimaryUnit.Text = social.primaryUnit; Remark.Text = social.Remark; DropDownListSecrecyLevel.SelectedIndex = Convert.ToInt32(social.SecrecyLevel - 1); if (social.Sort == "社会兼职") { ddl_sort.SelectedIndex = 0; } else { ddl_sort.SelectedIndex = 1; } } catch (Exception ex) { publicmethod.SaveError(ex, this.Request); } }
//为某用户添加社会兼职 public bool InsertForPeople(SocialPartTime parttime) { if (parttime != null) { dbcontext.SocialPartTimeContext.Add(parttime); dbcontext.SaveChanges(); return(true); } else { return(false); } }
//删除用户兼职信息 public bool Delete(int parttimeid) { try { SocialPartTime parttime = dbcontext.SocialPartTimeContext.Where(u => u.SocialPartTimeID == parttimeid).FirstOrDefault(); dbcontext.SocialPartTimeContext.Attach(parttime); dbcontext.SocialPartTimeContext.Remove(parttime); dbcontext.SaveChanges(); return(true); } catch (System.Data.SqlClient.SqlException e) { throw e; } }
//更新IsPass状态 public void UpdateIsPass(int ID, bool isPass) { try { SocialPartTime Social = dbcontext.SocialPartTimeContext.Find(ID); if (Social == null) { return; } Social.IsPass = isPass; dbcontext.SaveChanges(); } catch { throw; } }
//保存 protected void Save_Click(object sender, EventArgs e) { try { if (UserInfoName.Text.Trim() != "") { if (bllUser.IsUser(UserInfoName.Text.Trim()) != null) { if (bllUser.IsUser(UserInfoName.Text.Trim()).IsPass == true) { if (PartTimeUnit.Text.Trim() == "") { Alert.ShowInTop("兼职单位名称不能为空!"); PartTimeUnit.Text = ""; return; } if (PartTimeName.Text.Trim() == "") { Alert.ShowInTop("兼职职位名称不能为空!"); PartTimeName.Text = ""; return; } if (AwardDepartments.Text.Trim() == "") { Alert.ShowInTop("授予部门不能为空!"); AwardDepartments.Text = ""; return; } SocialPartTime social = new SocialPartTime(); social.UserInfoID = bllUser.FindID(UserInfoName.Text.Trim()); social.LevelName = DropDownListLevelName.SelectedItem.Text; social.PartTimeName = PartTimeName.Text.Trim(); social.PartUnitName = PartTimeUnit.Text.Trim(); social.Terms = Terms.Text.Trim(); social.AwardDepartments = AwardDepartments.Text.Trim(); social.ApproveTime = DatePickerApproveTime.SelectedDate; social.Remark = Remark.Text.Trim(); social.SecrecyLevel = DropDownListSecrecyLevel.SelectedIndex + 1; social.primaryUnit = tprimaryUnit.Text.Trim(); social.Sort = ddl_sort.SelectedText.Trim(); social.EntryPerson = bllUser.FindByLoginName(Session["LoginName"].ToString()).UserName; if (Convert.ToInt32(Session["SecrecyLevel"]) != 5) { social.IsPass = false; bllSocial.InsertForPeople(social); //插入社会兼职表 OperationLog operate = new OperationLog(); operate.LoginName = bllUser.FindByLoginName(Session["LoginName"].ToString()).UserName; operate.LoginIP = ""; operate.OperationType = "添加"; operate.OperationContent = "SocialPartTime"; operate.OperationDataID = social.SocialPartTimeID; operate.OperationTime = System.DateTime.Now; operate.Remark = ""; bllOperate.Insert(operate);//插入操作表 PageContext.RegisterStartupScript(ActiveWindow.GetConfirmHideRefreshReference() + Alert.GetShowInTopReference("人员社会兼职信息已提交审核!")); } else { social.IsPass = true; bllSocial.InsertForPeople(social); //插入社会兼职表 PageContext.RegisterStartupScript(ActiveWindow.GetConfirmHideRefreshReference() + Alert.GetShowInTopReference("人员社会兼职信息已添加完成!")); } } else { Alert.ShowInTop("该人员正在审核中!"); } } else { Alert.ShowInTop("人员不存在!"); UserInfoName.Text = ""; return; } } else { Alert.ShowInTop("人员名称不能为空!"); UserInfoName.Text = ""; return; } } catch (Exception ex) { publicmethod.SaveError(ex, this.Request); } }