protected void ButtonAddStoreCustomMember_Click(object sender, EventArgs e) { LabelError.Text = ""; bool hasError = false; PanelError.Visible = false; if (TextBoxStoreCustomMemberEmployeeName.Text.Length == 0) { LabelError.Text += "Name is required.\n"; PanelError.Visible = true; hasError = true; } if (DropDownListStoreCustomMemberEmployeeRole.SelectedValue == "0") { LabelError.Text += "Role Name is required.\n"; PanelError.Visible = true; hasError = true; } if (hasError == false) { try { StoreCustomMember storeCustomMember = new StoreCustomMember(); storeCustomMember.StoreCustomMemberId = (ViewState["StoreCustomMemberId"] == null) ? 0 : Convert.ToInt32(ViewState["StoreCustomMemberId"]); storeCustomMember.StoreCustomId = this.storeCustomId; storeCustomMember.EmployeeName = TextBoxStoreCustomMemberEmployeeName.Text; storeCustomMember.RoleName = DropDownListStoreCustomMemberEmployeeRole.SelectedValue; storeCustomMember.Email = TextBoxStoreCustomMemberEmail.Text; storeCustomMember.ContactNumber = TextBoxStoreCustomMemberContactNumber.Text; storeCustomMember.Birthday = (TextBoxStoreCustomBirthday.Text.Length == 0) ? Convert.ToDateTime("1900/01/01") : Convert.ToDateTime(TextBoxStoreCustomBirthday.Text); storeCustomMember.ModifiedUser = this.Master.LoggedOnAccount; storeCustomMember.Save(); BindStoreCustomMember(); TextBoxStoreCustomMemberEmployeeName.Text = ""; //DropDownListStoreCustomMemberEmployeeRole.Items.Clear(); //DropDownListStoreCustomMemberEmployeeRole.Items.FindByText("").Selected = true; BindEmployeeRole(); TextBoxStoreCustomMemberEmail.Text = ""; TextBoxStoreCustomMemberEmail.Text = ""; TextBoxStoreCustomMemberContactNumber.Text = ""; TextBoxStoreCustomBirthday.Text = ""; } 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 GridViewStoreCustomMember_RowCommand(object sender, GridViewCommandEventArgs e) { try { switch (e.CommandName.ToLower()) { case "removestorecustommember": { StoreCustomMember.DeleteStoreCustomMemberByStoreCustomMemberId(Convert.ToInt32(e.CommandArgument)); BindStoreCustomMember(); break; } case "editstorecustommember": { StoreCustomMember storeCustomMember = StoreCustomMember.GetStoreCustomMemberByStoreCustomMemberId(Convert.ToInt32(e.CommandArgument)); ViewState["StoreCustomMemberId"] = storeCustomMember.StoreCustomMemberId; TextBoxStoreCustomMemberEmployeeName.Text = storeCustomMember.EmployeeName; //BindEmployeeRole(); DropDownListStoreCustomMemberEmployeeRole.ClearSelection(); DropDownListStoreCustomMemberEmployeeRole.Items.FindByText(storeCustomMember.RoleName).Selected = true; TextBoxStoreCustomMemberEmail.Text = storeCustomMember.Email; TextBoxStoreCustomMemberContactNumber.Text = storeCustomMember.ContactNumber; TextBoxStoreCustomBirthday.Text = storeCustomMember.Birthday.ToString("yyyy/MM/dd"); 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; } }
private void BindStoreCustomMember() { GridViewStoreCustomMember.DataSource = StoreCustomMember.GetStoreCustomMemberListByStoreCustomId(this.storeCustomId); GridViewStoreCustomMember.DataBind(); }