Exemple #1
0
 //构造函数
 public StudentInfor(StudentExt stu)
 {
     InitializeComponent();
     StuId                  = stu.Sid;
     this.Title             = stu.Sname + "-信息";
     lblAddress.Content     = stu.Saddress;
     lblAge.Content         = stu.Sage;
     lblBirthday.Content    = stu.Birthday.ToString("yyyy-MM-dd");
     lblCardNo.Content      = stu.CardNo;
     lblClassName.Content   = stu.Scname;
     lblGender.Content      = stu.Ssex;
     lblName.Content        = stu.Sname;
     lblPhoneNumber.Content = stu.Sphone;
     lblStuId.Content       = stu.Sid;
     lblStuNoId.Content     = stu.SidNo;
     if (string.IsNullOrEmpty(stu.SImage))
     {
         stuImg.Source = new BitmapImage(new Uri("/img/bg/zwzp.jpg", UriKind.RelativeOrAbsolute));
     }
     else
     {
         //如果学员的Iamge字段中能够查询到数据,那么就可以直接将这个数据反序列化成BitmapImage对象
         common.Bitmapimg image  = SerializeObjectTostring.DeserializeObject(stu.SImage) as common.Bitmapimg;
         BitmapImage      bitmap = new BitmapImage();
         bitmap.BeginInit();
         bitmap.StreamSource = new MemoryStream(image.Buffer);
         bitmap.EndInit();
         stuImg.Source = bitmap;
     }
 }
Exemple #2
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;
        }
Exemple #3
0
 //实现打印及打印预览
 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.SImage))
     {
         selectStu.ImgPath = "/img/bg/zwzp.jpg";
     }
     else
     {
         image = SerializeObjectTostring.DeserializeObject(selectStu.SImage) 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.PrintWindow frmPrint = new PrintWindow("PrintModel.xaml", selectStu);
     frmPrint.ShowInTaskbar = false;
     frmPrint.ShowDialog();
 }