Esempio n. 1
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, "", "保存失败");
                }
            }
        }
Esempio n. 2
0
 public static List<LabMS.Model.Student> DataSettoStudentModule(DataSet ds)
 {
     List<LabMS.Model.Student> modelList = new List<LabMS.Model.Student>();
     int rowsCount = ds.Tables[0].Rows.Count;
     if (rowsCount > 0)
     {
         LabMS.Model.Student model;
         for (int n = 0; n < rowsCount; n++)
         {
             model = new LabMS.Model.Student();
             if (ds.Tables[0].Rows[n]["ID"].ToString() != "")
             {
                 model.ID = int.Parse(ds.Tables[0].Rows[n]["ID"].ToString());
             }
             model.Student_Code = ds.Tables[0].Rows[n]["Student_Code"].ToString();
             model.Student_Name = ds.Tables[0].Rows[n]["Student_Name"].ToString();
             model.Student_Pass = ds.Tables[0].Rows[n]["Student_Pass"].ToString();
             model.Student_Summary = ds.Tables[0].Rows[n]["Student_Summary"].ToString();
             if (ds.Tables[0].Rows[n]["ClassID"].ToString() != "")
             {
                 model.ClassID = int.Parse(ds.Tables[0].Rows[n]["ClassID"].ToString());
             }
             model.Student_Sex = ds.Tables[0].Rows[n]["Student_Sex"].ToString();
             if (ds.Tables[0].Rows[n]["Student_Pro"].ToString() != "")
             {
                 model.Student_Pro = int.Parse(ds.Tables[0].Rows[n]["Student_Pro"].ToString());
             }
             if (ds.Tables[0].Rows[n]["Student_EntryDate"].ToString() != "")
             {
                 model.Student_EntryDate = DateTime.Parse(ds.Tables[0].Rows[n]["Student_EntryDate"].ToString());
             }
             model.Student_Grade = ds.Tables[0].Rows[n]["Student_Grade"].ToString();
             if (ds.Tables[0].Rows[n]["Student_Photo"].ToString() != "")
             {
                 model.Student_Photo = (byte[])ds.Tables[0].Rows[n]["Student_Photo"];
             }
             modelList.Add(model);
         }
     }
     return modelList;
 }
Esempio n. 3
0
 /*
 /// <summary>
 /// ��ҳ��ȡ�����б�
 /// </summary>
 public DataSet GetList(int PageSize,int PageIndex,string strWhere)
 {
     SqlParameter[] parameters = {
             new SqlParameter("@tblName", SqlDbType.VarChar, 255),
             new SqlParameter("@fldName", SqlDbType.VarChar, 255),
             new SqlParameter("@PageSize", SqlDbType.Int),
             new SqlParameter("@PageIndex", SqlDbType.Int),
             new SqlParameter("@IsReCount", SqlDbType.Bit),
             new SqlParameter("@OrderType", SqlDbType.Bit),
             new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
             };
     parameters[0].Value = "Student";
     parameters[1].Value = "ID";
     parameters[2].Value = PageSize;
     parameters[3].Value = PageIndex;
     parameters[4].Value = 0;
     parameters[5].Value = 0;
     parameters[6].Value = strWhere;
     return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
 }*/
 /// <summary>
 /// ��¼��֤
 /// </summary>
 /// <param name="strPeople"></param>
 /// <param name="strPass"></param>
 /// <returns></returns>
 public override object ValidatePeople(string strPeople, string strPass)
 {
     StringBuilder strSql = new StringBuilder();
     strSql.Append("select * from Student");
     strSql.Append(" where Student_Name=@Student_Name and Student_Pass=@Student_Pass ");
     SqlParameter[] parameters = {
             new SqlParameter("@Student_Name", SqlDbType.VarChar,50),
             new SqlParameter("@Student_Pass", SqlDbType.VarChar,50)};
     parameters[0].Value = strPeople;
     parameters[1].Value = strPass;
     DataSet ds = new DataSet();
     try
     {
         ds = DbHelperSQL.Query(strSql.ToString(), parameters);
     }
     catch
     {
         throw (new Exception("���ݿ���ʴ���!"));
     }
     LabMS.Model.Student model = new LabMS.Model.Student();
     try
     {
         if (ds.Tables[0].Rows.Count > 0)
         {
             if (ds.Tables[0].Rows[0]["ID"].ToString() != "")
             {
                 model.ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
             }
             model.Student_Code = ds.Tables[0].Rows[0]["Student_Code"].ToString();
             model.Student_Name = ds.Tables[0].Rows[0]["Student_Name"].ToString();
             model.Student_Pass = ds.Tables[0].Rows[0]["Student_Pass"].ToString();
             model.Student_Summary = ds.Tables[0].Rows[0]["Student_Summary"].ToString();
             if (ds.Tables[0].Rows[0]["ClassID"].ToString() != "")
             {
                 model.ClassID = int.Parse(ds.Tables[0].Rows[0]["ClassID"].ToString());
             }
             model.Student_Sex = ds.Tables[0].Rows[0]["Student_Sex"].ToString();
             if (ds.Tables[0].Rows[0]["Student_Pro"].ToString() != "")
             {
                 model.Student_Pro = int.Parse(ds.Tables[0].Rows[0]["Student_Pro"].ToString());
             }
             if (ds.Tables[0].Rows[0]["Student_EntryDate"].ToString() != "")
             {
                 model.Student_EntryDate = DateTime.Parse(ds.Tables[0].Rows[0]["Student_EntryDate"].ToString());
             }
             model.Student_Grade = ds.Tables[0].Rows[0]["Student_Grade"].ToString();
             if (ds.Tables[0].Rows[0]["Student_Photo"].ToString() != "")
             {
                 model.Student_Photo = (byte[])ds.Tables[0].Rows[0]["Student_Photo"];
             }
             return model;
         }
         else
         {
             return null;
         }
     }
     catch
     {
         throw (new Exception("datasetTOobjectת������!"));
     }
 }
Esempio n. 4
0
        /// <summary>
        /// �õ�һ������ʵ��
        /// </summary>
        public LabMS.Model.Student GetModel(int ID)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 ID,Student_Code,Student_Name,Student_Pass,Student_Summary,ClassID,Student_Sex,Student_Pro,Student_EntryDate,Student_Grade,Student_Photo from Student ");
            strSql.Append(" where ID=@ID ");
            SqlParameter[] parameters = {
                    new SqlParameter("@ID", SqlDbType.Int,4)};
            parameters[0].Value = ID;

            LabMS.Model.Student model=new LabMS.Model.Student();
            DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
            if(ds.Tables[0].Rows.Count>0)
            {
                if(ds.Tables[0].Rows[0]["ID"].ToString()!="")
                {
                    model.ID=int.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                }
                model.Student_Code=ds.Tables[0].Rows[0]["Student_Code"].ToString();
                model.Student_Name=ds.Tables[0].Rows[0]["Student_Name"].ToString();
                model.Student_Pass=ds.Tables[0].Rows[0]["Student_Pass"].ToString();
                model.Student_Summary=ds.Tables[0].Rows[0]["Student_Summary"].ToString();
                if(ds.Tables[0].Rows[0]["ClassID"].ToString()!="")
                {
                    model.ClassID=int.Parse(ds.Tables[0].Rows[0]["ClassID"].ToString());
                }
                model.Student_Sex=ds.Tables[0].Rows[0]["Student_Sex"].ToString();
                if(ds.Tables[0].Rows[0]["Student_Pro"].ToString()!="")
                {
                    model.Student_Pro=int.Parse(ds.Tables[0].Rows[0]["Student_Pro"].ToString());
                }
                if(ds.Tables[0].Rows[0]["Student_EntryDate"].ToString()!="")
                {
                    model.Student_EntryDate=DateTime.Parse(ds.Tables[0].Rows[0]["Student_EntryDate"].ToString());
                }
                model.Student_Grade=ds.Tables[0].Rows[0]["Student_Grade"].ToString();
                if(ds.Tables[0].Rows[0]["Student_Photo"].ToString()!="")
                {
                    model.Student_Photo=(byte[])ds.Tables[0].Rows[0]["Student_Photo"];
                }
                return model;
            }
            else
            {
                return null;
            }
        }
Esempio n. 5
0
        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, "", "新增失败");
                    }

                }
            }
        }
Esempio n. 6
0
        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丢失,请退出系统,重新登录后进行修改密码!");
                }
        }