Esempio n. 1
0
 //构造函数
 public FrmStudentInfor(StudentExt stu)
 {
     InitializeComponent();
     StuId                  = stu.StudentId;
     this.Title             = stu.StudentName + "-信息";
     lblAddress.Content     = stu.StudentAddress;
     lblAge.Content         = stu.Age;
     lblBirthday.Content    = stu.Birthday.ToString("yyyy-MM-dd");
     lblCardNo.Content      = stu.CardNo;
     lblClassName.Content   = stu.ClassName;
     lblGender.Content      = stu.Gender;
     lblName.Content        = stu.StudentName;
     lblPhoneNumber.Content = stu.PhoneNumber;
     lblStuId.Content       = stu.StudentId;
     lblStuNoId.Content     = stu.StudentIdNo;
     if (string.IsNullOrEmpty(stu.StuImage))
     {
         stuImg.Source = new BitmapImage(new Uri("/img/bg/zwzp.jpg", UriKind.RelativeOrAbsolute));
     }
     else
     {
         //如果学员的Iamge字段中能够查询到数据,那么就可以直接将这个数据反序列化成BitmapImage对象
         common.BitmapImg image  = SerializeObjectTostring.DeserializeObject(stu.StuImage) as common.BitmapImg;
         BitmapImage      bitmap = new BitmapImage();
         bitmap.BeginInit();
         bitmap.StreamSource = new MemoryStream(image.Buffer);
         bitmap.EndInit();
         stuImg.Source = bitmap;
     }
 }
        public AddstudentManager(StudentExt stu)
        {
            InitializeComponent();
            student1 = stu;

            if (string.IsNullOrEmpty(stu.StuImage))
            {
                stuImg.Source = new BitmapImage(new Uri("/img/bg/zw.jpg", UriKind.RelativeOrAbsolute));
            }
            else
            {
                image      = SerializeObjectTostring.DeserializeObject(stu.StuImage) as common.BitmapImg;
                img.Buffer = image.Buffer;
                BitmapImage bitmap = new BitmapImage();
                bitmap.BeginInit();
                bitmap.StreamSource = new MemoryStream(image.Buffer);
                bitmap.EndInit();
                stuImg.Source = bitmap;
            }
            List <StudentClass> classes = csm.GetClasses();

            cmbClassName.ItemsSource       = classes;
            cmbClassName.DisplayMemberPath = "ClassName";
            cmbClassName.SelectedValuePath = "ClassID";
            //cmbClassName.SelectedIndex = stu.ClassID - 1;
            cmbClassName.SelectedValue = 1;
        }
Esempio n. 3
0
        public UpdateStuInfor(StudentsExt ext)
        {
            InitializeComponent();

            //从上传照片
            common.BitmapImg img = new common.BitmapImg();

            //把获取的元素放在一个属性里方便下面的调用
            studentSJ = ext;

            //开始在这个页面上显示修改按钮所点击的那个学生的所有信息在这里显示,点击是显示原有的
            txtAddress.Text     = ext.StudentAddress; //地址
            txtAge.Text         = ext.Age.ToString(); //年龄
            txtCardNo.Text      = ext.CardNo;         //考勤卡号
            txtName.Text        = ext.StudentName;    //姓名
            txtPhoneNumber.Text = ext.PhoneNumber;    //电话
            txtStuNoId.Text     = ext.StudentIdNo;    //ID
            if (ext.Gender == "男")                    //性别
            {
                radBoy.IsChecked = true;
            }
            else
            {
                radGirl.IsChecked = true;
            }

            /*//获取或设置要选定的日期
             * datePkBirthday.DisplayDate =Convert.ToDateTime(ext.Birthday);
             * //获取或设置当前要选定的日期
             * datePkBirthday.SelectedDate = Convert.ToDateTime(ext.Birthday);*/
            datePkBirthday.Text = ext.Birthday;
            //图片的显示,如果当前图片为空时进入获取这下面zwzp图片
            if (string.IsNullOrEmpty(ext.StuImage))
            {
                stuImg.Source = new BitmapImage(new Uri("/img1/bg/zwzp.jpg", UriKind.RelativeOrAbsolute));
            }
            else
            {
                //如果学员的Iamge字段中能够查询到数据,那么就可以直接将这个数据反序列化成BitmapImage对象
                image       = BinaryStuObjcet.FBinaryForStu(ext.StuImage) as common.BitmapImg;
                img1.Buffer = image.Buffer;
                BitmapImage bitmap = new BitmapImage();
                bitmap.BeginInit();
                bitmap.StreamSource = new MemoryStream(image.Buffer);
                bitmap.EndInit();
                stuImg.Source = bitmap;
            }

            //获取下拉列表的内容
            List <StudentClass> classes = csm.GetClasses();

            cmbClassName.ItemsSource       = classes;
            cmbClassName.DisplayMemberPath = "ClassName";
            cmbClassName.SelectedValuePath = "ClassId";
            cmbClassName.SelectedIndex     = ext.ClassId - 1;
        }
Esempio n. 4
0
        public FrmUpdateStuInfor(StudentExt stu)
        {
            InitializeComponent();
            //信息绑定
            this.Title          = "修改【" + stu.StudentName + "】信息";
            student             = stu;
            txtAddress.Text     = stu.StudentAddress;
            txtAge.Text         = stu.Age.ToString();
            txtCardNo.Text      = stu.CardNo;
            txtName.Text        = stu.StudentName;
            txtPhoneNumber.Text = stu.PhoneNumber;
            txtStuNoId.Text     = stu.StudentIdNo;
            if (stu.Gender == "男")
            {
                radBoy.IsChecked = true;//如果性别为男 则界面男选中
            }
            else
            {
                radGirl.IsChecked = true;
            }
            datePkBirthday.DisplayDate  = stu.Birthday;
            datePkBirthday.SelectedDate = stu.Birthday;
            if (string.IsNullOrEmpty(stu.StuImage))
            {
                //如果数据库为存储照片则展示预定照片
                stuImg.Source = new BitmapImage(new Uri("/img/zwzp.jpg", UriKind.RelativeOrAbsolute));
            }
            else
            {
                //如果查询到Image字段,则进行反序列化进行处理
                image      = SerializeObjectTostring.DeserializeObject(stu.StuImage) as common.BitmapImg;
                img.Buffer = image.Buffer;
                BitmapImage bitmap = new BitmapImage();
                bitmap.BeginInit();
                bitmap.StreamSource = new MemoryStream(image.Buffer);
                bitmap.EndInit();
                stuImg.Source = bitmap;
            }
            List <StudentClass> classes = csm.GetClasses();

            cmbClassName.ItemsSource       = classes;
            cmbClassName.DisplayMemberPath = "ClassName";
            cmbClassName.SelectedValuePath = "ClassId";
            cmbClassName.SelectedIndex     = stu.ClassId;
        }
Esempio n. 5
0
        public FrmUpdateStuInfor(StudentExt stu)
        {
            InitializeComponent();
            this.Title          = "修改【" + stu.StudentName + "】信息";
            student             = stu;
            txtAddress.Text     = stu.StudentAddress;
            txtAge.Content      = stu.Age.ToString();
            txtCardNo.Text      = stu.CardNo;
            txtName.Text        = stu.StudentName;
            txtPhoneNumber.Text = stu.PhoneNumber;
            txtStuNoId.Text     = stu.StudentIdNo;
            if (stu.StudentSex == "男")//性别男
            {
                radBoy.IsChecked = true;
            }
            else//性别女
            {
                radGirl.IsChecked = true;
            }
            datePkBirthday.Content = stu.Birthday.ToString("yyyy-MM-dd");
            if (string.IsNullOrEmpty(stu.StuImage))
            {
                stuImg.Source = new BitmapImage(new Uri("/img/zwzp.jpg", UriKind.RelativeOrAbsolute));
            }
            else
            {
                //如果学员的Iamge字段中能够查询到数据,那么就可以直接将这个数据反序列化成BitmapImage对象
                imge       = SerializeObjectTostring.DeserializeObject(stu.StuImage) as common.BitmapImg;//照片字符串格式
                img.Buffer = imge.Buffer;
                BitmapImage bitmap = new BitmapImage();
                bitmap.BeginInit();                                  //开始
                bitmap.StreamSource = new MemoryStream(imge.Buffer); //获取流
                bitmap.EndInit();                                    //结束
                stuImg.Source = bitmap;                              //获取照片
            }
            List <StudentClass> classes = csm.GetClasses();

            cmbClassName.ItemsSource       = classes;
            cmbClassName.DisplayMemberPath = "ClassName";
            cmbClassName.SelectedValuePath = "ClassId";
            cmbClassName.SelectedIndex     = stu.ClssID;
        }
Esempio n. 6
0
        public XiugaiStudentManage(StudentExt stu)
        {
            InitializeComponent();
            student             = stu;
            txtAddress.Text     = stu.StudentAddress;
            txtAge.Content      = stu.Age.ToString();
            txtCardNo.Text      = stu.CardNo;
            txtName.Text        = stu.StudentName;
            txtPhoneNumber.Text = stu.PhoneNumber;
            txtStuNoId.Text     = stu.StudentidNo;

            if (stu.StudentSex == "男")
            {
                radboy.IsChecked = true;
            }
            else
            {
                radGirl.IsChecked = true;
            }
            datePkBirthday.Content = stu.Birthday.ToString();

            if (string.IsNullOrEmpty(stu.StuImage))
            {
                stuImg.Source = new BitmapImage(new Uri("/img/bg/zw.jpg", UriKind.RelativeOrAbsolute));
            }
            else
            {
                image      = SerializeObjectTostring.DeserializeObject(stu.StuImage) as common.BitmapImg;
                img.Buffer = image.Buffer;
                BitmapImage bitmap = new BitmapImage();
                bitmap.BeginInit();
                bitmap.StreamSource = new MemoryStream(image.Buffer);
                bitmap.EndInit();
                stuImg.Source = bitmap;
            }
            List <StudentClass> classes = csm.GetClasses();

            cmbClassName.ItemsSource       = classes;
            cmbClassName.DisplayMemberPath = "ClassName";
            cmbClassName.SelectedValuePath = "ClassID";
            cmbClassName.SelectedIndex     = 0;
        }
 /// <summary>
 /// 打印考勤
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void dayinkaoqin_Click(object sender, RoutedEventArgs e)
 {
     selectStu = smDgkapqinLsit.SelectedItem as StudentExt;
     if (selectStu == null)
     {
         MessageBox.Show("请选择您要打印的学员", "提示");
         return;
     }
     common.BitmapImg image = null;
     if (string.IsNullOrEmpty(selectStu.StuImage))
     {
         selectStu.ImgPath = "/img/bg/zw.jpg";
     }
     else
     {
         image = SerializeObjectTostring.DeserializeObject(selectStu.StuImage) as common.BitmapImg;
         BitmapImage bitmap = new BitmapImage();
         bitmap.BeginInit();
         bitmap.StreamSource = new MemoryStream(image.Buffer);
         bitmap.EndInit();
         BitmapEncoder encoder = new PngBitmapEncoder();
         encoder.Frames.Add(BitmapFrame.Create(bitmap));
         long sc = DateTime.Now.Ticks;
         using (MemoryStream stream = new MemoryStream())
         {
             encoder.Save(stream);
             byte[] buffer = stream.ToArray();
             File.WriteAllBytes(AppDomain.CurrentDomain.BaseDirectory + "/photos/" + sc + ".png", buffer);
             stream.Close();
         }
         selectStu.ImgPath = AppDomain.CurrentDomain.BaseDirectory + "/photos/" + sc + ".png";
     }
     View.DayinxinxiManger frmPrint = new DayinxinxiManger("DayinModel.xaml", selectStu);
     frmPrint.ShowInTaskbar = false;
     frmPrint.ShowDialog();
 }
 /// <summary>
 /// 实现打印与预览
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void BtnPrint_Click(object sender, RoutedEventArgs e)
 {
     selectStu = smDgStudentLsit.SelectedItem as StudentExt;//获取信息
     if (selectStu == null)
     {
         MessageBox.Show("请选择您要打印的学员!", "提示");
         return;
     }
     common.BitmapImg image = null;                //照片
     if (string.IsNullOrEmpty(selectStu.StuImage)) //判断照片是否为空
     {
         selectStu.ImgPath = "/img/zwzp.jpg";      //默认照片
     }
     else
     {
         image = SerializeObjectTostring.DeserializeObject(selectStu.StuImage) as common.BitmapImg; //反序列化
         BitmapImage bitmap = new BitmapImage();
         bitmap.BeginInit();                                                                        //开始初始化
         bitmap.StreamSource = new MemoryStream(image.Buffer);
         bitmap.EndInit();                                                                          //结束
         BitmapEncoder encoder = new PngBitmapEncoder();                                            //图片格式
         encoder.Frames.Add(BitmapFrame.Create(bitmap));
         long sc = DateTime.Now.Ticks;                                                              //时间
         using (MemoryStream stream = new MemoryStream())
         {
             encoder.Save(stream); //以流的形式进行存储图片
             byte[] buffer = stream.ToArray();
             File.WriteAllBytes(AppDomain.CurrentDomain.BaseDirectory + "/printImg/" + sc + ".png", buffer);
             stream.Close();
         }
         selectStu.ImgPath = AppDomain.CurrentDomain.BaseDirectory + "/printImg/" + sc + ".png";//添加照片
     }
     View.FrmPrintWindow frmPrint = new FrmPrintWindow("PrintModel.xaml", selectStu);
     frmPrint.ShowInTaskbar = false;
     frmPrint.ShowDialog();
 }
Esempio n. 9
0
        //打印学员信息( 实现打印及打印预览)
        private void BtnPrint_Click(object sender, RoutedEventArgs e)
        {
            //点击选中的学员,按下打印学员信息的buttom按钮,这样就获取具体学员的信息了(用一个实体类接收一下在smDgStudentLsit里面数据,当点击时把所有的值用selectStu接收一下)
            selectStu = smDgStudentLsit.SelectedItem as StudentsExt;//(现在selectStu里面就装了点击时所包含的值)
            //当StudentsExt的值等于等于空值时,表示
            if (selectStu == null)
            {
                MessageBox.Show("请选择您要打印的学员", "提示");
                return;
            }
            //实例化放图片的空数据
            common.BitmapImg image = null;
            if (string.IsNullOrEmpty(selectStu.StuImage))
            {
                //最后在StudentsExt多添加了一个属性
                selectStu.ImgPath = "/img1/bg/zwzp.jpg";
            }
            //如果有图片执行下面获取的图片
            else
            {
                //(获取数据库中图片的反序列化)用空的图片类来接收数据库中的这个图片(当点击要打印学生信息就可以获取selectStu.StuImage的数据)
                image = BinaryStuObjcet.FBinaryForStu(selectStu.StuImage) as common.BitmapImg;
                //实例化BitmapImage用来封装序列化和反序列化的转换路径的*记录方式*
                BitmapImage bitmap = new BitmapImage();
                bitmap.BeginInit();//用信号通知BitmapImage初始化开始
                //图像流:  对象的集合编码为图像流(new无法自己出来,所以自己输入)
                BitmapEncoder encoder = new PngBitmapEncoder();

                /*1.向图像流中添加
                 * 2.BitmapFrame图像数据属于静态类
                 * 3.创建这个BitmapImage路径并添加给图像流
                 * 4.就相当于给这个图像流输入照片路径
                 * 总结:encoder.Frames.Add相当于给图像流中添加图片的路径
                 */
                encoder.Frames.Add(BitmapFrame.Create(bitmap));//把图片从数据库拿到的图片路径拿到,并创建

                //获取事件
                long sc = DateTime.Now.Ticks;
                //using表示方式这个流被其他替代,在using里绝对不会被替代相当一个封闭环境
                using (MemoryStream stream = new MemoryStream())
                {
                    //**encoder里面获取到的内容给了stream流**:将位图图像编码为指定的流;把
                    encoder.Save(stream);
                    //用一个byte数组来装这个流
                    byte[] buffer = stream.ToArray();

                    /*1.file是一个静态类可以直接使用里面的方法
                     * 2.使用WriteAllBytes这个方法创建一个新文件在其中写入指定的字节数组,然后关闭改文件。如果目标问价以存在,则覆盖改文件
                     * 3.AppDomain应用程序中独立执行的环境
                     * 4.CurrentDomain获取当前程序域
                     * 5.BaseDirectory获取基目录
                     * 6.sc表示当前时间
                     * 7.printImg文件名、
                     * 8.buffer表示记录stream流中的所有内容
                     * 总结创建了一个图片文件
                     */
                    File.WriteAllBytes(AppDomain.CurrentDomain.BaseDirectory + "/printImg/" + sc + ".png", buffer); //???
                    stream.Close();                                                                                 //关闭流
                }
                //获取学生图片的路径
                selectStu.ImgPath = AppDomain.CurrentDomain.BaseDirectory + "/printImg/" + sc + ".png";
            }

            /*1.创建打印学生信息界面
             * 2.参数1(PrintModel.xaml:框架形式是流文档所以创建流文档写打印界面):表示对打印界面的设计
             * 3.参数2(selectStu):表示获取学生的所有数据
             */
            View.PrintWindow frmPrint = new PrintWindow("PrintModel.xaml", selectStu);
            //获取或设置一个值,该值指示窗口是否具有任务栏按钮
            frmPrint.ShowInTaskbar = false;
            //打开打印学生窗口窗口
            frmPrint.ShowDialog();
        }
Esempio n. 10
0
        /// <summary>
        /// 这个也是构造函数所以里面可以传参数
        /// </summary>
        // 下面的函数有了StudentsExt参数类型,这样我们只需要把在FrmStuManager这个窗口的数据以参数的形式传递进来;这个函数就可以访问到数据了
        public WindowDoubleStu(StudentsExt ext)
        {
            InitializeComponent();
            //把参数类型StudentsExt的学生ID赋给Stuext
            Stuext = ext.StudentId;

            //在主窗口放一个lable名字Id测试
            //Id.Content = ext.StudentName;
            this.Title = ext.StudentName + "-信息";
            //地址
            lblAddress.Content = ext.StudentAddress;
            //年龄
            lblAge.Content = ext.Age;
            //出生日期
            lblBirthday.Content = ext.Birthday.ToString();
            //考勤卡号
            lblCardNo.Content = ext.CardNo;
            //课程名字
            lblClassName.Content = ext.ClassName;
            //性别
            lblGender.Content = ext.Gender;
            //学生名字
            lblName.Content = ext.StudentName;
            //学生电话
            lblPhoneNumber.Content = ext.PhoneNumber;
            //学生ID
            lblStuId.Content = ext.StudentId;
            //学生身份证号
            lblStuNoId.Content = ext.StudentIdNo;



            //学生图片
            //if这个图片为空时进入绑定这个图片
            if (string.IsNullOrEmpty(ext.StuImage))
            {
                //在创建的时候直接用image图片装
                stuImg.Source = new BitmapImage(new Uri("/img1/bg/zwzp.jpg", UriKind.RelativeOrAbsolute));
            }
            else
            {
                //1.第一步给通用层Common中添加序列化和反序列化
                //2.先反序列化

                //1.现在通用层里面添加一个类,用里面的属性来实现序列化的转变
                //2.反序列化在数据库中获取
                //(1)如果学员的Iamge字段中能够查询到数据,那么就可以直接将这个数据反序列化成BitmapImage对象
                //(2)反序列化就可以从数据库中那图片了
                //如果学员的Iamge字段中能够查询到数据,那么就可以直接将这个数据反序列化成BitmapImage对象
                //(3)要求封装好的
                /*BitmapImage image = Common.BinaryStuObjcet.FBinaryForStu(ext.StuImage) as BitmapImage;*/
                //2.获取到ext.StuImage的名字
                common.BitmapImg image = BinaryStuObjcet.FBinaryForStu(ext.StuImage) as common.BitmapImg;
                //3.实例化一下这个装图片盒子
                BitmapImage bitmap = new BitmapImage();
                bitmap.BeginInit();
                //获取反序列化的内容
                bitmap.StreamSource = new MemoryStream(image.Buffer);
                bitmap.EndInit();
                //图片名字的路径上赋一个bitmap
                stuImg.Source = bitmap;

                /* image.Buffer = image.Buffer;
                 * BitmapImage bitmap = new BitmapImage();
                 * bitmap.BeginInit();
                 * bitmap.StreamSource = new MemoryStream(image.Buffer);
                 * bitmap.EndInit();
                 * stuImg.Source = bitmap;*/

                /* //如果学员的Iamge字段中能够查询到数据,那么就可以直接将这个数据反序列化成BitmapImage对象
                 * common.BitmapImg image = SerializeObjectTostring.DeserializeObject(stu.StuImage) as common.BitmapImg;
                 * BitmapImage bitmap = new BitmapImage();
                 * bitmap.BeginInit();
                 * bitmap.StreamSource = new MemoryStream(image.Buffer);
                 * bitmap.EndInit();
                 * stuImg.Source = bitmap;*/
            }
        }