예제 #1
0
        private void BtnUpdate_Click(object sender, RoutedEventArgs e)
        {
            Employee emp = new Employee();

            EmployeeValidations ev = new EmployeeValidations();

            emp.EmployeeID           = int.Parse(txtEId.Text.ToString());
            emp.EmployeeName         = txtEName.Text.ToString();
            emp.Designation          = txtDesgn.Text.ToString();
            emp.PhoneNumber          = double.Parse(txtPhone.Text.ToString());
            emp.EmailID              = txtEmail.Text.ToString();
            emp.Address              = txtAddress.Text.ToString();
            emp.DrivingLicenseNumber = txtDL.Text.ToString();
            bool updateStatus = ev.UpdateEmployee_BLL(emp);

            if (updateStatus)
            {
                MessageBox.Show("Employee Details Updated");
                gridEmployee.Visibility = Visibility.Hidden;
                txtEId.Clear();
                txtEName.Clear();
                txtDesgn.Clear();
                txtPhone.Clear();
                txtEmail.Clear();
                txtAddress.Clear();
                txtDL.Clear();
            }
            else
            {
                MessageBox.Show("Employee Cannot be Updated");
            }
        }
예제 #2
0
        public static void DeserializeEmployee()
        {
            try
            {
                List <Employee> empList = EmployeeValidations.DeserializeEmployee();

                if (empList != null || empList.Count > 0)
                {
                    Console.WriteLine("***********************************************************************************************************************");
                    Console.WriteLine("Employee ID     Employee Name       Date of Joining    Date of Birth    Salary      Phone Number      City");
                    Console.WriteLine("***********************************************************************************************************************");
                    foreach (Employee emp in empList)
                    {
                        Console.WriteLine(emp.EmployeeID + "\t" + emp.EmployeeName + "\t" + emp.DOJ + "\t" + emp.DOB + "\t" + emp.Salary + "\t" + emp.Phone + "\t" + emp.City);
                    }
                    Console.WriteLine("***********************************************************************************************************************");
                }
                else
                {
                    throw new EmployeeException("Employee Details not deserialized");
                }
            }
            catch (EmployeeException ex)
            {
                Console.WriteLine(ex.Message);
            }
            catch (SystemException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
예제 #3
0
        public static void SearchEmployee()
        {
            try
            {
                int empID;

                Console.Write("Enter Employee ID for Search : ");
                empID = Convert.ToInt32(Console.ReadLine());

                Employee emp = EmployeeValidations.SearchEmployee(empID);

                if (emp != null)
                {
                    Console.WriteLine("Employee ID : " + emp.EmployeeID);
                    Console.WriteLine("Employee Name : " + emp.EmployeeName);
                    Console.WriteLine("Date of Joining : " + emp.DOJ);
                    Console.WriteLine("Date of Birth : " + emp.DOB);
                    Console.WriteLine("Employee Salary : " + emp.Salary);
                    Console.WriteLine("Phone Number : " + emp.Phone);
                    Console.WriteLine("Employee City : " + emp.City);
                }
                else
                {
                    throw new EmployeeException("Employee " + empID + " not found");
                }
            }
            catch (EmployeeException ex)
            {
                Console.WriteLine(ex.Message);
            }
            catch (SystemException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
예제 #4
0
        public static void DeleteEmployee()
        {
            try
            {
                int empID;

                Console.Write("Enter Employee ID to be Deleted : ");
                empID = Convert.ToInt32(Console.ReadLine());

                bool isDeleted = EmployeeValidations.DeleteEmployee(empID);

                if (isDeleted)
                {
                    Console.WriteLine("Employee " + empID + " deleted successfully");
                }
                else
                {
                    throw new EmployeeException("Employee " + empID + " not deleted");
                }
            }
            catch (EmployeeException ex)
            {
                Console.WriteLine(ex.Message);
            }
            catch (SystemException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        private void BtnDelete_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Employee emp = new Employee();

                EmployeeValidations ev = new EmployeeValidations();
                int  eid          = int.Parse(txtEId.Text.ToString());
                bool deleteStatus = ev.DeleteEmployee_BLL(eid);
                if (deleteStatus)
                {
                    MessageBox.Show("Employee Details Deleted");
                    gridEmployee.Visibility = Visibility.Hidden;
                    txtEId.Clear();
                    txtEName.Clear();
                    txtDesgn.Clear();
                    txtPhone.Clear();
                    txtEmail.Clear();
                    txtAddress.Clear();
                    txtDL.Clear();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #6
0
        private void BtnMainSearch_Click(object sender, RoutedEventArgs e)
        {
            if (rbEmployee.IsChecked == true)
            {
                Employee emp = new Employee();

                EmployeeValidations ev = new EmployeeValidations();
                int eid = int.Parse(txtSearch.Text);
                emp = ev.SearchEmployee_BLL(eid);

                if (emp != null)
                {
                    txtEId.Text             = emp.EmployeeID.ToString();
                    txtEName.Text           = emp.EmployeeName;
                    txtDesgn.Text           = emp.Designation;
                    txtPhone.Text           = emp.PhoneNumber.ToString();
                    txtEmail.Text           = emp.EmailID;
                    txtAddress.Text         = emp.Address;
                    txtDL.Text              = emp.DrivingLicenseNumber;
                    gridEmployee.Visibility = Visibility.Visible;
                }
                else
                {
                    MessageBox.Show("Employee Not Found");
                }
            }
            else if (rbCustomer.IsChecked == true)
            {
                Customer cust = new Customer();

                CustomerValidations cv = new CustomerValidations();
                int cid = int.Parse(txtSearch.Text);
                cust = cv.SearchCustomer_BLL(cid);

                if (cust != null)
                {
                    txtCId.Text             = cust.CustomerID.ToString();
                    txtCName.Text           = cust.CustomerName;
                    txtCEmail.Text          = cust.EmailID;
                    txtCPhone.Text          = cust.PhoneNumber.ToString();
                    txtCAddress.Text        = cust.Address;
                    gridCustomer.Visibility = Visibility.Visible;
                }
                else
                {
                    MessageBox.Show("Customer Not Found");
                }
            }
            else
            {
                gridEmployee.Visibility = Visibility.Hidden;
                gridCustomer.Visibility = Visibility.Hidden;
                MessageBox.Show("Select Employee or Customer");
            }
        }
예제 #7
0
        public static void UpdateEmployee()
        {
            try
            {
                Employee emp = new Employee();
                Console.Write("Enter Employee ID to be updated: ");
                emp.EmployeeID = Convert.ToInt32(Console.ReadLine());

                Console.Write("Enter Modified Employee Name : ");
                emp.EmployeeName = Console.ReadLine();

                Console.Write("Enter Modified Date of Joining : ");
                emp.DOJ = Convert.ToDateTime(Console.ReadLine());

                Console.Write("Enter Modified Date of Birth : ");
                emp.DOB = Convert.ToDateTime(Console.ReadLine());

                Console.Write("Enter Modified Employee Salary : ");
                emp.Salary = Convert.ToDouble(Console.ReadLine());

                Console.Write("Enter Modified Phone Number : ");
                emp.Phone = Console.ReadLine();

                Console.Write("Enter Modified City : ");
                emp.City = Console.ReadLine();

                bool isUpdated = EmployeeValidations.UpdateEmployee(emp);

                if (isUpdated)
                {
                    Console.WriteLine("Employee details updated successfully");
                }
                else
                {
                    throw new EmployeeException("Employee details not updated");
                }
            }
            catch (EmployeeException ex)
            {
                Console.WriteLine(ex.Message);
            }
            catch (SystemException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
예제 #8
0
        private void Btn_EmpRegister_Click(object sender, RoutedEventArgs e)
        {
            Employee emp = new Employee();

            emp.EmployeeName         = txt_EName.Text.ToString();
            emp.EmailID              = txt_Email.Text;
            emp.PhoneNumber          = long.Parse(txt_Phone.Text.ToString());
            emp.Designation          = txt_Desgn.Text.ToString();
            emp.Address              = txt_Address.Text;
            emp.DrivingLicenseNumber = txt_License.Text.ToString();
            Users users = new Users();

            users.LoginID  = (txt_LoginID.Text);
            users.Password = txt_Password.Password.ToString();
            users.Role     = "Employee";
            //users.EmployeeID = 0;

            EmployeeValidations ev = new EmployeeValidations();

            try
            {
                if (ev.AddEmployee_BLL(emp, users) != 0)
                {
                    MessageBox.Show("Employee Details are added");
                    CustomerHome ch = new CustomerHome();
                    ch.Show();
                    Close();
                }
                else
                {
                    throw new EmployeeException("Entered details are not correct");
                }
            }
            catch (EmployeeException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #9
0
        public static void SerializeEmployee()
        {
            try
            {
                bool isSerialized = EmployeeValidations.SerializeEmployee();

                if (isSerialized)
                {
                    Console.WriteLine("Employee Data is Serialized");
                }
                else
                {
                    throw new EmployeeException("Employee Data is not Serialized");
                }
            }
            catch (EmployeeException ex)
            {
                Console.WriteLine(ex.Message);
            }
            catch (SystemException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }