Esempio n. 1
0
      private void OKevent(Window p)
      {
          EMPLOYEE em = new EMPLOYEE();

          em.FIRST_NAME         = EmployeeViewObj.first_name;
          em.LAST_NAME          = EmployeeViewObj.last_name;
          em.TITLE              = EmployeeViewObj.title;
          em.START_DATE         = EmployeeViewObj.start_date;
          em.END_DATE           = EmployeeViewObj.end_date;
          em.ASSIGNED_BRANCH_ID = BranchDao.Instance().SelectbyName(EmployeeViewObj.branch).BRANCH_ID;
          em.DEPT_ID            = DepartmentDao.Instace().SelectbyName(EmployeeViewObj.department).DEPT_ID;
          em.SUPERIOR_EMP_ID    = null;
          if (cv == "insert")
          {
              EmployeeDao.Instance().Insert(em);
              evm.EmployeeViewLists = evm.UpdateListview();
          }
          else
          {
              em.EMP_ID = EmployeeViewObj.id;
              EmployeeDao.Instance().Update(em);
              evm.EmployeeViewLists = evm.UpdateListview();
          }
          p.Close();
      }
Esempio n. 2
0
 private void NewEditForm()
 {
     DepartmentEdit depart = new DepartmentEdit("insert", this);
     depart.txtDepID.Text = (DepartmentDao.Instace().GetLastID() + 1).ToString();
     depart.txtDepID.IsReadOnly = true;
     depart.Show();       
 }
Esempio n. 3
0
        private void FindDepartment(FrameworkElement p)
        {
            string id = "";
            if (p != null)
            {
                var fe = p as Grid;
                if (fe != null)
                {
                    foreach (var item in fe.Children)
                    {
                        var tx = item as TextBox;
                        if (tx != null)
                        {
                            if (tx.Name.Equals("txtSearch"))
                            {
                                id = tx.Text;
                            }
                        }
                    }
                }
            }
            if (!string.IsNullOrEmpty(id))
                DeparmentLists = new ObservableCollection<DEPARTMENT>(DepartmentDao.Instace().getListByName(id));
            else
                DeparmentLists = new ObservableCollection<DEPARTMENT>(DepartmentDao.Instace().getAll());

        }
Esempio n. 4
0
        private void RemoveDepartment(DEPARTMENT d)
        {

            DepartmentDao.Instace().Delete(d.DEPT_ID);
            DeparmentLists = null;
            DeparmentLists= new ObservableCollection<DEPARTMENT>(DepartmentDao.Instace().getAll());
        }
Esempio n. 5
0
 /// <summary>
 /// Constructor
 /// </summary>
 public DepartmentVM()
 {
     DeparmentLists = new ObservableCollection<DEPARTMENT>(DepartmentDao.Instace().getAll());
     FindCommand = new RelayCommand<FrameworkElement>((p) => { return p != null ? true : false; }, (p) => { FindDepartment(p); });
     EditFormCommand = new RelayCommand<DEPARTMENT>((p) => true, (p) => { ShowEditForm(p); });
     DeleteRowCommand = new RelayCommand<DEPARTMENT>((p) => true, (p) => { RemoveDepartment(p); });
     NewFormCommand = new RelayCommand<Window>((p) => true , (p) => { NewEditForm(); });
 }
Esempio n. 6
0
        private void NewEditForm()
        {
            EmployeeEdit   pro  = new EmployeeEdit();
            EmployeeEditVM eevm = new EmployeeEditVM();

            eevm.evm        = this;
            pro.DataContext = eevm;
            pro.Show();
            pro.txtID.IsReadOnly          = true;
            pro.txtBranch.ItemsSource     = BranchDao.Instance().getAll();
            pro.txtDepartment.ItemsSource = DepartmentDao.Instace().getAll();
        }
Esempio n. 7
0
 private void ShowEditForm(EmployeeView pv)
 {
     if (pv != null)
     {
         EmployeeEdit   pro  = new EmployeeEdit();
         EmployeeEditVM eevm = new EmployeeEditVM();
         eevm.evm             = this;
         eevm.EmployeeViewObj = pv;
         pro.DataContext      = eevm;
         pro.Show();
         pro.txtID.IsReadOnly          = true;
         pro.txtBranch.ItemsSource     = BranchDao.Instance().getAll();
         pro.txtDepartment.ItemsSource = DepartmentDao.Instace().getAll();
     }
 }
Esempio n. 8
0
        private void OKevent(FrameworkElement p)
        {
            DEPARTMENT dep = new DEPARTMENT();
            var        fe  = p as Grid;

            if (fe != null)
            {
                foreach (var item in fe.Children)
                {
                    var tx = item as TextBox;
                    if (tx != null)
                    {
                        if (tx.Name.Equals("txtDepID"))
                        {
                            dep.DEPT_ID = int.Parse(tx.Text);
                        }
                        else if (tx.Name.Equals("txtName"))
                        {
                            dep.NAME = tx.Text;
                        }
                    }
                }
            }
            if (dep.DEPT_ID <= DepartmentDao.Instace().GetLastID())
            {
                DepartmentDao.Instace().Update(dep);
            }
            else
            {
                DepartmentDao.Instace().Insert(dep);
            }
            foreach (Window item in Application.Current.Windows)
            {
                if (item.DataContext == this)
                {
                    item.Close();
                }
            }
            dvm.DeparmentLists = null;
            dvm.DeparmentLists = new System.Collections.ObjectModel.ObservableCollection <DEPARTMENT>(DepartmentDao.Instace().getAll());
        }