Beispiel #1
0
        /// <summary>
        /// Hàm thực hiện thêm mới học phí
        /// </summary>
        /// <param name="parameter"></param>
        private void OnAddHocPhi(object parameter)
        {
            var values = (object[])parameter;
            var window = (Window)values[0];
            var stack  = (StackPanel)values[1];

            try
            {
                HocPhiDaoImpl impl   = new HocPhiDaoImpl();
                HocPhi        hocphi = new HocPhi();
                foreach (var child in stack.Children)
                {
                    string name = null;
                    if (child is FrameworkElement)
                    {
                        name = (child as FrameworkElement).Name.ToString();

                        switch (name)
                        {
                        case "txtTenHocPhi":
                            hocphi.TenhocPhi = (child as TextBox).Text;
                            break;

                        case "txtChiPhi":
                            hocphi.ChiPhi = (int)(child as NumericUpDown).Value.GetValueOrDefault();;
                            break;

                        case "txtGhiChu":
                            hocphi.GhiChu = (child as TextBox).Text;
                            break;

                        case "cbxLoaiHocPhi":
                            hocphi.LoaiHocPhi = (child as ComboBox).SelectedValue.ToString();
                            break;
                        }
                    }
                }
                impl.AddHocPhi(hocphi);
                window.DataContext = new MetadataHocPhiViewModel();
                MessageBox.Show("Susscess!");
            }
            catch
            {
                MessageBox.Show("Fail!");
            }
        }
Beispiel #2
0
 private void OnDeleteHocPhi(object parameter)
 {
     try
     {
         var           values     = (object[])parameter;
         var           window     = (Window)values[0];
         var           listhocphi = (ListBox)values[1];
         HocPhi        hocphi     = listhocphi.SelectedItem as HocPhi;
         HocPhiDaoImpl impl       = new HocPhiDaoImpl();
         impl.DeleteHocPhi(hocphi.MaHocPhi);
         window.DataContext = new MetadataHocPhiViewModel();
         MessageBox.Show("Susscess!");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Beispiel #3
0
        /// <summary>
        /// Hàm lấy dánh sách học phí
        /// </summary>
        public void GetListHocPhi()
        {
            HocPhiDaoImpl impl = new HocPhiDaoImpl();

            //get học phí đầu năm
            if (ListHocPhiDauNam == null)
            {
                ListHocPhiDauNam = new ObservableCollection <HocPhi>();
            }
            else
            {
                ListHocPhiDauNam.Clear();
            }
            impl.GetListHocPhi().FindAll(p => p.LoaiHocPhi == "LoaiHocPhi-20D1").ToList().ForEach(p => ListHocPhiDauNam.Add(p));

            //get hoc phi thang
            if (ListHocPhiTheoThang == null)
            {
                ListHocPhiTheoThang = new ObservableCollection <HocPhi>();
            }
            else
            {
                ListHocPhiTheoThang.Clear();
            }
            impl.GetListHocPhi().FindAll(p => p.LoaiHocPhi == "LoaiHocPhi-2FAA").ToList().ForEach(p => ListHocPhiTheoThang.Add(p));

            // get hojc phis dich vu
            if (ListHocPhiDichVu == null)
            {
                ListHocPhiDichVu = new ObservableCollection <HocPhi>();
            }
            else
            {
                ListHocPhiDichVu.Clear();
            }
            impl.GetListHocPhi().FindAll(p => p.LoaiHocPhi == "LoaiHocPhi-472E").ToList().ForEach(p => ListHocPhiDichVu.Add(p));
        }
Beispiel #4
0
 /// <summary>
 /// Hàm lưu học phí
 /// </summary>
 /// <param name="parameter"></param>
 private void OnSaveHocPhi(UIElementCollection parameter)
 {
     try
     {
         foreach (var child in parameter)
         {
             if (child is ListBox)
             {
                 foreach (var obj in (child as ListBox).Items.SourceCollection)
                 {
                     HocPhiDaoImpl impl   = new HocPhiDaoImpl();
                     HocPhi        hocphi = new HocPhi();
                     hocphi = obj as HocPhi;
                     impl.EditHocPhi(hocphi);
                 }
             }
         }
         MessageBox.Show("Save sussess!");
     }
     catch
     {
         MessageBox.Show("Fail!");
     }
 }