public static int getId(string name) { using (var db = new TeachingCenterEntities()) { SourceCategory sc = db.SourceCategory.Single(a => a.SourceCategory_name == name); return(sc.SourceCategory_id); } }
public static string getCategoryName(int id) { using (var db = new TeachingCenterEntities()) { ProCatCategory pc = db.ProCatCategory.Single(a => a.ProCatCategory_id == id); return(pc.ProCatCategory_name); } }
protected void Page_Load(object sender, EventArgs e) { try { string teacher = Session["AdminID"].ToString(); if (!IsPostBack) { int id = 0; if (Request.QueryString["id"] != null) { id = Convert.ToInt32(Request.QueryString["id"]); } else { Response.Redirect("ProjectList.aspx"); } Dictionary <int, string> stage = new Dictionary <int, string>(); stage.Add(0, "初审"); stage.Add(1, "中期"); stage.Add(2, "结题"); Dictionary <int, string> status = new Dictionary <int, string>(); status.Add(-2, "未分配至评审"); status.Add(-1, "未评判结果"); status.Add(1, "已通过当前阶段"); status.Add(0, "未通过"); status.Add(-100, "已过期"); using (var db = new TeachingCenterEntities()) { var project = db.ProjectInfo.SingleOrDefault(a => a.project_id == id); lbName.Text = project.name; lbCategory.Text = project.category_name; lbTeacher.Text = project.teacher_name; content_id.Value = id.ToString(); var project_stage = (from it in db.ProjectStage where it.project_id == id orderby it.stage descending select it).FirstOrDefault(); int now_stage = project_stage.stage; int now_status = project_stage.is_pass; lbStage.Text = stage[now_stage]; lbStatus.Text = status[now_status]; lbContent.Text = Server.HtmlDecode(project_stage.project_content); string fund = (from it in db.Project where it.project_id == id select it).FirstOrDefault().fund; lbFund.Text = fund; //if (now_status == -2) // btnDeliver.Visible = true; //if (now_status == -1) // btnJudge.Visible = true; // 绑定评审列表 //var judge = from it in db.Teacher where it.is_judge == 1 select it; //rptJudge.DataSource = judge.ToList(); //rptJudge.DataBind(); } } } catch { JSHelper.AlertThenRedirect("请先登录!", "Login.aspx"); } }
//分页 void DataBindToRepeater(int currentPage) { int id = Convert.ToInt16(Request.QueryString["id"]); using (var db = new TeachingCenterEntities()) { //var catagory = from it in db.ActivityTeacher where it.activity_id == id select it; List <ActivityTeacher> at = db.ActivityTeacher.Where(a => a.activity_id == id).ToList(); List <Teacher> teacher = new List <Teacher>(); foreach (ActivityTeacher i in at) { Teacher t = db.Teacher.SingleOrDefault(a => a.id == i.teacher_id); teacher.Add(t); } rptCategory.DataSource = teacher.ToList(); rptCategory.DataBind(); ltCount.Text = teacher.Count().ToString(); PagedDataSource pds = new PagedDataSource(); pds.AllowPaging = true; pds.PageSize = 5; pds.DataSource = teacher.ToList(); pds.CurrentPageIndex = currentPage - 1; rptCategory.DataSource = pds; rptCategory.DataBind(); ltTotal.Text = pds.PageCount.ToString(); if (Convert.ToInt32(ltNow.Text) == 1) { btnLast.Enabled = false; } else { btnLast.Enabled = true; } if (Convert.ToInt32(ltNow.Text) == pds.PageCount) { btnNext.Enabled = false; } else { btnNext.Enabled = true; } } }
protected void btnExport_Click(object sender, EventArgs e) { DataTable dt = new DataTable(); using (var db = new TeachingCenterEntities()) { List <Service> service; DateTime min = new DateTime(1900, 1, 1); DateTime max = new DateTime(2300, 12, 31); if (logmin.Value != "") { min = Convert.ToDateTime(logmin.Value); } if (logmax.Value != "") { max = Convert.ToDateTime(logmax.Value).AddDays(1); } if (dropCategory.SelectedValue != "全部分类") { int category = ServiceHelper.getCategoryID(dropCategory.SelectedValue); service = db.Service.Where(a => a.Service_isdeleted == 0 && a.Service_category == category && a.Service_time >= min && a.Service_time <= max).OrderBy(a => a.Service_isdeal).ThenByDescending(a => a.Service_time).ToList(); } else { service = db.Service.Where(a => a.Service_isdeleted == 0 && a.Service_time >= min && a.Service_time <= max).OrderBy(a => a.Service_isdeal).ThenByDescending(a => a.Service_time).ToList(); } DataColumn dc1 = new DataColumn("序号", System.Type.GetType("System.String")); DataColumn dc2 = new DataColumn("申请人", System.Type.GetType("System.String")); DataColumn dc3 = new DataColumn("申请时间", System.Type.GetType("System.DateTime")); DataColumn dc4 = new DataColumn("联系方式", System.Type.GetType("System.String")); DataColumn dc5 = new DataColumn("备注", System.Type.GetType("System.String")); DataColumn dc6 = new DataColumn("审核状态", System.Type.GetType("System.String")); dt.Columns.Add(dc1); dt.Columns.Add(dc2); dt.Columns.Add(dc3); dt.Columns.Add(dc4); dt.Columns.Add(dc5); dt.Columns.Add(dc6); int count = 1; foreach (var i in service) { DataRow row = dt.NewRow(); row["序号"] = count.ToString(); row["申请人"] = TeacherHelper.getTeacherNameByID(i.Service_teacher); row["申请时间"] = i.Service_time.ToString(); row["联系方式"] = i.Service_phone.ToString(); row["备注"] = i.Service_remarks.ToString(); row["审核状态"] = i.Service_isdeal == 0 ? "未处理" : "已处理"; dt.Rows.Add(row); } } ExcleHelper.ExportDataGrid(dt, "application/ms-excel", "教师服务申请.xls"); }
static public bool checkID(int id) { using (var db = new TeachingCenterEntities()) { var dev = from it in db.Develop where it.Develop_id == id select it; return(dev.ToList().Count == 0 ? false : true); } }
protected void Page_Load(object sender, EventArgs e) { try { string teacher = Session["AdminID"].ToString(); ltName.Text = AdminHelper.getNameByID(teacher); using (var db = new TeachingCenterEntities()) { var service = from it in db.Service where it.Service_isdeal == 0 && it.Service_isdeleted == 0 select it; ltServese.Text = service.ToList().Count().ToString(); if (service.Count() == 0) { services.Visible = false; } int number = 0; var apply = from it in db.JudgeApplication select it; //foreach(var a in apply) //{ // var record = (from b in db.ProjectStage where b.project_id == a orderby b.stage descending select b).FirstOrDefault(); // if (record.is_pass == -2) // number++; //} number = apply.Count(); if (number == 0) { applys.Visible = false; } ltApply.Text = number.ToString(); int p_number = 0; var project = from it in db.Project where it.is_deleted == 0 select it; foreach (var item in project) { var project_stage = (from it in db.ProjectStage where it.project_id == item.project_id orderby it.stage descending select it).FirstOrDefault(); if (project_stage.is_pass == -1 || project_stage.is_pass == -2) { p_number++; } } if (p_number == 0) { projects.Visible = false; } ltProject.Text = p_number.ToString(); Admin admin = db.Admin.Single(a => a.Admin_id == teacher); if (admin.Admin_emai_check == 0) { email.Visible = true; } } } catch { JSHelper.AlertThenRedirect("请先登录!", "Login.aspx"); } }
static public bool checkExit(string id) { using (var db = new TeachingCenterEntities()) { //if() var admin = from it in db.Admin where it.Admin_id == id select it; return(admin.Count() != 0 ? true : false); } }
protected void lbtAdd_Click(object sender, EventArgs e) { try { string alert; int teacher = TeacherHelper.getTeacherIDByNumber(Session["TeacherNumber"].ToString()); //int teacher = 1; int id; //int teacher = 1, id = 3; try { id = Convert.ToInt32(Request.QueryString["id"].ToString()); } catch { id = 3; } using (var db = new TeachingCenterEntities()) { Activity ac = db.Activity.Single(a => a.Activity_id == id); if (ac.Activity_nowcount >= ac.Activity_limitcount) { alert = "操作失败,人数已达到上限。"; } else if (ac.Activity_hold_time < DateTime.Now) { alert = "该活动已结束!"; } else { var acs = from it in db.ActivityTeacher where it.teacher_id == teacher && it.activity_id == id select it; if (acs.Count() > 0) { alert = "您已参加了该项目!"; } else { ac.Activity_nowcount++; db.SaveChanges(); ActivityTeacher at = new ActivityTeacher(); at.activity_id = id; at.teacher_id = teacher; db.ActivityTeacher.Add(at); db.SaveChanges(); alert = "参与成功!"; } } } JSHelper.ShowAlert(alert); } catch { JSHelper.ShowAlert("请先登录!"); } }
private void SendMail() { string teacher = Session["AdminID"].ToString(); using (var db = new TeachingCenterEntities()) { Admin admin = db.Admin.Single(a => a.Admin_id == teacher); Session["random"] = MailHelper.Random_check(admin.Admin_emai); } }
protected void lbtSearch_Click(object sender, EventArgs e) { if ((logmin.Text == "" && logmax.Text != "") || (logmin.Text != "" && logmax.Text == "")) { Response.Write("<script>alert('请选择完整的日期范围!');</script>"); } else { string title = ""; if (txtTitle.Text.Length != 0) { title = txtTitle.Text; } List <EducateSource> result = new List <EducateSource>(); using (var db = new TeachingCenterEntities()) { var src = from it in db.EducateSource where it.is_deleted == 0 orderby it.publish_time descending select it; if (title != "") { src = from it in db.EducateSource where it.title.IndexOf(title) >= 0 && it.is_deleted == 0 orderby it.publish_time descending select it; } if (logmin.Text != "" && logmax.Text != "") { DateTime min = Convert.ToDateTime(logmax.Text); DateTime max = Convert.ToDateTime(logmin.Text); foreach (EducateSource item in src) { DateTime time = Convert.ToDateTime(item.publish_time); if (DateTime.Compare(time, min) < 0 && DateTime.Compare(time, max) > 0) { result.Add(item); } } } else if (logmin.Text == "" && logmax.Text == "") { result = src.ToList(); } if (result.Count != 0) { currentPage.Text = "1"; TotalPage.Text = Math.Ceiling(result.Count() / 10.0).ToString(); rptSource.DataSource = result.ToList().Take(10); rptSource.DataBind(); ltSum.Text = result.Count().ToString(); Session["ds"] = result.ToList(); } else { Response.Write("<script>alert('搜索无结果!');location.href='EduSrcList.aspx';</script>"); } } } }
protected void Page_Load(object sender, EventArgs e) { try { //判断是不是评审 if (!TeacherHelper.isJudge(Session["TeacherNumber"].ToString())) { liJudge.Visible = false; } int project_id = 5; int stage = 0; if (Request.QueryString["id"] != null && Request.QueryString["stage"] != null) { project_id = Convert.ToInt32(Request.QueryString["id"]); stage = Convert.ToInt32(Request.QueryString["stage"]); } else { Response.Redirect("main-index.aspx"); } if (Session["TeacherNumber"] == null) { Response.Redirect("main-index.aspx"); } else { this.FileUp.Attributes.Add("onchange", "javascript:return Check_FilePath();"); if (!IsPostBack) { using (var db = new TeachingCenterEntities()) { var projectinfo = (from it in db.ProjectInfo where it.project_id == project_id select it).FirstOrDefault(); txtName.Text = projectinfo.name; txtCategory.Text = projectinfo.category_name; txtDuty.Text = projectinfo.teacher_name; DateTime time = Convert.ToDateTime(projectinfo.submit_time); txtYear.Text = time.Year.ToString(); txtMonth.Text = time.Month.ToString(); txtDay.Text = time.Day.ToString(); var project = (from it in db.Project where it.project_id == project_id select it).FirstOrDefault(); txtMoney.Text = project.fund; string department = (from it in db.Teacher where it.id == project.teacher_id select it).FirstOrDefault().department; txtDepartment.Text = department; var project_stage = (from it in db.ProjectStage where it.project_id == project_id select it).FirstOrDefault(); } } } } catch { JSHelper.AlertThenRedirect("请先登录!", "main-index.aspx"); } }
protected void lbtSearch_Click(object sender, EventArgs e) { if ((logmin.Text == "" && logmax.Text != "") || (logmin.Text != "" && logmax.Text == "")) { Response.Write("<script>alert('请选择完整的日期范围!');</script>"); } else { string project_name = ""; if (txtName.Text.Length != 0) { project_name = txtName.Text; } List <ProjectCategory> result = new List <ProjectCategory>(); using (var db = new TeachingCenterEntities()) { var pro_category = from it in db.ProjectCategory where it.is_deleted == 1 orderby it.end_time select it; if (project_name != "") { pro_category = from it in db.ProjectCategory where it.name.IndexOf(project_name) >= 0 && it.is_deleted == 1 orderby it.end_time select it; } if (logmin.Text != "" && logmax.Text != "") { DateTime min = Convert.ToDateTime(logmax.Text); DateTime max = Convert.ToDateTime(logmin.Text); foreach (ProjectCategory item in pro_category) { DateTime time = Convert.ToDateTime(item.end_time); if (DateTime.Compare(time, min) < 0 && DateTime.Compare(time, max) > 0) { result.Add(item); } } } else if (logmin.Text == "" && logmax.Text == "") { result = pro_category.ToList(); } if (result.Count != 0) { currentPage.Text = "1"; TotalPage.Text = Math.Ceiling(result.Count() / 10.0).ToString(); rptCategory.DataSource = result.ToList().Take(10); rptCategory.DataBind(); ltSum.Text = result.Count().ToString(); Session["ds"] = result.ToList(); } else { Response.Write("<script>alert('搜索无结果!');location.href='RecycleProjectCategory.aspx';</script>"); } } } }
protected void lbtExport_Click(object sender, EventArgs e) { DataTable dt = new DataTable(); using (var db = new TeachingCenterEntities()) { DateTime now = DateTime.Now; DateTime last = now.AddYears(-1); int teacher = TeacherHelper.getTeacherIDByNumber(Session["TeacherNumber"].ToString()); //int teacher = 1; var at = from it in db.ActivityTeacher where it.teacher_id == teacher select it; List <Activity> ac = new List <Activity>(); foreach (var i in at) { Activity activity = db.Activity.Single(a => a.Activity_id == i.activity_id && a.Activity_hold_time >= last && a.Activity_hold_time <= now); if (activity.Activity_isdeleted == 0) { ac.Add(activity); } } DataColumn dc1 = new DataColumn("序号", System.Type.GetType("System.String")); DataColumn dc5 = new DataColumn("活动类型", System.Type.GetType("System.String")); DataColumn dc2 = new DataColumn("活动名称", System.Type.GetType("System.String")); DataColumn dc3 = new DataColumn("活动地点", System.Type.GetType("System.String")); DataColumn dc4 = new DataColumn("活动时间", System.Type.GetType("System.DateTime")); dt.Columns.Add(dc1); dt.Columns.Add(dc5); dt.Columns.Add(dc2); dt.Columns.Add(dc3); dt.Columns.Add(dc4); int count = 1; foreach (var i in ac) { DataRow row = dt.NewRow(); row["序号"] = count.ToString(); row["活动类型"] = ActivityHelper.getCategoryName(i.Activity_categoryid); row["活动名称"] = i.Activity_title; row["活动地点"] = i.Activity_place; row["活动时间"] = i.Activity_hold_time; dt.Rows.Add(row); } } ExcleHelper.ExportDataGrid(dt, "application/ms-excel", "我的活动.xls"); }
protected void BtnReset_Click(object sender, EventArgs e) { using (var db = new TeachingCenterEntities()) { string number = ltNumber.Text; Teacher te = db.Teacher.Single(a => a.number == number); te.password = PwdHelper.MD5("ouc" + number); db.SaveChanges(); //Server.Transfer("ResetPwd.aspx"); JSHelper.AlertThenRedirect("重置成功,重置密码为ouc+教师工号!", "ResetPwd.aspx"); } }
// 开启下一阶段前将尚未完善的项目和为评判结果的评审记录设置为超时 protected bool setIsPass() { try { // 获取当前项目类型id int id = Convert.ToInt32(pro_id.Value.ToString()); using (var db = new TeachingCenterEntities()) { var category = (from it in db.ProjectCategory where it.id == id select it).FirstOrDefault(); // 当前项目类型 DateTime end_time = Convert.ToDateTime(category.end_time); // 提交项目截止时间 DateTime judge_end_time = Convert.ToDateTime(category.judge_end_time); // 评审评判截止时间 // 遍历所有项目 var project = from it in db.Project where it.is_deleted == 0 select it; foreach (var item in project) { // 判断是否属于当前项目类型 if (item.category == id) { // 获取该项目当前的阶段 var pro = (from it in db.ProjectStage where it.project_id == item.project_id orderby it.stage descending select it).FirstOrDefault(); // 若该项目当前阶段落后于项目类型的阶段,则设置为超时 if (pro.stage < category.stage || pro.is_pass < 0) { pro.is_pass = -100; } // 遍历该项目分配至评审的所有记录 var judge = from it in db.ProjectJudge where it.project_id == item.project_id select it; if (judge.Count() != 0) { foreach (var record in judge) { // 若该记录当前阶段落后于项目类型的阶段,则设置为超时 if (record.is_pass == -1) { record.is_pass = -100; } } } } } db.SaveChanges(); } return(true); } catch { return(false); } }
protected void Page_Load(object sender, EventArgs e) { try { //判断是不是评审 if (!TeacherHelper.isJudge(Session["TeacherNumber"].ToString())) { //liJudge.Visible = false; this.FileUp.Attributes.Add("onchange", "javascript:return Check_FilePath();"); } if (!IsPostBack) { if (Session["TeacherNumber"] == null) { Response.Redirect("main-index.aspx"); } else { if (!IsPostBack) { using (var db = new TeachingCenterEntities()) { int teacher_id = TeacherHelper.getTeacherIDByNumber(Session["TeacherNumber"].ToString()); var teacher = (from it in db.Teacher where it.id == teacher_id select it).FirstOrDefault(); if (teacher.department == "") { JSHelper.AlertThenRedirect("请先完善个人单位!", "Person-index.aspx"); } DateTime now = DateTime.Now; var category = from it in db.ProjectCategory where it.is_deleted == 0 && it.stage == 0 select it; List <ProjectCategory> show = new List <ProjectCategory>(); foreach (var item in category) { DateTime end = Convert.ToDateTime(item.end_time); if (DateTime.Compare(end, now) > 0) { show.Add(item); } } rptSelect.DataSource = show; rptSelect.DataBind(); } } } } } catch { JSHelper.AlertThenRedirect("请先登录!", "main-index.aspx"); } }
protected void btnNewPwd_Click(object sender, EventArgs e) { string teacher = Session["AdminID"].ToString(); using (var db = new TeachingCenterEntities()) { Admin admin = db.Admin.Single(a => a.Admin_id == teacher); admin.Admin_pwd = PwdHelper.MD5(txtNewPwd.Text); db.SaveChanges(); Server.Transfer("AdminInformation.aspx"); //JSHelper.AlertThenRedirect("修改成功!", "AdminInformation.aspx"); } }
protected void rptActivity_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { LinkButton linkbuttom = (LinkButton)e.Item.FindControl("lbtDelete"); int id = Convert.ToInt32(linkbuttom.Text); using (var db = new TeachingCenterEntities()) { Activity ac = db.Activity.Single(a => a.Activity_id == id); linkbuttom.Text = ac.Activity_time < DateTime.Now ? "" : "取消参与该活动"; } } }
protected void lbtExport_Click(object sender, EventArgs e) { DataTable dt = new DataTable(); int teacher = TeacherHelper.getTeacherIDByNumber(Session["TeacherNumber"].ToString()); using (var db = new TeachingCenterEntities()) { List <Service> service; DateTime now = DateTime.Now; DateTime last = now.AddYears(-1); service = db.Service.Where(a => a.Service_isdeleted == 0 && a.Service_teacher == teacher && a.Service_time >= last && a.Service_time < now).OrderBy(a => a.Service_isdeal).ThenByDescending(a => a.Service_time).ToList(); DataColumn dc1 = new DataColumn("序号", System.Type.GetType("System.String")); DataColumn dc1_1 = new DataColumn("申请类型", System.Type.GetType("System.String")); DataColumn dc2 = new DataColumn("申请人", System.Type.GetType("System.String")); DataColumn dc3 = new DataColumn("申请时间", System.Type.GetType("System.DateTime")); DataColumn dc4 = new DataColumn("联系方式", System.Type.GetType("System.String")); DataColumn dc5 = new DataColumn("备注", System.Type.GetType("System.String")); DataColumn dc6 = new DataColumn("审核状态", System.Type.GetType("System.String")); DataColumn dc7 = new DataColumn("管理员回复", System.Type.GetType("System.String")); dt.Columns.Add(dc1); dt.Columns.Add(dc1_1); dt.Columns.Add(dc2); dt.Columns.Add(dc3); dt.Columns.Add(dc4); dt.Columns.Add(dc5); dt.Columns.Add(dc6); dt.Columns.Add(dc7); int count = 1; foreach (var i in service) { DataRow row = dt.NewRow(); row["序号"] = count.ToString(); row["申请人"] = TeacherHelper.getTeacherNameByID(i.Service_teacher); row["申请类型"] = ServiceHelper.getCategoryName(i.Service_category); row["申请时间"] = i.Service_time.ToString(); row["联系方式"] = i.Service_phone.ToString(); row["备注"] = i.Service_remarks.ToString(); row["审核状态"] = i.Service_isdeal == 0 ? "未处理" : "已处理"; row["管理员回复"] = i.Service_reply; dt.Rows.Add(row); } } ExcleHelper.ExportDataGrid(dt, "application/ms-excel", "我的服务.xls"); }
protected void btnChange_Click(object sender, EventArgs e) { int id = Convert.ToInt16(lbReplyID.Text); using (var db = new TeachingCenterEntities()) { Service sc = db.Service.Single(a => a.Service_id == id); sc.Service_isdeal = 1; sc.Service_reply = txtReply.Text; db.SaveChanges(); Server.Transfer("ServiceManage.aspx"); // JSHelper.AlertThenRedirect("处理成功!", "ServiceManage.aspx"); } }
static public string getTeacherList(int id) { using (var db = new TeachingCenterEntities()) { string list = ""; var at = from it in db.ActivityTeacher where it.activity_id == id select it; foreach (var i in at) { list += TeacherHelper.getTeacherNameByID(i.teacher_id) + " , "; } return(list.Length == 0 ? "无" : list.Substring(0, list.Length - 2)); } }
//分页 void DataBindToRepeater(int currentPage) { string teacher = Session["AdminID"].ToString(); using (var db = new TeachingCenterEntities()) { var catagory = from it in db.DevelopCategory select it; rptCategory.DataSource = catagory.ToList(); rptCategory.DataBind(); ltCount.Text = catagory.Count().ToString(); PagedDataSource pds = new PagedDataSource(); pds.AllowPaging = true; pds.PageSize = 5; pds.DataSource = catagory.ToList(); pds.CurrentPageIndex = currentPage - 1; rptCategory.DataSource = pds; rptCategory.DataBind(); ltTotal.Text = pds.PageCount.ToString(); if (Convert.ToInt32(ltNow.Text) == 1) { btnLast.Enabled = false; } else { btnLast.Enabled = true; } if (Convert.ToInt32(ltNow.Text) == pds.PageCount) { btnNext.Enabled = false; } else { btnNext.Enabled = true; } } }
// 列表中删除一行 protected void rptSource_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "Delete") { int id = Convert.ToInt32(e.CommandArgument.ToString()); using (var db = new TeachingCenterEntities()) { var src = db.EducateSource.SingleOrDefault(a => a.id == id); src.is_deleted = 1; src.deletedtime = DateTime.Now; db.SaveChanges(); Response.Write("<script>alert('删除成功!');location.href='EduSrcList.aspx';</script>"); } } }
//检查工号是否存在 static public bool checkNumber(string number) { using (var db = new TeachingCenterEntities()) { var teacher = from it in db.Teacher where it.number == number select it; if (teacher.Count() == 0) { return(true); } else { return(false); } } }
public bool judgeDisplay(int id) { using (var db = new TeachingCenterEntities()) { var banners = (from it in db.Picture orderby it.is_top descending select it).Take(4); for (int i = 0; i < banners.Count(); i++) { if (banners.ToList()[i].Picture_id == id) { return(true); } } return(false); } }
static public bool checkCategoryNameExit(string name) { using (var db = new TeachingCenterEntities()) { var sc = from it in db.DevelopCategory where it.DevelopCategory_name == name select it; if (sc.Count() == 0) { return(false); } else { return(true); } } }
// 通过项目id获取项目当前所属阶段 public int getStage(int id) { try { using (var db = new TeachingCenterEntities()) { var stage = (from it in db.ProjectStage where it.project_id == id orderby it.stage descending select it).FirstOrDefault(); return(stage.stage); } } catch { return(0); } }
protected void ltbLogin_Click(object sender, EventArgs e) { string id = txtID.Text; string pwd = txtPwd.Text; if (id.Length == 0 || pwd.Length == 0) { JSHelper.ShowAlert("输入不能为空!"); } else if (TeacherHelper.checkNumber(id)) { JSHelper.ShowAlert("工号不存在!"); } else { if (Session["PngLogin"] != null) { if (TextBox1.Value != Session["PngLogin"].ToString()) { JSHelper.ShowAlert("验证码错误!"); } else { using (var db = new TeachingCenterEntities()) { Teacher ad = db.Teacher.Single(a => a.number == id); if (ad.password == PwdHelper.MD5(pwd)) { //if (cbxRemeberUser.Checked == true) { CookieHelper.SetCookie("TeacherNumber", txtID.Text, DateTime.Now.AddDays(30)); CookieHelper.SetCookie("TeacherPwd", txtPwd.Text, DateTime.Now.AddDays(30)); } //JSHelper.AlertThenRedirect("登陆成功!","main-index.aspx"); Session["TeacherNumber"] = id; Server.Transfer("main-index.aspx"); //JSHelper.js("window.history.go(0);"); } else { JSHelper.ShowAlert("密码错误!"); } } } } } }
protected void btnSub_Click(object sender, EventArgs e) { string title = txtTitle.Text; string content = myEditor11.InnerHtml; string summary = TextBox1.Text; if (title.Length == 0 || content.Length == 0) { JSHelper.ShowAlert("输入不能为空!"); } else if (summary.Length == 0) { JSHelper.ShowAlert("输入不能为空!"); } else { try { using (var db = new TeachingCenterEntities()) { int id = Convert.ToInt32(Request.QueryString["id"]); ActivitySummary acsu = db.ActivitySummary.Single(a => a.ActivitySummary_id == id); acsu.ActivitySummary_title = title; acsu.ActivitySummary_content = content; acsu.ActivitySummary_summary = summary; if (dropAuthor.SelectedValue == "0") { acsu.ActivitySummary_author = AdminHelper.getNameByID(Session["AdminID"].ToString()); } else if (dropAuthor.SelectedValue == "1") { acsu.ActivitySummary_author = "匿名"; } else { acsu.ActivitySummary_author = "未知"; } acsu.ActivitySummary_time = Convert.ToDateTime(pushlishTime.Value); db.SaveChanges(); Server.Transfer("ActivitySummaryManage.aspx"); //JSHelper.AlertThenRedirect("修改成功!", "ActivitySummaryManage.aspx"); } } catch { } } }