protected void lnkBtnDeleteEmployee_Click(object sender, EventArgs e)
 {
     myEmployee = EmployeeDB.GetEmployeeDetails(intEmployee_ID);
     EmployeeDB.DeleteEmployee(myEmployee.ID);
     Response.Redirect("Default.aspx");
 }
Beispiel #2
0
        public static Boolean ValidateEmployeeDetails(EmployeeDetails myEmployee, bool NewEntry)
        {
            Boolean Valid = true;

            if (!NewEntry)
            {
                if (myEmployee.ID <= 0)
                {
                    Valid = false;
                }
            }


            if (myEmployee.FirstName.Length == 0)
            {
                Valid = false;
            }

            if (myEmployee.LastName.Length == 0)
            {
                Valid = false;
            }

            if (!NewEntry)
            {
                if (myEmployee.ContactID == 0)
                {
                    Valid = false;
                }
            }

            if (myEmployee.ContactEmail.Length > 0)
            {
                var  EAA        = new EmailAddressAttribute();
                bool validemail = EAA.IsValid(myEmployee.ContactEmail);
                if (!validemail)
                {
                    Valid = false;
                }
            }

            if (myEmployee.ContactHomePhone.Length > 0)
            {
                if (!IsPhoneNumber(myEmployee.ContactHomePhone.ToString()))
                {
                    Valid = false;
                }
            }

            if (myEmployee.ContactCellPhone.Length > 0)
            {
                if (!IsPhoneNumber(myEmployee.ContactCellPhone.ToString()))
                {
                    Valid = false;
                }
            }

            if (myEmployee.ContactFax.Length > 0)
            {
                if (!IsPhoneNumber(myEmployee.ContactFax.ToString()))
                {
                    Valid = false;
                }
            }

            if (!NewEntry)
            {
                if (myEmployee.Employee_AddressID == 0)
                {
                    Valid = false;
                }
            }

            if (myEmployee.Employee_AddressLine.Length == 0)
            {
                Valid = false;
            }

            if (myEmployee.Employee_AddressCity.Length == 0)
            {
                Valid = false;
            }

            if (myEmployee.Employee_Address_StateID == 0)
            {
                Valid = false;
            }

            if (myEmployee.Employee_AddressZip.Length == 0)
            {
                Valid = false;
            }

            return(Valid);
        }