Example #1
0
        /// <summary>
        /// hàm thục thi excute
        /// </summary>
        /// <param name="parameter"></param>
        private void OnExcutePTC(object parameter)
        {
            var obj    = (object[])parameter;
            var window = (Window)obj[0];
            var wrap   = (WrapPanel)obj[1];
            PhieuChiTieuDaoImpl impl = new PhieuChiTieuDaoImpl();
            PhieuChiTieu        ptc  = new PhieuChiTieu();

            try
            {
                foreach (var item in (wrap as WrapPanel).Children)
                {
                    string name = null;
                    if (item is FrameworkElement)
                    {
                        name = (item as FrameworkElement).Name;
                        switch (name)
                        {
                        case "txbMaPhieu":
                            ptc.MaPhieuChiTieu = (item as TextBlock).Text;
                            break;

                        case "dtNgay":
                            ptc.NgayTaoPhieu = (item as DatePicker).SelectedDate.Value;
                            break;

                        case "txtMaNV":
                            ptc.MaNhanVien = (item as TextBox).Text;
                            break;

                        case "nbChiPhi":
                            ptc.ChiPhi = (decimal)(item as NumericUpDown).Value.GetValueOrDefault();
                            break;

                        case "txtLyDo":
                            ptc.LyDo = (item as TextBox).Text;
                            break;
                        }
                    }
                }
                if (string.IsNullOrEmpty(ptc.MaPhieuChiTieu))
                {
                    // theem moi
                    impl.AddPhieuChiTieu(ptc);
                    MessageBox.Show("Thêm mói thành công");
                }
                else
                {
                    // suawr
                    impl.EditPhieuChiTieu(ptc);
                    MessageBox.Show("Sửa thành công");
                }
                window.DataContext = new PhieuChiTieuViewModel();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Example #2
0
        /// <summary>
        /// hàm lấy danh sách phiếu chi tiêu
        /// </summary>
        /// <returns></returns>
        private ObservableCollection <PhieuChiTieu> getListPTC()
        {
            ObservableCollection <PhieuChiTieu> list = new ObservableCollection <PhieuChiTieu>();
            PhieuChiTieuDaoImpl impl = new PhieuChiTieuDaoImpl();

            if (list != null)
            {
                list.Clear();
                impl.GetListPhieuChiTieu().ForEach(p => list.Add(p));
            }
            return(list);
        }
Example #3
0
        /// <summary>
        /// hàm delete
        /// </summary>
        /// <param name="parameter"></param>
        private void OnDeletePTC(object parameter)
        {
            var obj                  = (object[])parameter;
            var window               = (Window)obj[0];
            var datagrid             = (DataGrid)obj[1];
            PhieuChiTieuDaoImpl impl = new PhieuChiTieuDaoImpl();

            try
            {
                PhieuChiTieu ptc = new PhieuChiTieu();
                ptc = datagrid.SelectedItem as PhieuChiTieu;
                impl.DeletePhieuChiTieu(ptc.MaPhieuChiTieu);
                window.DataContext = new PhieuChiTieuViewModel();
                MessageBox.Show("Xóa thành công!");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }