protected void InitBind(int ID) { LabMS.BLL.Student BStudent = new LabMS.BLL.Student(); List<LabMS.Model.Student> list = new List<LabMS.Model.Student>(); list = BStudent.GetModelList("ID="+ID); textboxCode.Text = list[0].Student_Code; textboxName.Text = list[0].Student_Name; ddlSex.SelectedValue = list[0].Student_Sex;//性别 ddlLJ.SelectedValue = list[0].Student_Grade;//年级 ExtendBLL.Class EClass = new ExtendBLL.Class(); if (list[0].Student_Pro!= null&&!string.IsNullOrEmpty(list[0].Student_Pro.Value.ToString())) { textboxMajor.Text = EClass.ProessionalNameByID(int.Parse(list[0].Student_Pro.Value.ToString()));//专业 } if (list[0].ClassID!=null&&!string.IsNullOrEmpty(list[0].ClassID.Value.ToString())) { textboxClass.Text = EClass.GetClassNameByClassID(int.Parse(list[0].ClassID.Value.ToString()));//班级 } if (list[0].Student_EntryDate != null) { tbRXLY.Text = list[0].Student_EntryDate.Value.ToShortDateString(); } tbSum.Text = list[0].Student_Summary; //if (!string.IsNullOrEmpty(list[0].Student_Photo.ToString())) //{ // imgStudent.ImageUrl = list[0].Student_Photo.ToString(); //} }
public void bind(string strWhere) { List<LabMS.Model.Student> liststudentsmodule = new List<LabMS.Model.Student>(); LabMS.BLL.Student bstudent = new LabMS.BLL.Student(); liststudentsmodule = bstudent.GetModelList(strWhere + " order by ID desc "); gvStudents.DataSource = liststudentsmodule; gvStudents.DataBind(); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string psw = context.Request.Params["Password"].ToString(); string usercode = context.Request.Params["UserCode"].ToString(); string usertype = context.Request.Params["UserType"].ToString(); string returnvalue=""; if (usertype == "mana") { LabMS.BLL.UserTable userTable = new LabMS.BLL.UserTable(); List<LabMS.Model.UserTable> userTableModelList = new List<LabMS.Model.UserTable>(); userTableModelList = userTable.GetModelList("Password='******' and PCode='" + usercode + "'"); if (userTableModelList.Count == 1) { returnvalue = "\"" + psw + "\",true"; } else { returnvalue = "\"" + psw + "\",false"; } } else if (usertype == "student") { LabMS.BLL.Student userTable = new LabMS.BLL.Student(); List<LabMS.Model.Student> userTableModelList = new List<LabMS.Model.Student>(); userTableModelList = userTable.GetModelList("Student_Pass='******' and Student_Code='" + usercode + "'"); if (userTableModelList.Count == 1) { returnvalue = "\"" + psw + "\",true"; } else { returnvalue = "\"" + psw + "\",false"; } } if (usertype == "teacher") { LabMS.BLL.Teacher userTable = new LabMS.BLL.Teacher(); List<LabMS.Model.Teacher> userTableModelList = new List<LabMS.Model.Teacher>(); userTableModelList = userTable.GetModelList("Password='******' and Teacher_Code='" + usercode + "'"); if (userTableModelList.Count == 1) { returnvalue = "\"" + psw + "\",true"; } else { returnvalue = "\"" + psw + "\",false"; } } context.Response.Write(returnvalue); }
/// <summary> /// 判断此学生号是否存在 /// </summary> /// <param name="Student_Code"></param> /// <returns></returns> public int IsStudentCodeExits(string Student_Code) { string str = "Student_Code='"+Student_Code+"'"; LabMS.BLL.Student BS = new LabMS.BLL.Student(); if (BS.GetModelList(str).Count > 0) { return -1;//已经存在,不能注册 } else { return 0;//不存在,可以注册 } }
protected void btnEdit_Click(object sender, EventArgs e) { #region 验证 if (string.IsNullOrEmpty(textboxCode.Text.Trim())) { Common.JShelper.JSAlert(this.Page, "", "学号不能为空!"); textboxCode.Focus(); } else if (string.IsNullOrEmpty(textboxName.Text.Trim())) { Common.JShelper.JSAlert(this.Page, "", "姓名不能为空!"); textboxName.Focus(); } #endregion else { LabMS.Model.Student MStudent = new LabMS.Model.Student(); MStudent.ID = int.Parse(Request.QueryString["ID"].ToString()); MStudent.Student_Code = textboxCode.Text.Trim(); MStudent.Student_Name = textboxName.Text.Trim(); MStudent.Student_Sex = ddlSex.SelectedValue; MStudent.Student_Summary = tbSum.Text.Trim(); if (!string.IsNullOrEmpty(tbC.Text.Trim())) { MStudent.ClassID = int.Parse(tbC.Text.Trim()); //存ID } if (!string.IsNullOrEmpty(tbM.Text.Trim())) { MStudent.Student_Pro = int.Parse(tbM.Text.Trim());//存ID } if (!string.IsNullOrEmpty(tbRXLY.Text.Trim())) { string[] DateTimeList = { "yyyy/MM/dd", "yyyy/MM", "yyyy/M", "yyyy-MM-dd", "yyyy-M-d", "yyyyMM", "yyyyMMdd", "yyyy-MM" }; MStudent.Student_EntryDate = DateTime.ParseExact(tbRXLY.Text.Trim(), DateTimeList, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.AllowInnerWhite); } MStudent.Student_Grade = ddlLJ.SelectedValue; LabMS.BLL.Student BStudent = new LabMS.BLL.Student(); try { BStudent.Update(MStudent); Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script type='text/javascript'>alert('保存成功');window.opener.location.replace(window.opener.location);self.close();</script>"); } catch { Common.JShelper.JSAlert(this.Page, "", "保存失败"); } } }
protected void Page_Load(object sender, EventArgs e) { strPagePrivilege.Add("BJKB"); strPageUserType.Add("student"); if (!Page.IsPostBack) { if (!string.IsNullOrEmpty(UserID) && !string.IsNullOrEmpty(UserName)) { YearBind(); lb_Year.Text = ddl_Year.SelectedValue; if (ddl_Term.SelectedValue == "1") { lb_Term.Text = "��ѧ��"; } else { lb_Term.Text = "��ѧ��"; } int TempID = 0; if (int.TryParse(UserID,out TempID)) { if (TempID > 0) { LabMS.BLL.Student Student = new LabMS.BLL.Student(); LabMS.Model.Student model = Student.GetModel(TempID); if (model != null) { if (model.ClassID.HasValue) { LabMS.BLL.Class Class = new LabMS.BLL.Class(); LabMS.Model.Class classmodel = Class.GetModel(model.ClassID.Value); if (classmodel != null) { lb_ClassName.Text = classmodel.Class_Name; } } } } } DataBinds(); } else { LabMS.Common.JShelper.JSAlert(this, "error", "ϵͳ��������ϵ����Ա"); } } }
protected string CombineStr(int row, int column) { string strWhere = "1=1"; if (!string.IsNullOrEmpty(ddl_Year.SelectedValue)) { strWhere += " and Year='" + ddl_Year.SelectedValue + "'"; } if (!string.IsNullOrEmpty(ddl_Term.SelectedValue)) { strWhere += " and ScoreTerm ='" + ddl_Term.SelectedValue + "'"; } bool correct = false; int TempID=0; if(int.TryParse(UserID,out TempID)) { if (TempID > 0) { LabMS.BLL.Student Student = new LabMS.BLL.Student(); LabMS.Model.Student stundentmodel = Student.GetModel(TempID); if (stundentmodel != null) { if (stundentmodel.ClassID.HasValue) { strWhere += " and ClassID=" + stundentmodel.ClassID.Value; correct = true; } } } } if (!correct) { lb_Error.Text = "���ݴ�������ϵ����Ա"; } strWhere += " and "; strWhere += " WeekDay =" + row; strWhere += " and "; strWhere += " lession =" + column; int Start = 0; int End = 0; if (!string.IsNullOrEmpty(tb_StartWeek.Text)) { if (int.TryParse(tb_StartWeek.Text, out Start)) { strWhere += " and Week>=" + Start; } } if (!string.IsNullOrEmpty(tb_EndWeek.Text)) { if (int.TryParse(tb_EndWeek.Text, out End)) { strWhere += " and Week <=" + End; } } return strWhere; }
/// <summary> /// ���ݷ����������ҵ���ʵ�������������� /// </summary> /// <param name="posterID">�����߱�ʶ</param> /// <param name="PosterType">���������(0Ϊ����Ա,1Ϊ��ʦ,2Ϊѧ��)</param> /// <returns></returns> public string GetAuthorName(int posterID, string posterType) { string name = String.Empty; switch (posterType) { case "0": // ����Ա LabMS.BLL.UserTable ut = new LabMS.BLL.UserTable(); LabMS.Model.UserTable utInfo = ut.GetModel(posterID); if (utInfo != null) name = utInfo.UserName; break; case "1": //��ʦ LabMS.BLL.Teacher bTeacher = new LabMS.BLL.Teacher(); LabMS.Model.Teacher teacher = bTeacher.GetModel(posterID); if (teacher != null) name = teacher.Teacher_Name; break; case "2"://ѧ�� LabMS.BLL.Student bStudent = new LabMS.BLL.Student(); LabMS.Model.Student student = bStudent.GetModel(posterID); if (student != null) name = student.Student_Name; break; } return name; }
protected void btnSave_Click(object sender, EventArgs e) { #region 验证 if (string.IsNullOrEmpty(tbCode.Text.Trim())) { Common.JShelper.JSAlert(this.Page, "", "学号不能为空!"); tbCode.Focus(); } else if (string.IsNullOrEmpty(tbName.Text.Trim())) { Common.JShelper.JSAlert(this.Page, "", "姓名不能为空!"); tbName.Focus(); } #endregion else { LabMS.Model.Student MStudent = new LabMS.Model.Student(); ExtendBLL.Student EStudent = new ExtendBLL.Student(); if (EStudent.IsStudentCodeExits(tbCode.Text.Trim()) == -1) { Common.JShelper.JSAlert(this.Page, "", "该学号已经存在!"); tbCode.Text = ""; tbCode.Focus(); } else { MStudent.Student_Code = tbCode.Text.Trim(); MStudent.Student_Name = tbName.Text.Trim(); MStudent.Student_Sex = ddlSex.SelectedValue; MStudent.Student_Summary = tbBZ.Text.Trim(); if (!string.IsNullOrEmpty(tbC.Text.Trim())) { MStudent.ClassID = int.Parse(tbC.Text.Trim()); //存ID } if (!string.IsNullOrEmpty(tbM.Text.Trim())) { MStudent.Student_Pro = int.Parse(tbM.Text.Trim());//存ID } if (!string.IsNullOrEmpty(tbRxly.Text.Trim())) { string[] DateTimeList = { "yyyy/MM/dd", "yyyy/MM", "yyyy/M", "yyyy-MM-dd", "yyyy-M-d", "yyyyMM", "yyyyMMdd", "yyyy-MM" }; MStudent.Student_EntryDate = DateTime.ParseExact(tbRxly.Text.Trim(), DateTimeList, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.AllowInnerWhite); //MStudent.Student_EntryDate = DateTime.ParseExact(tbRxly.Text.Trim(), "yyyyMM", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.AllowInnerWhite); } MStudent.Student_Grade = ddlLJ.SelectedValue; //#region 上传文件 //if (FileUpload1.HasFile)//如果有文件 //{ // string FileName = FileUpload1.PostedFile.FileName;//文件名 // int Length = FileUpload1.PostedFile.ContentLength;//文件大小 // if (Length > 1024 * 1024) // { // Common.JShelper.JSAlert(this.Page, "", "图片文件不能大于1M!"); // } // else // { // string Ext = FileName.Substring(FileName.LastIndexOf(@"."));//取出后缀 // if (Ext != ".jpg" && Ext != ".bmp" && Ext != ".gif") // { // Common.JShelper.JSAlert(this.Page, "", "图片格式不正确!"); // return; // } // else // { // //判断存放文件的路径是否存在 // string Path = Server.MapPath("UploadFile") + "\\"; // System.IO.DirectoryInfo dirInfo = new System.IO.DirectoryInfo(Path); // if (!dirInfo.Exists) // { // dirInfo.Create(); // } // else // { // string fullfilename = Guid.NewGuid() + Ext; // try // { // FileUpload1.PostedFile.SaveAs(fullfilename);//保存文件 // //保存到数据库中 // byte[] PhotoArray = new byte[Length]; // System.IO.Stream photoStream = FileUpload1.PostedFile.InputStream; // photoStream.Read(PhotoArray, 0, Length); // MStudent.Student_Photo = PhotoArray;//相片 // } // catch // { // Common.JShelper.JSAlert(this.Page, "", "图片上传失败"); // } // } // } // } //} //#endregion LabMS.BLL.Student BStudent = new LabMS.BLL.Student(); int count = BStudent.Add(MStudent); if (count > 0) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script type='text/javascript'>alert('新增成功!');window.opener.location.href=window.opener.location.href;self.close();</script>"); } else { Common.JShelper.JSAlert(this.Page, "", "新增失败"); } } } }
protected void Save_OnClick(object sender, EventArgs e) { #region if (String.IsNullOrEmpty(UserPasswordTBX.Text.Trim())) { Common.JShelper.JSAlert(Page, "script", "请输入旧密码!"); return; } if (UserPasswordTBX.Text.Length > 50) { Common.JShelper.JSAlert(Page, "script", "旧密码长度输入过长!"); return; } if (String.IsNullOrEmpty(NewPasswordTBX.Text.Trim())) { Common.JShelper.JSAlert(Page, "script", "请输入新密码密码!"); return; } if (NewPasswordTBX.Text.Length > 50) { Common.JShelper.JSAlert(Page, "script", "新密码长度输入过长!"); return; } if (!Regex.IsMatch(NewPasswordTBX.Text.Trim(), @"^\w+$")) { Common.JShelper.JSAlert(Page, "script", "新密码输入不合法(只能为数字、英文或下划线的组合)!"); return; } //if (String.IsNullOrEmpty(RePasswordTBX.Text.Trim())) //{ // Common.JShelper.JSAlert(Page, "script", "请重复输入新密码!"); //} //if (RePasswordTBX.Text.Length > 50) //{ // Common.JShelper.JSAlert(Page, "script", "重复新密码长度输入过长!"); //} //if (!Regex.IsMatch(RePasswordTBX.Text.Trim(), @"^\w+$")) //{ // Common.JShelper.JSAlert(Page, "script", "重复新密码输入不合法(只能为数字、英文或下划线的组合)!"); //} if (String.Compare(RePasswordTBX.Text, NewPasswordTBX.Text) != 0) { Common.JShelper.JSAlert(Page, "script", "两次新密码输入不一致!"); return; } //验证用户名和密码输入是否正确 if (!IsUserNameAndPassword()) { Common.JShelper.JSAlert(Page, "script", "用户名和密码输入不匹配!"); return; } #endregion if (!String.IsNullOrEmpty(UserID)) { int ID; if (int.TryParse(UserID, out ID)) { if (UserType == "mana") { LabMS.BLL.UserTable userTable = new LabMS.BLL.UserTable(); LabMS.Model.UserTable userTableModel = new LabMS.Model.UserTable(); userTableModel = userTable.GetModel(ID); userTableModel.Password = NewPasswordTBX.Text.Trim(); try { userTable.Update(userTableModel); Common.JShelper.JsAlertAndClose(Page, "script", "密码修改成功!"); } catch { Common.JShelper.JsAlertAndClose(Page, "script", "密码修改失败!"); } } else if (UserType == "teacher") { LabMS.BLL.Teacher userTable = new LabMS.BLL.Teacher(); LabMS.Model.Teacher userTableModel = new LabMS.Model.Teacher(); userTableModel = userTable.GetModel(ID); userTableModel.Password = NewPasswordTBX.Text.Trim(); try { userTable.Update(userTableModel); Common.JShelper.JsAlertAndClose(Page, "script", "密码修改成功!"); } catch { Common.JShelper.JsAlertAndClose(Page, "script", "密码修改失败!"); } } else { LabMS.BLL.Student userTable = new LabMS.BLL.Student(); LabMS.Model.Student userTableModel = new LabMS.Model.Student(); userTableModel = userTable.GetModel(ID); userTableModel.Student_Pass = NewPasswordTBX.Text.Trim(); try { userTable.Update(userTableModel); Common.JShelper.JsAlertAndClose(Page, "script", "密码修改成功!"); } catch { Common.JShelper.JsAlertAndClose(Page, "script", "密码修改失败!"); } } } else { Common.JShelper.JsAlertAndClose(Page, "script", "用户ID存储不合法,请退出系统,重新登录后进行修改密码!"); } } else { Common.JShelper.JsAlertAndClose(Page, "script", "用户Session丢失,请退出系统,重新登录后进行修改密码!"); } }
private bool IsUserNameAndPassword() { if (UserType == "mana") { LabMS.BLL.UserTable userTable = new LabMS.BLL.UserTable(); List<LabMS.Model.UserTable> userTableModelList = new List<LabMS.Model.UserTable>(); userTableModelList = userTable.GetModelList("Password='******' and PCode='" + UserCodeTBX.Text + "'"); if (userTableModelList.Count == 1) { return true; } else { return false; } } else if (UserType == "teacher") { LabMS.BLL.Teacher userTable = new LabMS.BLL.Teacher(); List<LabMS.Model.Teacher> userTableModelList = new List<LabMS.Model.Teacher>(); userTableModelList = userTable.GetModelList("Password='******' and Teacher_Code='" + UserCodeTBX.Text + "'"); if (userTableModelList.Count == 1) { return true; } else { return false; } } else { LabMS.BLL.Student userTable = new LabMS.BLL.Student(); List<LabMS.Model.Student> userTableModelList = new List<LabMS.Model.Student>(); userTableModelList = userTable.GetModelList("Student_Pass='******' and Student_Code='" + UserCodeTBX.Text + "'"); if (userTableModelList.Count == 1) { return true; } else { return false; } } }