Esempio n. 1
0
        public override void FormToModel()
        {
            EmployeeInfo employeeInfo = EmployeeController.EmployeeInfoModel;
            if (employeeInfo == null)
            {
                employeeInfo = new EmployeeInfo();
            }

            employeeInfo.EmployeeName = txtEmployeeName.Text.Trim();
            employeeInfo.Address = txtAddress.Text.Trim();
            employeeInfo.StartDate = dtpCreateDate.Value;
            employeeInfo.Salary = ObjectConverter.Convert<Int32>(txtSalary.Text);
            //employeeInfo.Employee.EmployeeId = employeeInfo.EmployeeId;
            EmployeeController.EmployeeInfoModel = employeeInfo;
        }
Esempio n. 2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            FormToModel();
            EmployeeEventArgs eventArgs = new EmployeeEventArgs();

            EmployeeInfo employeeInfo = new EmployeeInfo();

            Employee employee = new Employee();
            employee.Department = SalePointController.DepartmentModel;
            //employee.DepartmentId = SalePointController.DepartmentModel.DepartmentId;
            employee.EmployeeInfo = employeeInfo;

            employeeInfo.Employee = employee;
            //employeeInfo.DepartmentId = (int)SalePointController.DepartmentModel.DepartmentId;

            EmployeePK employeePK = new EmployeePK();
            employeePK.DepartmentId = SalePointController.DepartmentModel.DepartmentId;
            employeeInfo.EmployeePK = employeePK;
            employee.EmployeePK = employeePK;

            eventArgs.EmployeeInfo = employeeInfo;
            eventArgs.SelectedEmployee = -1;
            this.Enabled = false;

            EventUtility.fireEvent(AddEmployeeEvent,this,eventArgs);
            if(eventArgs.AddedEmployee!=null)
            {
                bdsEmployeeSource.Add(eventArgs.AddedEmployee);
                bdsEmployeeSource.EndEdit();
                dgvEmployees.Refresh();
                dgvEmployees.Invalidate();
            }
            this.Enabled = true;
            employeeController.EmployeeInfoModel = null;
        }
Esempio n. 3
0
 /// <summary>
 /// Delete EmployeeInfo from database.
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public void Delete(EmployeeInfo data)
 {
     HibernateTemplate.Delete(data);
 }
Esempio n. 4
0
 private Department GetDepartmentFromEmployee(EmployeeInfo info)
 {
     foreach (Department department in bdsDepartment)
     {
         if(department.DepartmentId== info.EmployeePK.DepartmentId)
         {
             return department;
         }
     }
     return null;
 }
Esempio n. 5
0
 /// <summary>
 /// Add EmployeeInfo to database.
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public EmployeeInfo Add(EmployeeInfo data)
 {
     HibernateTemplate.Save(data);
     return data;
 }
Esempio n. 6
0
        /// <summary>
        /// Update EmployeeInfo to database.
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public void Update(EmployeeInfo data)
        {
            /*HibernateTemplate.Execute(
                delegate(ISession session)
                {

                    return data;
                }
                );*/
            //            ObjectCriteria criteria = new ObjectCriteria();
            //            criteria.AddEqCriteria("EmployeePK.EmployeeId", data.EmployeePK.EmployeeId);
            //            criteria.AddEqCriteria("EmployeePK.DepartmentId", data.EmployeePK.DepartmentId);
            //            IList list = FindAll(criteria);
            EmployeeInfo info = FindById(data.EmployeePK);
            if(info!=null)
            {
                //EmployeeInfo info = (EmployeeInfo)list[0];
                info.UpdateDate = data.UpdateDate;
                info.UpdateId = data.UpdateId;
                info.DelFlg = data.DelFlg;
                info.Country = data.Country;
                info.Address = data.Address;
                info.EmployeeName = data.EmployeeName;
                info.Address = data.Address;
                info.Salary = data.Salary;
                info.StartDate = data.StartDate;
                info.Employee = data.Employee;
                HibernateTemplate.Update(info);
            }
            //HibernateTemplate.Update(data);
        }
        public EmployeeInfo Add(EmployeeInfo employeeInfo)
        {
            ObjectCriteria crit = new ObjectCriteria();
            crit.AddOrder("Barcode", false);
            crit.MaxResult = 3;
            IList list = EmployeeDetailDAO.FindAll(crit);
            string barCode = "NV000001";
            if(list!=null && list.Count > 0 )
            {
                EmployeeInfo info = (EmployeeInfo) list[0];
                barCode = "NV" + string.Format("{0:000000}",Int32.Parse(info.Barcode.Substring(2))+1);
            }

            if (employeeInfo.Employee==null) // create new
            {
                string employeeId = ConvertEmployeeNameToId(employeeInfo.EmployeeName);
                //employeeInfo.EmployeePK.DepartmentId = departmentId;
                var employeePK = new EmployeePK { DepartmentId = 0, EmployeeId = employeeId };

                employeeInfo.EmployeePK = employeePK;
                //employeeInfo.EmployeeId = employeeId;

                if(employeeInfo.Employee == null)
                {
                    employeeInfo.Employee = new Employee();
                }
                employeeInfo.Employee.EmployeePK = employeePK;
                employeeInfo.Employee.CreateDate = DateTime.Now;
                employeeInfo.Employee.CreateId = ClientInfo.getInstance().LoggedUser.Name;
                employeeInfo.DelFlg = 0;
                employeeInfo.ExclusiveKey = 1;
                employeeInfo.Employee.DelFlg = 0;
                employeeInfo.Employee.ExclusiveKey = 1;
                employeeInfo.Employee.Department = new Department {DepartmentId = 0};
                employeeInfo.Department = new Department{DepartmentId = 0};
                /*employeeInfo.Employee.EmployeeId = employeeId;
                employeeInfo.Employee.DepartmentId = departmentId;*/
                employeeInfo.CreateDate = DateTime.Now;
                employeeInfo.CreateId = ClientInfo.getInstance().LoggedUser.Name;
                employeeInfo.Barcode = barCode;
                employeeInfo.Employee.CreateDate = DateTime.Now;
                employeeInfo.Employee.CreateId = ClientInfo.getInstance().LoggedUser.Name;
                EmployeeDAO.Add(employeeInfo.Employee);
                EmployeeDetailDAO.Add(employeeInfo);

            }
            else // update
            {

                employeeInfo.UpdateDate = DateTime.Now;
                employeeInfo.UpdateId = ClientInfo.getInstance().LoggedUser.Name;

                employeeInfo.Employee.UpdateDate = DateTime.Now;
                employeeInfo.Employee.UpdateId = ClientInfo.getInstance().LoggedUser.Name;

                EmployeeDetailDAO.Update(employeeInfo);
                //EmployeeDAO.Update(employeeInfo.Employee);

            }

            //EmployeeDetailDAO.Add(data);
            return employeeInfo;
        }
 public void Update(EmployeeInfo data)
 {
     EmployeeDetailDAO.Update(data);
 }
 public void Delete(EmployeeInfo data)
 {
     EmployeeDetailDAO.Delete(data);
 }