protected void Page_Load(object sender, EventArgs e) { //Collects current method and page for error tracking string method = "Page_Load"; Session["currPage"] = "CustomerAddNew.aspx"; object[] objPageDetails = { Session["currPage"].ToString(), method }; try { //checks if the user has logged in if (Session["currentUser"] == null) { //Go back to Login to log in Response.Redirect("LoginPage.aspx", false); } else { CU = (CurrentUser)Session["currentUser"]; //Checks for a Customer Key if (Convert.ToInt32(Request.QueryString["customer"].ToString()) != -10) { if (!IsPostBack) { //Create customer class and fill page with all info based in the customer number Customer customer = CM.CallReturnCustomerWithInvoiceList(Convert.ToInt32(Request.QueryString["customer"].ToString()), objPageDetails)[0]; txtFirstName.Text = customer.varFirstName.ToString(); txtLastName.Text = customer.varLastName.ToString(); txtPrimaryAddress.Text = customer.varAddress.ToString(); txtSecondaryAddress.Text = customer.secondaryAddress.ToString(); txtPrimaryPhoneNumber.Text = customer.varContactNumber.ToString(); txtSecondaryPhoneNumber.Text = customer.secondaryPhoneNumber.ToString(); txtEmail.Text = customer.varEmailAddress.ToString(); txtCity.Text = customer.varCityName.ToString(); DdlCountry.DataSource = LM.CallReturnCountryDropDown(objPageDetails); DdlCountry.DataBind(); DdlCountry.SelectedValue = customer.intCountryID.ToString(); ddlProvince.DataSource = LM.CallReturnProvinceDropDown(customer.intCountryID, objPageDetails); ddlProvince.SelectedValue = customer.intProvinceID.ToString(); ddlProvince.DataBind(); txtPostalCode.Text = customer.varPostalCode.ToString(); chkEmailList.Checked = customer.bitSendMarketing; //Binds invoice list to the grid view GrdInvoiceSelection.DataSource = customer.invoices; GrdInvoiceSelection.DataBind(); } } else { //no cust number if (!IsPostBack) { DdlCountry.DataSource = LM.CallReturnCountryDropDown(objPageDetails); DdlCountry.DataBind(); DdlCountry.SelectedValue = CU.location.intCountryID.ToString(); ddlProvince.DataSource = LM.CallReturnProvinceDropDown(0, objPageDetails); ddlProvince.DataBind(); } //Displays text boxes instead of label for customer creation info txtFirstName.Enabled = true; txtLastName.Enabled = true; txtPrimaryAddress.Enabled = true; txtSecondaryAddress.Enabled = true; txtPrimaryPhoneNumber.Enabled = true; txtSecondaryPhoneNumber.Enabled = true; txtEmail.Enabled = true; txtCity.Enabled = true; ddlProvince.Enabled = true; DdlCountry.Enabled = true; chkEmailList.Enabled = true; txtPostalCode.Enabled = true; //hides and displays the proper buttons for access BtnSaveCustomer.Visible = false; BtnAddCustomer.Visible = true; pnlDefaultButton.DefaultButton = "btnAddCustomer"; BtnEditCustomer.Visible = false; BtnStartSale.Visible = false; BtnCancel.Visible = false; BtnBackToSearch.Visible = true; } } } //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); } }
//private static Employee employee; protected void Page_Load(object sender, EventArgs e) { //Collects current method and page for error tracking string method = "Page_Load"; Session["currPage"] = "EmployeeAddNew.aspx"; object[] objPageDetails = { Session["currPage"].ToString(), method }; try { //checks if the user has logged in if (Session["currentUser"] == null) { //Go back to Login to log in Response.Redirect("LoginPage.aspx", false); } else { CU = (CurrentUser)Session["currentUser"]; if (CU.employee.intJobID != 0) { //If user is not an admin then disable the edit employee button BtnEditEmployee.Enabled = false; } //Check to see if an employee was selected if (Convert.ToInt32(Request.QueryString["employee"].ToString()) != -10) { if (!IsPostBack) { //Create an employee class Employee employee = EM.CallReturnEmployee(Convert.ToInt32(Request.QueryString["employee"].ToString()), objPageDetails)[0]; //Fill asll lables with current selected employee info txtFirstName.Text = employee.varFirstName.ToString(); txtLastName.Text = employee.varLastName.ToString(); ddlJob.DataSource = EM.CallReturnJobPosition(objPageDetails); ddlJob.DataBind(); ddlJob.SelectedValue = employee.intJobID.ToString(); ddlLocation.DataSource = LM.CallReturnLocationDropDown(objPageDetails); ddlLocation.DataBind(); ddlLocation.SelectedValue = employee.location.intLocationID.ToString(); txtEmail.Text = employee.varEmailAddress.ToString(); txtPrimaryPhoneNumber.Text = employee.varContactNumber.ToString(); txtSecondaryPhoneNumber.Text = employee.secondaryContactNumber.ToString(); txtPrimaryAddress.Text = employee.varAddress.ToString(); txtSecondaryAddress.Text = employee.secondaryAddress.ToString(); txtCity.Text = employee.varCityName.ToString(); txtPostalCode.Text = employee.varPostalCode.ToString(); ddlProvince.SelectedValue = employee.intProvinceID.ToString(); DdlCountry.SelectedValue = employee.intCountryID.ToString(); DdlCountry.DataSource = LM.CallReturnCountryDropDown(objPageDetails); DdlCountry.DataBind(); ddlProvince.DataSource = LM.CallReturnProvinceDropDown(employee.intCountryID, objPageDetails); ddlProvince.DataBind(); } } else { if (!IsPostBack) { ddlJob.DataSource = EM.CallReturnJobPosition(objPageDetails); ddlJob.DataBind(); ddlJob.SelectedValue = CU.employee.intJobID.ToString(); ddlLocation.DataSource = LM.CallReturnLocationDropDown(objPageDetails); ddlLocation.DataBind(); ddlLocation.SelectedValue = CU.location.intLocationID.ToString(); DdlCountry.DataSource = LM.CallReturnCountryDropDown(objPageDetails); DdlCountry.DataBind(); DdlCountry.SelectedValue = CU.location.intCountryID.ToString(); ddlProvince.DataSource = LM.CallReturnProvinceDropDown(0, objPageDetails); ddlProvince.DataBind(); ddlProvince.SelectedValue = CU.location.intProvinceID.ToString(); } //With no employee selected display text boxes and drop downs to add employee txtFirstName.Enabled = true; txtLastName.Enabled = true; ddlJob.Enabled = true; ddlLocation.Enabled = true; txtEmail.Enabled = true; txtPrimaryPhoneNumber.Enabled = true; txtSecondaryPhoneNumber.Enabled = true; txtPrimaryAddress.Enabled = true; txtSecondaryAddress.Enabled = true; txtCity.Enabled = true; txtPostalCode.Enabled = true; ddlProvince.Enabled = true; DdlCountry.Enabled = true; //hides and displays the proper buttons for access BtnSaveEmployee.Visible = false; BtnAddEmployee.Visible = true; pnlDefaultButton.DefaultButton = "btnAddEmployee"; BtnEditEmployee.Visible = false; BtnCancel.Visible = false; BtnBackToSearch.Visible = true; } } } //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); } }