예제 #1
0
 //打印信息
 private void btnPrint_Click(object sender, RoutedEventArgs e)
 {
     selectStu = smDgStudentLsit.SelectedItem as StudentExt;
     if (selectStu == null)
     {
         MessageBox.Show("请选择你要打印的学员", "提示");
     }
     common.BItmapImg image = null;
     if (string.IsNullOrEmpty(selectStu.StuIMage))
     {
         selectStu.ImgPath = "/img/bg/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";
     }
     Vime.FrmPrintStuInfo frmPrint = new FrmPrintStuInfo("PrintModel.xaml", selectStu);
     frmPrint.ShowInTaskbar = false;
     frmPrint.ShowDialog();
 }
예제 #2
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;
     }
 }
예제 #3
0
 public FrmStudentInfor(StudentExt stu)
 {
     InitializeComponent();
     StuID                  = stu.StudentID; //获取到当前的学员ID
     this.Title             = stu.StudentName + "信息";
     labName.Content        = stu.StudentName;
     labGender.Content      = stu.Gender;
     labStuID.Content       = stu.StudentID;
     labAge.Content         = stu.Age;
     labstuBirthday.Content = stu.Birthday.ToString("yyyy-mm-dd");
     labGardNo.Content      = stu.CardNO;
     labstuNub.Content      = stu.StudentIdNO;
     labstuClass.Content    = stu.ClassName;
     labstuPhon.Content     = stu.PhoneNumber;
     labstuAddress.Content  = stu.StudentAddress;
     //添加照片信息
     if (string.IsNullOrEmpty(stu.StuIMage))
     {
         stuImg.Source = new BitmapImage(new Uri("/img/bg/zwzp.jpg", UriKind.RelativeOrAbsolute));
     }
     else
     {
         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;
        }
예제 #5
0
        StudentExt student     = new StudentExt();                                          //添加的学员对象
        public FrmAddStudentInfor()
        {
            InitializeComponent();
            //班级
            List <StudentClass> stuclaslist = stuclass.GetClasses();//获取班级表数据

            combstuClass.ItemsSource       = stuclaslist;
            combstuClass.DisplayMemberPath = "ClassName"; //获取班级名
            combstuClass.SelectedValuePath = "ClassID";   //通过班级获取路径
            combstuClass.SelectedIndex     = 0;
            //照片
            if (string.IsNullOrEmpty(student.StuIMage))
            {
                stuImg.Source = new BitmapImage(new Uri("/img/bg/zwzp.jpg", UriKind.RelativeOrAbsolute));
            }
            else
            {
                image      = SerializeObjectTostring.DeserializeObject(student.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;
            }
        }
예제 #6
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;
        }
예제 #7
0
        public AddStudent()
        {
            InitializeComponent();
            StudentExt stu = new StudentExt();

            student             = stu;
            txtAddress.Text     = stu.Saddress;
            txtAge.Content      = stu.Sage.ToString();
            txtCardNo.Text      = stu.CardNo;
            txtName.Text        = stu.Sname;
            txtPhoneNumber.Text = stu.Sphone;
            txtStuNoId.Text     = stu.SidNo;
            if (stu.Ssex == "男")
            {
                radBoy.IsChecked = true;
            }
            else
            {
                radGirl.IsChecked = true;
            }
            datePkBirthday.Content = stu.Birthday.ToString("yyyy-MM-dd");
            if (string.IsNullOrEmpty(stu.SImage))
            {
                stuImg.Source = new BitmapImage(new Uri("/img/bg/zwzp.jpg", UriKind.RelativeOrAbsolute));
            }
            else
            {
                //如果学员的Iamge字段中能够查询到数据,那么就可以直接将这个数据反序列化成BitmapImage对象
                image      = SerializeObjectTostring.DeserializeObject(stu.SImage) 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.GetStudentClasses();

            cmbClassName.ItemsSource       = classes;
            cmbClassName.DisplayMemberPath = "Scname";
            cmbClassName.SelectedValuePath = "Scid";
            cmbClassName.SelectedIndex     = stu.Sclassid - 1;
        }
예제 #8
0
        }                                       //学员对象
        public FrmUpdateStudentInfor(StudentExt stu)
        {
            InitializeComponent();
            this.Title    = "修改【" + stu.StudentName + "】信息";
            student       = stu;
            textName.Text = stu.StudentName; //姓名
            if (stu.Gender == "男")
            {
                radBoy.IsChecked = true;
            } //性别
            else
            {
                radGirl.IsChecked = true;
            }
            dateBirthday.Content = stu.Birthday.ToString("yyyy-MM-dd"); //生日
            textAge.Content      = stu.Age.ToString();                  //年龄
            textGardNo.Text      = stu.CardNO;                          //打卡号
            textstuNub.Text      = stu.StudentIdNO;                     //身份证号
            textstuPhon.Text     = stu.PhoneNumber;                     //手机号
            textstuAddress.Text  = stu.StudentAddress;                  //地址
            //班级
            List <StudentClass> stuclaslist = stuclass.GetClasses();

            combstuClass.ItemsSource       = stuclaslist;
            combstuClass.DisplayMemberPath = "ClassName";
            combstuClass.SelectedValuePath = "ClassID";
            combstuClass.SelectedIndex     = stu.ClassID - 101;
            //照片
            if (string.IsNullOrEmpty(stu.StuIMage))
            {
                stuImg.Source = new BitmapImage(new Uri("/img/bg/zwzp.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;
            }
        }
예제 #9
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;
        }
예제 #10
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 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();
 }