protected void ButtonSearch_Click(object sender, EventArgs e) { GridViewResult.DataSource = ClaimSkuSubCategorySupplier.GetClaimSkuSubCategorySupplierListByClaimSupplierId(Convert.ToInt32(DropDownListSupplier.SelectedValue)); GridViewResult.DataBind(); ButtonSaveList.Visible = GridViewResult.Rows.Count > 0; }
protected void ButtonSave_Click(object sender, EventArgs e) { if (Page.IsValid) { LabelError.Text = ""; try { int companyId = Account.GetAccountByUserName(Page.User.Identity.Name.ToString()).CompanyId; ClaimSkuSubCategorySupplier.DeleteClaimSkuSubCategorySupplierByClaimSupplierId(Convert.ToInt32(DropDownListSupplier.SelectedValue)); ClaimSkuSubCategorySupplier claimSkuSubCategorySupplier = null; foreach (GridViewRow gridViewRow in GridViewResult.Rows) { claimSkuSubCategorySupplier = new ClaimSkuSubCategorySupplier(); HiddenField hiddenFieldStoreCategoryId = (HiddenField)gridViewRow.Cells[0].FindControl("HiddenFieldClaimSkuSubCategoryId"); CheckBox checkBoxLink = (CheckBox)gridViewRow.Cells[7].FindControl("CheckBoxClaimSkuSubCategoryId"); if (checkBoxLink.Checked) { claimSkuSubCategorySupplier.ClaimSkuSubCategorySupplierId = 0; claimSkuSubCategorySupplier.ClaimSkuSubCategoryId = Convert.ToInt32(hiddenFieldStoreCategoryId.Value); claimSkuSubCategorySupplier.ClaimSupplierId = (Convert.ToInt32(DropDownListSupplier.SelectedValue)); claimSkuSubCategorySupplier.LocationId = 0; claimSkuSubCategorySupplier.ModifiedUser = this.Master.LoggedOnAccount; claimSkuSubCategorySupplier.Save(); } } Button clickedButton = (Button)sender; switch (clickedButton.ID) { case "ButtonSaveList": Response.Redirect("ClaimSupplierSkuEdit.aspx"); 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 GridViewResult_RowDataBound(object sender, GridViewRowEventArgs e) { GridViewRow currentRow = e.Row; if (currentRow.RowIndex == 0) { previousGridViewResult = (Object)currentRow.DataItem; } if (currentRow.RowIndex > 0) { ClaimSkuSubCategorySupplier previousStoreCategory = (ClaimSkuSubCategorySupplier)previousGridViewResult; ClaimSkuSubCategorySupplier currentStoreCategory = (ClaimSkuSubCategorySupplier)currentRow.DataItem; if (previousStoreCategory.ClaimSkuCategory == currentStoreCategory.ClaimSkuCategory) { currentRow.Cells[2].ForeColor = System.Drawing.Color.White; currentRow.Cells[2].Text = String.Empty; } previousGridViewResult = (Object)currentStoreCategory; } }