private String saveBaseInfo() { String F_ID = context.Session[SessionMgm.VisitUserID].ToString(); context.Response.ContentType = "text/plain"; DataClassesDataContext dc = new DataClassesDataContext(); bool insert = false; User newUser = dc.User.SingleOrDefault(user => user.F_ID.Equals(F_ID /*paras["F_ID"]*/)); if (newUser == null) { newUser = new User(); newUser.F_Role = RoleType.Applicant; newUser.F_ID = paras["F_ID"]; insert = true; } // newUser.F_userName = paras["F_userName"]; newUser.F_realName = paras["F_realName"]; newUser.F_sexual = paras["F_sexual"]; if (String.IsNullOrEmpty(paras["F_birthday"]) == false) { newUser.F_birthday = DateTime.Parse(paras["F_birthday"]); } newUser.F_bornplace = paras["F_bornplace"]; newUser.F_nativeplace = paras["F_nativeplace"]; newUser.F_nationality = paras["F_nationality"]; newUser.F_party = paras["F_party"]; if (String.IsNullOrEmpty(paras["F_partyEntryDate"]) == false) { newUser.F_partyEntryDate = DateTime.Parse(paras["F_partyEntryDate"]); } newUser.F_highestDegree = paras["F_highestDegree"]; newUser.F_highestEducation = paras["F_highestEducation"]; newUser.F_highestGrduateSch = paras["F_highestGrduateSch"]; if (String.IsNullOrEmpty(paras["F_workBeginDate"]) == false) { newUser.F_workBeginDate = DateTime.Parse(paras["F_workBeginDate"]); } newUser.F_workDept = paras["F_workDeptText"]; newUser.F_belongDeptID = paras["F_workDept"]; newUser.F_position = paras["F_position"]; newUser.F_title = paras["F_title"]; if (String.IsNullOrEmpty(paras["F_posBeginDate"]) == false) { newUser.F_posBeginDate = DateTime.Parse(paras["F_posBeginDate"]); } newUser.F_adminRanking = paras["F_adminRanking"]; if (String.IsNullOrEmpty(paras["F_adminRkBeginDate"]) == false) { newUser.F_adminRkBeginDate = DateTime.Parse(paras["F_adminRkBeginDate"]); } newUser.F_idType = paras["F_idType"]; newUser.F_idNumber = paras["F_idNumber"]; if (String.IsNullOrWhiteSpace(newUser.F_idNumber) == false) { User t = dc.User.SingleOrDefault(_user => _user.F_idType.Equals(newUser.F_idType) && _user.F_idNumber.Equals(newUser.F_idNumber)); if (t != null && t.F_ID.Equals(newUser.F_ID) == false) { return("系统中已存在相同的证件号和证件名"); } } newUser.F_mobile = paras["F_mobile"]; newUser.F_phone = paras["F_phone"]; newUser.F_phone2 = paras["F_phone2"]; newUser.F_email = paras["F_email"]; newUser.F_freeAddress = paras["F_freeAddress"]; newUser.F_fax = paras["F_fax"]; newUser.F_lastModifyTime = DateTime.Now; if (insert) { dc.User.InsertOnSubmit(newUser); } dc.SubmitChanges(); return("保存成功"); }
/// <summary> /// /// </summary> /// <param name="dc"></param> /// <returns>新用户的id</returns> private string createNewUser(DataClassesDataContext dc) { // 创建新用户 User newUser = new User(); newUser.F_Role = RoleType.Applicant; newUser.F_ID = Guid.NewGuid().ToString(); newUser.F_userName = paras["F_empno"];// 教工号即username,密码同教工号 newUser.F_pwd = UtilHelper.MD5Encrypt(newUser.F_userName); newUser.F_realName = paras["F_realName"]; newUser.F_sexual = paras["F_sexual"]; if (String.IsNullOrEmpty(paras["F_birthday"]) == false) { newUser.F_birthday = DateTime.Parse(paras["F_birthday"]); } newUser.F_bornplace = paras["F_bornplace"]; newUser.F_nativeplace = paras["F_nativeplace"]; newUser.F_nationality = paras["F_nationality"]; newUser.F_party = paras["F_party"]; if (String.IsNullOrEmpty(paras["F_partyEntryDate"]) == false) { newUser.F_partyEntryDate = DateTime.Parse(paras["F_partyEntryDate"]); } newUser.F_highestDegree = paras["F_highestDegree"]; newUser.F_highestEducation = paras["F_highestEducation"]; newUser.F_highestGrduateSch = paras["F_highestGrduateSch"]; if (String.IsNullOrEmpty(paras["F_workBeginDate"]) == false) { newUser.F_workBeginDate = DateTime.Parse(paras["F_workBeginDate"]); } newUser.F_workDept = paras["F_workDeptText"]; newUser.F_belongDeptID = paras["F_workDept"]; newUser.F_position = paras["F_position"]; newUser.F_title = paras["F_title"]; if (String.IsNullOrEmpty(paras["F_posBeginDate"]) == false) { newUser.F_posBeginDate = DateTime.Parse(paras["F_posBeginDate"]); } newUser.F_adminRanking = paras["F_adminRanking"]; if (String.IsNullOrEmpty(paras["F_adminRkBeginDate"]) == false) { newUser.F_adminRkBeginDate = DateTime.Parse(paras["F_adminRkBeginDate"]); } newUser.F_idType = paras["F_idType"]; newUser.F_idNumber = paras["F_idNumber"]; if (String.IsNullOrWhiteSpace(newUser.F_idNumber) == false) { User t = dc.User.SingleOrDefault(_staff => _staff.F_idType.Equals(newUser.F_idType) && _staff.F_idNumber.Equals(newUser.F_idNumber)); if (t != null && t.F_ID.Equals(newUser.F_ID) == false) { return("该证件号和证件名已被其他用户使用"); } } newUser.F_mobile = paras["F_mobile"]; newUser.F_phone = paras["F_phone"]; newUser.F_phone2 = paras["F_phone2"]; newUser.F_email = paras["F_email"]; newUser.F_freeAddress = paras["F_freeAddress"]; newUser.F_fax = paras["F_fax"]; // 在此处自动创建的用户默认为“审核通过” newUser.F_status = InfoStatus.Authoried; newUser.F_lastModifyTime = DateTime.Now; dc.User.InsertOnSubmit(newUser); return(newUser.F_ID); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ViewState["retu"] = Request.UrlReferrer.ToString(); String unitID = Request["unitID"]; if (unitID == null) { unitID = Session[SessionMgm.UnitID].ToString(); String guideID = Request["guideID"]; auditedSocialProjects.SelectParameters["unitID"].DefaultValue = unitID; SqlDataSource1.SelectParameters["unitID"].DefaultValue = unitID; DataClassesDataContext dc = new DataClassesDataContext(); AssignProject ap = dc.AssignProject.SingleOrDefault(_ap => _ap.F_projectID.Equals(guideID) && _ap.F_unitID.Equals(unitID)); if (ap != null) { decimal amount = ap.F_amount.Value; int sciB = ap.F_sciB.Value; int sciImp = ap.F_sciImp.Value; int sciInd = ap.F_sciIndustry.Value; int sciNor = ap.F_sciNormal.Value; int socImp = ap.F_socialImpA.Value; int socNor = ap.F_socialNorA.Value; int socProxy = ap.F_socialProxy.Value; int socB = ap.F_socialB.Value; labAmount.Text = amount.ToString(); labSciB.Text = sciB.ToString(); labSciImp.Text = sciImp.ToString(); labSciInd.Text = sciInd.ToString(); labSciNor.Text = sciNor.ToString(); labSocB.Text = socB.ToString(); labSocImp.Text = socImp.ToString(); labSocNor.Text = socNor.ToString(); labSocProxy.Text = socProxy.ToString(); int usedsciImp = dc.ViewAuditedBySchool.Count(_sp => _sp.F_guideProjectID.Equals(guideID) && _sp.F_type.Equals("重点") && unitID.Equals(_sp.F_unitID)); int usedsciInd = dc.ViewAuditedBySchool.Count(_sp => _sp.F_guideProjectID.Equals(guideID) && _sp.F_type.Equals("产学研") && unitID.Equals(_sp.F_unitID)); int usedsciNor = dc.ViewAuditedBySchool.Count(_sp => _sp.F_guideProjectID.Equals(guideID) && _sp.F_type.Equals("一般") && unitID.Equals(_sp.F_unitID)); int usedsciB = dc.ViewAuditedBySchool.Count(_sp => _sp.F_guideProjectID.Equals(guideID) && _sp.F_type.Equals("B类") && unitID.Equals(_sp.F_unitID)); int usedsocImp = dc.ViewAuditedBySchool.Count(_sp => _sp.F_guideProjectID.Equals(guideID) && _sp.F_type.Equals("A类重点项目") && unitID.Equals(_sp.F_unitID)); int usedsocNor = dc.ViewAuditedBySchool.Count(_sp => _sp.F_guideProjectID.Equals(guideID) && _sp.F_type.Equals("一般项目") && unitID.Equals(_sp.F_unitID)); int usedsocB = dc.ViewAuditedBySchool.Count(_sp => _sp.F_guideProjectID.Equals(guideID) && _sp.F_type.Equals("B类项目") && unitID.Equals(_sp.F_unitID)); int usedsocProxy = dc.ViewAuditedBySchool.Count(_sp => _sp.F_guideProjectID.Equals(guideID) && _sp.F_type.Equals("委托项目") && unitID.Equals(_sp.F_unitID)); decimal?sumOfSci = (from m in dc.ViewAuditedBySchool where m.F_guideProjectID.Equals(guideID) && unitID.Equals(m.F_unitID) && "科技项目".Equals(m.F_projectType) select m.F_fund).Sum(); decimal value1 = 0; if (sumOfSci != null) { value1 = sumOfSci.Value; } decimal?sumOfSocial = (from m in dc.ViewAuditedBySchool where m.F_guideProjectID.Equals(guideID) && unitID.Equals(m.F_unitID) && "社科项目".Equals(m.F_projectType) select m.F_fund).Sum(); decimal value2 = 0; if (sumOfSocial != null) { value2 = sumOfSocial.Value; } decimal usedamount = value1 + value2; labUseAmount.Text = usedamount.ToString(); labUseSciB.Text = usedsciB.ToString(); labUseSciImp.Text = usedsciImp.ToString(); labUseSciInd.Text = usedsciInd.ToString(); labUseSciNor.Text = usedsciNor.ToString(); labUseSocB.Text = usedsocB.ToString(); labUseSocImp.Text = usedsocImp.ToString(); labUseSocNor.Text = usedsocNor.ToString(); labUseSocProxy.Text = usedsocProxy.ToString(); labRemAmount.Text = (amount - usedamount).ToString(); labRemB.Text = (socB - usedsocB).ToString(); labRemNor.Text = (socNor - usedsocNor).ToString(); labRemProxy.Text = (socProxy - usedsocProxy).ToString(); labRemSocImp.Text = (socImp - usedsocImp).ToString(); labRemSciB.Text = (sciB - usedsciB).ToString(); labRemSciImp.Text = (sciImp - usedsciImp).ToString(); labRemSciInd.Text = (sciInd - usedsciInd).ToString(); labRemSciNor.Text = (sciNor - usedsciNor).ToString(); } } gvSocial.DataBind(); SmartGridView3.DataBind(); } }
protected void btnCommit_Click(object sender, EventArgs e) { String[] projects = txtName.Text.Trim().Split(new char[] { '\n' }); String[] units = txtUnit.Text.Trim().Split(new char[] { '\n' }); String[] leaders = this.txtLeader.Text.Trim().Split(new char[] { '\n' }); String[] funds = this.txtFund.Text.Trim().Split(new char[] { '\n' }); DateTime startDate = DateTime.Parse(txtStart.Text); DateTime endDate = DateTime.Parse(txtEnd.Text); if (projects.Length == units.Length && units.Length == leaders.Length) { DataClassesDataContext dc = new DataClassesDataContext(); for (int i = 0; i < projects.Length; i++) { try { units[i] = units[i].Trim().Replace("\"", ""); units[i] = units[i].Replace("\r", "").Trim(); units[i] = units[i].Replace(" ", "").Trim(); ApplicantUnit unit = dc.ApplicantUnit.SingleOrDefault(_au => _au.F_name.Equals(units[i])); if (unit == null) { unit = new ApplicantUnit(); unit.F_ID = Guid.NewGuid().ToString(); unit.F_name = units[i]; unit.F_status = RoleType.Authoried; dc.ApplicantUnit.InsertOnSubmit(unit); } leaders[i] = leaders[i].Trim().Replace("\"", ""); leaders[i] = leaders[i].Replace(" ", ""); leaders[i] = leaders[i].Replace("\r", "").Trim(); EducationV2.User user = dc.User.SingleOrDefault(_user => _user.F_realName.Equals(leaders[i]) && _user.F_belongUnitID.Equals(unit.F_ID)); if (user == null) { user = new EducationV2.User(); user.F_ID = Guid.NewGuid().ToString(); user.F_userName = leaders[i]; user.F_realName = leaders[i]; user.F_Role = RoleType.Expert; user.F_belongUnitID = unit.F_ID; dc.User.InsertOnSubmit(user); dc.SubmitChanges(); } if (ddlType.SelectedIndex < 4) { projects[i] = projects[i].Trim().Replace("\"", ""); projects[i] = projects[i].Replace("\r", "").Trim(); SocialProject project = dc.SocialProject.SingleOrDefault(_sp => _sp.F_name.Equals(projects[i])); if (project != null) { continue; } project = new SocialProject(); project.F_unitID = unit.F_ID; project.F_leader = user.F_realName; project.F_leaderID = user.F_ID; project.F_status = ProjectStatus.Approval; project.F_guideProjectID = ddlGuide.SelectedValue; project.F_code = EducationV2.Services.SocialProject.GetCode(ddlType.SelectedValue, txtYear.Text); project.F_status = ProjectStatus.Approval; if (txtSameFund.Text.Trim().Length > 0) { project.F_Fund = decimal.Parse(txtSameFund.Text); } else { project.F_Fund = decimal.Parse(funds[i]); } project.F_applicantDate = startDate; project.F_completeDate = endDate; project.F_type = ddlType.SelectedValue; project.F_name = projects[i]; project.F_ID = Guid.NewGuid().ToString(); CreateAcceptProject(dc, project); dc.SocialProject.InsertOnSubmit(project); } else { ScienceProject project = dc.ScienceProject.SingleOrDefault(_sp => _sp.F_name.Equals(projects[i])); if (project != null) { continue; } project = new ScienceProject(); project.F_unitID = unit.F_ID; project.F_leader = user.F_realName; project.F_leaderID = user.F_ID; project.F_status = ProjectStatus.Approval; project.F_guideProjectID = ddlGuide.SelectedValue; project.F_code = EducationV2.Services.SciProject.GetCode(ddlType.SelectedValue, txtYear.Text); project.F_status = ProjectStatus.Approval; if (txtSameFund.Text.Trim().Length > 0) { project.F_totalFund = decimal.Parse(txtSameFund.Text); } else { project.F_totalFund = decimal.Parse(funds[i]); } project.F_beginDate = startDate; project.F_applicantDate = startDate; project.F_finishDate = endDate; project.F_type = ddlType.SelectedValue; project.F_name = projects[i]; project.F_ID = Guid.NewGuid().ToString(); dc.ScienceProject.InsertOnSubmit(project); CreateAcceptProject(dc, project); } dc.SubmitChanges(); } catch (Exception exp) { Console.Write(exp.ToString()); } } } else { UtilHelper.AlertMsg(Response, "name: " + projects.Length + " unit: " + units.Length + " leader: " + leaders.Length + " fund: " + funds.Length); UtilHelper.AlertMsg(Response, "inequal"); } }
private String saveBaseInfo() { context.Response.ContentType = "text/plain"; DataClassesDataContext dc = new DataClassesDataContext(); bool insert = false; string id; Staff newStaff; if (getStaffID(out id)) { newStaff = dc.Staff.SingleOrDefault(staff => staff.F_StaffID.Equals(id /*paras["F_ID"]*/)); } else { newStaff = new Staff(); newStaff.F_StaffID = Guid.NewGuid().ToString(); insert = true; } newStaff.F_empno = paras["F_empno"]; if (String.IsNullOrWhiteSpace(newStaff.F_empno) == false) { Staff t = dc.Staff.SingleOrDefault(_staff => _staff.F_empno.Equals(newStaff.F_empno)); if (t != null && t.F_StaffID.Equals(newStaff.F_StaffID) == false) { return("档案库中已存在相同的教工号"); } } if (String.IsNullOrEmpty(paras["F_UserID"]) == false) { newStaff.F_UserID = paras["F_UserID"].ToString().Trim(); newStaff.F_userName = paras["F_userName"]; } else { newStaff.F_UserID = createNewUser(dc); newStaff.F_userName = paras["F_empno"]; } newStaff.F_realName = paras["F_realName"]; newStaff.F_sexual = paras["F_sexual"]; if (String.IsNullOrEmpty(paras["F_birthday"]) == false) { newStaff.F_birthday = DateTime.Parse(paras["F_birthday"]); } newStaff.F_bornplace = paras["F_bornplace"]; newStaff.F_nativeplace = paras["F_nativeplace"]; newStaff.F_nationality = paras["F_nationality"]; newStaff.F_party = paras["F_party"]; if (String.IsNullOrEmpty(paras["F_partyEntryDate"]) == false) { newStaff.F_partyEntryDate = DateTime.Parse(paras["F_partyEntryDate"]); } newStaff.F_highestDegree = paras["F_highestDegree"]; newStaff.F_highestEducation = paras["F_highestEducation"]; newStaff.F_highestGrduateSch = paras["F_highestGrduateSch"]; if (String.IsNullOrEmpty(paras["F_workBeginDate"]) == false) { newStaff.F_workBeginDate = DateTime.Parse(paras["F_workBeginDate"]); } newStaff.F_workDept = paras["F_workDeptText"]; newStaff.F_belongDeptID = paras["F_workDept"]; newStaff.F_position = paras["F_position"]; newStaff.F_title = paras["F_title"]; if (String.IsNullOrEmpty(paras["F_posBeginDate"]) == false) { newStaff.F_posBeginDate = DateTime.Parse(paras["F_posBeginDate"]); } newStaff.F_adminRanking = paras["F_adminRanking"]; if (String.IsNullOrEmpty(paras["F_adminRkBeginDate"]) == false) { newStaff.F_adminRkBeginDate = DateTime.Parse(paras["F_adminRkBeginDate"]); } newStaff.F_idType = paras["F_idType"]; newStaff.F_idNumber = paras["F_idNumber"]; if (String.IsNullOrWhiteSpace(newStaff.F_idNumber) == false) { Staff t = dc.Staff.SingleOrDefault(_staff => _staff.F_idType.Equals(newStaff.F_idType) && _staff.F_idNumber.Equals(newStaff.F_idNumber)); if (t != null && t.F_StaffID.Equals(newStaff.F_StaffID) == false) { return("档案库中已存在相同的证件号和证件名"); } } newStaff.F_mobile = paras["F_mobile"]; newStaff.F_phone = paras["F_phone"]; newStaff.F_phone2 = paras["F_phone2"]; newStaff.F_email = paras["F_email"]; newStaff.F_freeAddress = paras["F_freeAddress"]; newStaff.F_fax = paras["F_fax"]; newStaff.F_status = paras["F_status"]; newStaff.F_lastModifyTime = DateTime.Now; if (insert) { dc.Staff.InsertOnSubmit(newStaff); } dc.SubmitChanges(); return(UtilHelper.GetJSON(newStaff)); }
private void CreateAcceptProject(DataClassesDataContext dc, ScienceProject project) { var aps = dc.AcceptProject.Where(apss => apss.F_projectID.Equals(project.F_ID)); dc.AcceptProject.DeleteAllOnSubmit(aps); AcceptProject acceptProject = new AcceptProject(); EducationV2.User user = dc.User.SingleOrDefault(us => us.F_ID.Equals(project.F_leaderID)); EducationV2.ApplicantUnit unit = dc.ApplicantUnit.SingleOrDefault(_au => _au.F_ID.Equals(user.F_belongUnitID)); int num = dc.AcceptProject.Count(); acceptProject.F_ID = Guid.NewGuid().ToString(); acceptProject.F_acceptApplicantState = ProjectStatus.Complete; acceptProject.F_acceptedCode = ""; acceptProject.F_applicantUnit = unit.F_name; acceptProject.F_acceptNo = DateTime.Now.ToString("yyyyMMddhh") + num.ToString(); acceptProject.F_applicantUnit = user.F_adminUnit; acceptProject.F_appliedDate = project.F_applicantDate; acceptProject.F_appliedYear = project.F_applicantDate.Value.Year.ToString(); acceptProject.F_executeState = ProjectStatus.Complete; acceptProject.F_leaderName = user.F_userName; acceptProject.F_leaderID = project.F_leaderID; acceptProject.F_projectID = project.F_ID; acceptProject.F_projectName = project.F_name; acceptProject.F_finishDate = project.F_finishDate.Value; acceptProject.F_projectState = ProjectStatus.Complete; acceptProject.F_projectType = project.F_type; dc.AcceptProject.InsertOnSubmit(acceptProject); var ess = dc.ExecuteStatus.Where(_es => _es.F_projectID.Equals(project.F_ID)); dc.ExecuteStatus.DeleteAllOnSubmit(ess); ExecuteStatus es = new ExecuteStatus(); es.F_acceptNo = acceptProject.F_acceptNo; es.F_planMoney = Decimal.ToInt32(project.F_totalFund.Value); es.F_applicantName = project.F_name; es.F_applicantType = project.F_type; es.F_applicantUnit = user.F_adminUnit; es.F_ContactPhone = user.F_phone; es.F_domain = project.F_belongeddomain; es.F_ID = Guid.NewGuid().ToString(); es.F_leaderID = project.F_leaderID; es.F_leaderName = project.F_leader; es.F_leaderNo = user.F_idNumber; es.F_mobile = user.F_mobile; es.F_projectID = project.F_ID; es.F_status = ProjectStatus.Complete; es.F_startAndStopDate = project.F_beginDate.Value.ToShortDateString() + "-" + project.F_finishDate.Value.ToShortDateString(); dc.ExecuteStatus.InsertOnSubmit(es); var aas = dc.AcceptApplicant.Where(_aa => _aa.F_projectID.Equals(project.F_ID)); dc.AcceptApplicant.DeleteAllOnSubmit(aas); AcceptApplicant aa = new AcceptApplicant(); aa.F_ID = Guid.NewGuid().ToString(); aa.F_type = project.F_type; if (String.IsNullOrEmpty(project.F_belongeddomain)) { aa.F_domain = "未定义"; } else { aa.F_domain = project.F_belongeddomain; } aa.F_name = project.F_name; aa.F_acceptNo = acceptProject.F_acceptNo; aa.F_leaderName = user.F_realName; aa.F_projectUnit = user.F_adminUnit; aa.F_projectUnit = unit.F_name; aa.F_startStopDate = es.F_startAndStopDate; aa.F_totalFund = decimal.Parse(project.F_totalFund.Value.ToString()); aa.F_projectID = project.F_ID; aa.F_projectObject = project.F_finalOutput; aa.F_cooperator = project.F_majorCooperator; aa.F_status = EducationV2.App_Code.ProjectStatus.Complete; aa.F_leaderID = user.F_ID; aa.F_appliedDate = project.F_applicantDate; dc.AcceptApplicant.InsertOnSubmit(aa); }
protected void btnSearch_Click(object sender, EventArgs e) { DataClassesDataContext dc = new DataClassesDataContext(); List <String> userIDs = Global.GetSuitUsers(Session); IEnumerable <ViewPosApl> datasource = getDatasource(false); if (txtKeyword.Text.Trim().Length > 0) { DataTable dt = UtilHelper.ToDataTable(datasource); for (int i = 0; i < dt.Rows.Count; i++) { if (ddlType.SelectedValue.Equals(SearchType.ExactMatch)) { if (dt.Rows[i][ddlField.SelectedValue].ToString().Equals(txtKeyword.Text) == false) { dt.Rows.RemoveAt(i); i--; } } else if (ddlType.SelectedValue.Equals(SearchType.FuzzMatch)) { if (dt.Rows[i][ddlField.SelectedValue].ToString().Contains(txtKeyword.Text) == false) { dt.Rows.RemoveAt(i); i--; } } else { DateTime selectedDate, inputDate; if (DateTime.TryParse(dt.Rows[i][ddlField.SelectedValue].ToString(), out selectedDate)) { if (DateTime.TryParse(txtKeyword.Text, out inputDate) == false) { UtilHelper.AlertMsg("请输入合法的日期"); } else { if (ddlType.SelectedValue.Equals(SearchType.Bigger)) { if (DateTime.Compare(selectedDate, inputDate) < 0) { dt.Rows.RemoveAt(i--); } } else if (ddlType.SelectedValue.Equals(SearchType.Smaller)) { if (DateTime.Compare(selectedDate, inputDate) > 0) { dt.Rows.RemoveAt(i--); } } } } else { UtilHelper.AlertMsg("大小只能用于比较日期"); } } } GridView1.DataSource = dt; } else { GridView1.DataSource = UtilHelper.ToDataTable(datasource); } Session.Add(SessionMgm.DataSource, GridView1.DataSource); GridView1.PageIndex = 0; GridView1.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { // String query = Request.UrlReferrer.Query; // F_ID = query.Substring(query.IndexOf("id=") + 3); F_ID = Session[SessionMgm.SciProjectID].ToString(); if (!IsPostBack) { txtDateDept.Text = DateTime.Now.ToLongDateString(); dateTeam.Text = DateTime.Now.ToLongDateString(); schoolDate.Text = DateTime.Now.ToLongDateString(); EduDate.Text = DateTime.Now.ToLongDateString(); DataClassesDataContext dc = new DataClassesDataContext(); var opinions = dc.AuditOpinion.Where(ao => ao.F_projectID.Equals(F_ID)); socialProject = dc.ScienceProject.Single(c => c.F_ID.Equals(F_ID)); foreach (AuditOpinion opinion in opinions) { if (opinion.F_date == null) { opinion.F_date = DateTime.Now; } if (opinion.F_type.Equals(RoleType.DeptAdmin)) { txtContentDept.Text = opinion.F_content; if (opinion.F_date != null) { txtDateDept.Text = opinion.F_date.Value.ToLongDateString(); } radDept.SelectedValue = opinion.F_result; } else if (opinion.F_type.Equals(RoleType.TeamAdmin)) { txtTeam.Text = opinion.F_content; if (opinion.F_date != null) { dateTeam.Text = opinion.F_date.Value.ToLongDateString(); } radTeam.SelectedValue = opinion.F_result; } else if (opinion.F_type.Equals(RoleType.SchoolAdmin)) { schoolContent.Text = opinion.F_content; if (opinion.F_date != null) { schoolDate.Text = opinion.F_date.Value.ToLongDateString(); } schoolResult.SelectedValue = opinion.F_result; } else if (opinion.F_type.Equals(RoleType.EduAdmin)) { EduContent.Text = opinion.F_content; if (opinion.F_date != null) { EduDate.Text = opinion.F_date.Value.ToLongDateString(); } EduResult.SelectedValue = opinion.F_result; } } ProjectDetail pd = dc.ProjectDetail.SingleOrDefault(_pd => _pd.F_ID.Equals(socialProject.F_guideProjectID)); switch (Session[SessionMgm.Role].ToString()) { case "申报人员(专家)": break; case "部门主管": SetDeptEnable(pd.F_schoolDeadline.Value); break; case "单位主管": SetSchoolEnable(pd.F_schoolDeadline.Value); break; case "教育厅管理人员": SetEduEnable(); break; } } }
private String AddExpert() { context.Response.ContentType = "text/plain"; DataClassesDataContext dc = new DataClassesDataContext(); bool insert = false; User newUser = dc.User.SingleOrDefault(user => user.F_ID.Equals(paras["F_ID"])); if (newUser == null) { newUser = new User(); newUser.F_Role = RoleType.Expert; newUser.F_ID = paras["F_ID"]; insert = true; } newUser.F_userName = paras["F_userName"]; newUser.F_realName = paras["F_realName"]; newUser.F_sexual = paras["F_sexual"]; newUser.F_idType = paras["F_idType"]; newUser.F_nationality = paras["F_nationality"]; newUser.F_highestDegree = paras["F_highestDegree"]; newUser.F_highestEducation = paras["F_highestEducation"]; newUser.F_idNumber = paras["F_idNumber"]; if (String.IsNullOrWhiteSpace(newUser.F_idNumber) == false) { User t = dc.User.SingleOrDefault(_user => _user.F_idType.Equals(newUser.F_idType) && _user.F_idNumber.Equals(newUser.F_idNumber)); if (t != null && t.F_ID.Equals(newUser.F_ID) == false) { return("系统中已存在相同的证件号和证件名"); } } DateTime dt = DateTime.Now; if (String.IsNullOrEmpty(paras["F_birthday"]) == false) { newUser.F_birthday = DateTime.Parse(paras["F_birthday"]); } newUser.F_workspace = paras["F_workspace"]; newUser.F_phone = paras["F_phone"]; newUser.F_workDept = paras["F_workDept"]; newUser.F_legalCode = paras["F_legalCode"]; newUser.F_phone2 = paras["F_phone2"]; newUser.F_position = paras["F_position"]; newUser.F_title = paras["F_title"]; newUser.F_email = paras["F_email"]; newUser.F_mobile = paras["F_mobile"]; newUser.F_adminUnit = paras["F_adminUnit"]; newUser.F_email2 = paras["F_email2"]; newUser.F_fax = paras["F_fax"]; newUser.F_freeAddress = paras["F_freeAddress"]; newUser.F_freeZipCode = paras["F_freeZipCode"]; newUser.F_mostFamiliarSubject = paras["F_mostFamiliarSubject"]; newUser.F_academicDuty = paras["F_academicDuty"]; if (!String.IsNullOrWhiteSpace(paras["F_familiarSubject"])) { String[] subjects = paras["F_familiarSubject"].Split(new char[] { ',' }); if (subjects.Length >= 1) { newUser.F_familiarSubject1 = subjects[0]; } if (subjects.Length == 2) { newUser.F_familiarSubject2 = subjects[1]; } } var educationBackgrounds = dc.EducationBackground.Where(eb => eb.F_userID.Equals(newUser.F_ID)); dc.EducationBackground.DeleteAllOnSubmit(educationBackgrounds); if (!String.IsNullOrWhiteSpace(paras["F_school"])) { String[] schools = paras["F_school"].Split(new char[] { ',' }); String[] majors = paras["F_major"].Split(new char[] { ',' }); String[] entryDates = paras["F_entryDate"].Split(new char[] { ',' }); String[] educations = paras["F_education"].Split(new char[] { ',' }); String[] degrees = paras["F_degree"].Split(new char[] { ',' }); String[] graduateDates = paras["F_graduateDate"].Split(new char[] { ',' }); String[] countrys = paras["F_country"].Split(new char[] { ',' }); for (int i = 0; i < schools.Length; i++) { EducationBackground eb = new EducationBackground(); eb.F_userID = newUser.F_ID; eb.F_ID = Guid.NewGuid().ToString(); eb.F_school = schools[i]; eb.F_major = majors[i]; dt = DateTime.Now; if (entryDates[i].Trim().Length > 0) { DateTime.TryParse(entryDates[i], out dt); eb.F_entryDate = dt; } if (graduateDates[i].Trim().Length > 0) { DateTime.TryParse(graduateDates[i], out dt); eb.F_graduateDate = dt; } eb.F_education = educations[i]; eb.F_degree = degrees[i]; eb.F_country = countrys[i]; dc.EducationBackground.InsertOnSubmit(eb); } } var certificates = dc.Certificate.Where(cert => cert.F_userID.Equals(newUser.F_ID)); dc.Certificate.DeleteAllOnSubmit(certificates); if (!String.IsNullOrWhiteSpace(paras["F_name"])) { String[] F_names = paras["F_name"].Split(new char[] { ',' }); String[] F_codes = paras["F_code"].Split(new char[] { ',' }); String[] F_grantDates = paras["F_grantDate"].Split(new char[] { ',' }); String[] F_grantOrgs = paras["F_grantOrg"].Split(new char[] { ',' }); for (int i = 0; i < F_names.Length; i++) { Certificate cert = new Certificate(); cert.F_ID = Guid.NewGuid().ToString(); cert.F_userID = newUser.F_ID; cert.F_name = F_names[i]; cert.F_code = F_codes[i]; if (F_grantDates[i].Trim().Length > 0) { DateTime.TryParse(F_grantDates[i], out dt); cert.F_grantDate = dt; } cert.F_grantOrg = F_grantOrgs[i]; dc.Certificate.InsertOnSubmit(cert); } } if (insert) { dc.User.InsertOnSubmit(newUser); } dc.SubmitChanges(); return("保存成功"); }
private void SavePage2() { String F_ID = context.Session[SessionMgm.VisitUserID].ToString(); DataClassesDataContext dc = new DataClassesDataContext(); bool insert = false; User newUser = dc.User.SingleOrDefault(user => user.F_ID.Equals(F_ID)); if (newUser == null) { newUser = new User(); newUser.F_ID = F_ID; newUser.F_Role = RoleType.Expert; insert = true; } Decimal num = 0; Decimal.TryParse(paras["F_appliedCivInvPatent"], out num); newUser.F_appliedCivInvPatent = num; num = 0; Decimal.TryParse(paras["F_authedCivInvPatent"], out num); newUser.F_authedCivInvPatent = num; num = 0; Decimal.TryParse(paras["F_appliedForeInvPatent"], out num); newUser.F_appliedForeInvPatent = num; num = 0; Decimal.TryParse(paras["F_authedForeInvPatent"], out num); newUser.F_authedForeInvPatent = num; num = 0; Decimal.TryParse(paras["F_appliedCivUtiPatent"], out num); newUser.F_appliedCivUtiPatent = num; num = 0; Decimal.TryParse(paras["F_authedCivUtilPatent"], out num); newUser.F_authedCivUtilPatent = num; num = 0; Decimal.TryParse(paras["F_appliedForUtiPatent"], out num); newUser.F_appliedForUtiPatent = num; num = 0; Decimal.TryParse(paras["F_authedForUtiPatent"], out num); newUser.F_authedForUtiPatent = num; num = 0; Decimal.TryParse(paras["F_publishCivPaper"], out num); newUser.F_publishCivPaper = num; num = 0; Decimal.TryParse(paras["F_publishForPaper"], out num); newUser.F_publishForPaper = num; num = 0; Decimal.TryParse(paras["F_publishMonograph"], out num); newUser.F_publishMonograph = num; DateTime dt = DateTime.Now; var workexperiences = dc.WorkExperience.Where(we => we.F_userID.Equals(F_ID)); dc.WorkExperience.DeleteAllOnSubmit(workexperiences); if (!String.IsNullOrWhiteSpace(paras["F_workspace"])) { String[] F_workspaces = paras["F_workspace"].Split(new char[] { ',' }); String[] F_beginDates = paras["F_beginDate"].Split(new char[] { ',' }); String[] F_endDates = paras["F_endDate"].Split(new char[] { ',' }); String[] F_contents = paras["F_content"].Split(new char[] { ',' }); for (int i = 0; i < F_workspaces.Length; i++) { WorkExperience eb = new WorkExperience(); eb.F_userID = newUser.F_ID; eb.F_workspace = F_workspaces[i]; eb.F_ID = Guid.NewGuid().ToString(); if (F_beginDates[i].Trim().Length > 0) { dt = DateTime.Now; DateTime.TryParse(F_beginDates[i], out dt); eb.F_beginDate = dt; } if (F_endDates[i].Trim().Length > 0) { dt = DateTime.Now; DateTime.TryParse(F_endDates[i], out dt); eb.F_endDate = dt; } eb.F_content = F_contents[i]; dc.WorkExperience.InsertOnSubmit(eb); } } var patents = dc.Patent.Where(pa => pa.F_userID.Equals(F_ID)); dc.Patent.DeleteAllOnSubmit(patents); if (!String.IsNullOrWhiteSpace(paras["F_patentName"])) { String[] F_patentNames = paras["F_patentName"].Split(new char[] { ',' }); String[] F_patentCodes = paras["F_patentCode"].Split(new char[] { ',' }); String[] F_patentTypes = paras["F_patentType"].Split(new char[] { ',' }); String[] F_patentDeclareDates = paras["F_patentDeclareDate"].Split(new char[] { ',' }); for (int i = 0; i < F_patentNames.Length; i++) { Patent eb = new Patent(); eb.F_userID = newUser.F_ID; eb.F_ID = Guid.NewGuid().ToString(); if (F_patentDeclareDates[i].Trim().Length > 0) { dt = DateTime.Now; DateTime.TryParse(F_patentDeclareDates[i], out dt); eb.F_declareDate = dt; } eb.F_name = F_patentNames[i]; eb.F_type = F_patentTypes[i]; eb.F_code = F_patentCodes[i]; dc.Patent.InsertOnSubmit(eb); } } var papers = dc.PublishedPaper.Where(pp => pp.F_USERID.Equals(F_ID)); dc.PublishedPaper.DeleteAllOnSubmit(papers); if (!String.IsNullOrWhiteSpace(paras["F_paperName"])) { String[] F_paperNames = paras["F_paperName"].Split(new char[] { ',' }); String[] F_journalNames = paras["F_journalName"].Split(new char[] { ',' }); String[] F_journalCodes = paras["F_journalCode"].Split(new char[] { ',' }); String[] F_volumes = paras["F_volume"].Split(new char[] { ',' }); String[] F_paperRanks = paras["F_paperRank"].Split(new char[] { ',' }); for (int i = 0; i < F_paperNames.Length; i++) { PublishedPaper eb = new PublishedPaper(); eb.F_USERID = F_ID; eb.F_ID = Guid.NewGuid().ToString(); eb.F_journalCode = F_journalCodes[i]; eb.F_journalName = F_journalNames[i]; eb.F_name = F_paperNames[i]; eb.F_rank = F_paperRanks[i]; eb.F_volume = F_volumes[i]; dc.PublishedPaper.InsertOnSubmit(eb); } } var awards = dc.Award.Where(pp => pp.F_userID.Equals(F_ID)); dc.Award.DeleteAllOnSubmit(awards); if (!String.IsNullOrWhiteSpace(paras["F_awardName"])) { String[] F_awardDates = paras["F_awardDate"].Split(new char[] { ',' }); String[] F_awardNames = paras["F_awardName"].Split(new char[] { ',' }); String[] F_awardProjectNames = paras["F_awardProjectName"].Split(new char[] { ',' }); String[] F_awardGrades = paras["F_awardGrade"].Split(new char[] { ',' }); String[] F_awardRanks = paras["F_awardRank"].Split(new char[] { ',' }); String[] F_issuedUnits = paras["F_issuedUnit"].Split(new char[] { ',' }); for (int i = 0; i < F_awardDates.Length; i++) { Award eb = new Award(); eb.F_userID = F_ID; eb.F_ID = Guid.NewGuid().ToString(); dt = DateTime.Now; DateTime.TryParse(F_awardDates[i], out dt); eb.F_grantDate = dt; eb.F_name = F_awardNames[i]; eb.F_projectName = F_awardProjectNames[i]; eb.F_grade = F_awardGrades[i]; eb.F_rank = F_awardRanks[i]; eb.F_issuedUnit = F_issuedUnits[i]; dc.Award.InsertOnSubmit(eb); } } if (insert) { dc.User.InsertOnSubmit(newUser); } dc.SubmitChanges(); }