protected void Page_Load(object sender, EventArgs e) { this.repStoreId = Common.GetEncryptedQueryStringValue("RepStoreId", 0); this.employeeId = Common.GetEncryptedQueryStringValue("EmployeeId", 0); this.storeId = Common.GetEncryptedQueryStringValue("StoreId", 0); callCycle = CallCycle.GetCallCycleList(); if (!IsPostBack) { if (ViewState["RepStoreId"] != null) { this.repStoreId = Convert.ToInt32(ViewState["RepStoreId"].ToString()); } if (ViewState["EmployeeId"] != null) { this.employeeId = Convert.ToInt32(ViewState["EmployeeId"].ToString()); } if (ViewState["StoreId"] != null) { this.storeId = Convert.ToInt32(ViewState["StoreId"].ToString()); } if (this.repStoreId != 0) { BindStoreCallCycle(); RepStore repStore = RepStore.GetRepStoreByRepStoreId(this.repStoreId); LabelPageTitle.Text = String.Format("{0} - {1}", repStore.FormattedName, repStore.Store); } } }
protected void RepeaterStore_ItemCommand(object source, RepeaterCommandEventArgs e) { try { switch (e.CommandName.ToLower()) { case "remove": { RepStore.DeleteRepStoreByRepStoreId(Convert.ToInt32(e.CommandArgument)); BindEmployeeStoreList(); BindStoreList(); break; } } } catch (System.Data.SqlClient.SqlException sqlEx) { LabelError.Text = ""; for (int i = 0; i < sqlEx.Errors.Count; i++) { LabelError.Text += (sqlEx.Errors[i].Message + "<br />"); } PanelError.Visible = true; } }
protected void ButtonSave_Click(object sender, EventArgs e) { if (Page.IsValid) { int employeeId = Convert.ToInt32(ListBoxEmployee.SelectedValue); try { LabelError.Text = ""; bool hasError = false; PanelError.Visible = false; foreach (GridViewRow gridViewRow in GridViewResult.Rows) { CheckBox checkBoxRepStoreLink = (CheckBox)gridViewRow.Cells[4].FindControl("CheckBoxLink"); HiddenField hiddenFieldRepStoreId = (HiddenField)gridViewRow.Cells[5].FindControl("HiddenFieldRepStoreId"); HiddenField hiddenFieldStoreId = (HiddenField)gridViewRow.Cells[6].FindControl("HiddenFieldStoreId"); if (Convert.ToInt32(hiddenFieldRepStoreId.Value) > 0) { if (!checkBoxRepStoreLink.Checked) { RepStore.DeleteRepStoreByRepStoreId(Convert.ToInt32(hiddenFieldRepStoreId.Value)); } } else { if (checkBoxRepStoreLink.Checked) { RepStore.InsertRepresentativeStore(employeeId, Convert.ToInt32(hiddenFieldStoreId.Value), this.Master.LoggedOnAccount /*, Convert.ToInt32(dropDownListCallCycle.SelectedValue), (checkBoxWeek1.Checked == true ? 1 : 0), (checkBoxWeek2.Checked == true ? 1 : 0), (checkBoxWeek3.Checked == true ? 1 : 0), (checkBoxWeek4.Checked == true ? 1 : 0), (checkBoxWeek5.Checked == true ? 1 : 0) 0, (checkBoxDay1.Checked == true ? 1 : 0), (checkBoxDay2.Checked == true ? 1 : 0), (checkBoxDay3.Checked == true ? 1 : 0), (checkBoxDay4.Checked == true ? 1 : 0), (checkBoxDay5.Checked == true ? 1 : 0), (checkBoxDay6.Checked == true ? 1 : 0), (checkBoxDay7.Checked == true ? 1 : 0)*/); } } } LabelError.Text = "Save successful."; PanelError.Visible = true; BindGridView(); } catch (System.Data.SqlClient.SqlException sqlEx) { LabelError.Text = ""; for (int i = 0; i < sqlEx.Errors.Count; i++) { LabelError.Text += (sqlEx.Errors[i].Message + "<br />"); } PanelError.Visible = true; } } }
private void BindEmployeeStoreList() { try { RepeaterStores.DataSource = RepStore.GetRepStoreListByEmployeeId(this.employeeId); RepeaterStores.DataBind(); } catch (System.Data.SqlClient.SqlException sqlEx) { LabelError.Text = ""; for (int i = 0; i < sqlEx.Errors.Count; i++) { LabelError.Text += (sqlEx.Errors[i].Message + "<br />"); } PanelError.Visible = true; } }
protected void ButtonAddStore_Click(object sender, EventArgs e) { try { if (DropDownListStore.Items.Count > 0) { RepStore.InsertRepresentativeStore(this.employeeId, Convert.ToInt32(DropDownListStore.SelectedValue), this.Master.LoggedOnAccount); BindEmployeeStoreList(); BindStoreList(); } } catch (System.Data.SqlClient.SqlException sqlEx) { LabelError.Text = ""; for (int i = 0; i < sqlEx.Errors.Count; i++) { LabelError.Text += (sqlEx.Errors[i].Message + "<br />"); } PanelError.Visible = true; } }