private void BindStoreCustom() { try { StoreCustom storeCustom = StoreCustom.GetStoreCustomByStoreId(this.storeId, this.companyId); TextBoxCustomDescription.Text = storeCustom.CustomDescription; TextBoxCustomStoreId.Text = storeCustom.CustomStoreId.ToString(); TextBoxAddress.Text = storeCustom.Address; TextBoxGPS.Text = storeCustom.GPS; TextBoxContactPerson.Text = storeCustom.ContactPerson; TextBoxContactNumber.Text = storeCustom.ContactNumber; CheckBoxGroupStore.Checked = storeCustom.GroupStore == 1; DropDownListStoreGroup.Items.FindByValue(storeCustom.StoreGroupId.ToString()).Selected = true; CheckBoxCatmanStore.Checked = storeCustom.CatmanStore == 1; //TextBoxAttachment.Text = storeCustom.CustomDescription; TextBoxComment.Text = storeCustom.Comment; TextBoxEmail.Text = storeCustom.Email; List <StoreCustomConcept> storeCustomConceptList = StoreCustomConcept.GetStoreCustomConceptLinkListByStoreCustomId(storeCustom.StoreCustomId); foreach (ListItem listItem in CheckBoxListStoreCustomConcept.Items) { foreach (StoreCustomConcept storeCustomConcept in storeCustomConceptList) { if (listItem.Value == storeCustomConcept.StoreCustomConceptId.ToString()) { listItem.Selected = true; } } } } catch (System.Data.SqlClient.SqlException sqlEx) { for (int i = 0; i < sqlEx.Errors.Count; i++) { LabelError.Text += (sqlEx.Errors[i].Message + "<br />"); } PanelError.Visible = true; } catch (Exception exception) { LabelError.Text += (exception.Message + "<br />"); PanelError.Visible = true; } }
protected void Page_Load(object sender, EventArgs e) { this.storeId = Common.GetEncryptedQueryStringValue("StoreId", 0); LabelPageTitle.Text = "Custom Store"; PanelError.Visible = false; Page.Form.DefaultFocus = TextBoxCustomDescription.ClientID; Page.Form.DefaultButton = ButtonSaveList.UniqueID; this.companyId = Account.GetAccountByUserName(Page.User.Identity.Name.ToString()).CompanyId; this.storeCustomId = StoreCustom.GetStoreCustomByStoreId(this.storeId, this.companyId).StoreCustomId; if (!IsPostBack) { PanelStoreCustomMember.Visible = false; PanelStoreCustomAttachment.Visible = false; TextBoxCustomDescription.Focus(); BindStoreCustomConcept(); BindStoreGroup(); if (ViewState["StoreId"] != null) { this.storeId = Convert.ToInt32(ViewState["StoreId"].ToString()); } BindStoreCustom(); if (this.storeId != 0) { if (storeCustomId != 0) { PanelStoreCustomMember.Visible = true; BindEmployeeRole(); BindStoreCustomMember(); PanelStoreCustomAttachment.Visible = true; BindStoreCustomAttachmentList(); } } } }
protected void ButtonSave_Click(object sender, EventArgs e) { if (Page.IsValid) { LabelError.Text = ""; if (TextBoxCustomStoreId.Text.Length > 0) { int customStoreId = 0; bool isCustomStoreId = int.TryParse(TextBoxCustomStoreId.Text, out customStoreId); if (!isCustomStoreId) { LabelError.Text += "Custome Store Code must be numeric.<br />"; } if (LabelError.Text.Length > 0) { PanelError.Visible = true; return; } } StoreCustom storeCusomLoad = StoreCustom.GetStoreCustomByStoreId(this.storeId, this.companyId); StoreCustom storeCustom = new StoreCustom(); storeCustom.StoreCustomId = storeCusomLoad.StoreCustomId; storeCustom.CustomDescription = (TextBoxCustomDescription.Text.Length == 0) ? "" : TextBoxCustomDescription.Text; storeCustom.CustomStoreId = (TextBoxCustomStoreId.Text.Length == 0) ? 0 : Convert.ToInt32(TextBoxCustomStoreId.Text); storeCustom.StoreId = this.storeId; storeCustom.SPARStoreId = storeCusomLoad.SPARStoreId; storeCustom.Address = (TextBoxAddress.Text.Length == 0) ? "" : TextBoxAddress.Text; storeCustom.GPS = (TextBoxGPS.Text.Length == 0) ? "" : TextBoxGPS.Text; storeCustom.ContactPerson = (TextBoxContactPerson.Text.Length == 0) ? "" : TextBoxContactPerson.Text; storeCustom.ContactNumber = (TextBoxContactNumber.Text.Length == 0) ? "" : TextBoxContactNumber.Text; storeCustom.GroupStore = (CheckBoxGroupStore.Checked) ? 1 : 0; storeCustom.StoreGroupId = Convert.ToInt32(DropDownListStoreGroup.SelectedValue); storeCustom.CatmanStore = (CheckBoxCatmanStore.Checked) ? 1 : 0; storeCustom.Comment = (TextBoxComment.Text.Length == 0) ? "" : TextBoxComment.Text; storeCustom.Email = (TextBoxEmail.Text.Length == 0) ? "" : TextBoxEmail.Text; storeCustom.ModifiedUser = this.Master.LoggedOnAccount; storeCustom.CompanyId = Account.GetAccountByUserName(Page.User.Identity.Name.ToString()).CompanyId; storeCustom.Attachment = "";//UploadAttachment(); try { storeCustom.Save(); int storeCustomId = storeCustom.StoreCustomId; SaveStoreCustomConcept(storeCustomId); Button clickedButton = (Button)sender; switch (clickedButton.ID) { case "ButtonSaveList": //Response.Redirect(String.Format("StoreList.aspx?StoreId={0}", storeCustom.StoreId)); Response.Redirect("StoreList.aspx"); break; case "ButtonSaveNew": Response.Redirect("StoreCustomEdit.aspx"); break; case "ButtonSaveEdit": Response.Redirect(String.Format("StoreCustomEdit.aspx?StoreId={0}", storeCustom.StoreId)); 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; } } }