コード例 #1
0
        protected void BtnAddEmployee_Click(object sender, EventArgs e)
        {
            //Collects current method for error tracking
            string method = "BtnAddEmployee_Click";

            object[] objPageDetails = { Session["currPage"].ToString(), method };
            try
            {
                //Collects new employee data to add to database
                Employee employee = new Employee();;
                employee.varFirstName           = txtFirstName.Text;
                employee.varLastName            = txtLastName.Text;
                employee.intJobID               = Convert.ToInt32(ddlJob.SelectedValue);
                employee.location               = LM.CallReturnLocation(Convert.ToInt32(ddlLocation.SelectedValue), objPageDetails)[0];
                employee.varEmailAddress        = txtEmail.Text;
                employee.varContactNumber       = txtPrimaryPhoneNumber.Text;
                employee.secondaryContactNumber = txtSecondaryPhoneNumber.Text;
                employee.varAddress             = txtPrimaryAddress.Text;
                employee.secondaryAddress       = txtSecondaryAddress.Text;
                employee.varCityName            = txtCity.Text;
                employee.varPostalCode          = txtPostalCode.Text;
                employee.intProvinceID          = Convert.ToInt32(ddlProvince.SelectedValue);
                employee.intCountryID           = Convert.ToInt32(DdlCountry.SelectedValue);

                var nameValues = HttpUtility.ParseQueryString(Request.QueryString.ToString());
                nameValues.Set("employee", EM.CallAddEmployee(employee, objPageDetails).ToString());
                Response.Redirect(Request.Url.AbsolutePath + "?" + nameValues, false);
            }
            //Exception catch
            catch (ThreadAbortException tae) { }
            catch (Exception ex)
            {
                //Log all info into error table
                ER.CallLogError(ex, CU.employee.intEmployeeID, Convert.ToString(Session["currPage"]) + "-V3.2", method, this);
                //Display message box
                MessageBoxCustom.ShowMessage("An Error has occurred and been logged. "
                                             + "If you continue to receive this message please contact "
                                             + "your system administrator.", this);
            }
        }