protected void ButtonSave_Click(object sender, EventArgs e) { //if (Page.IsValid) //{ try { LabelError.Text = ""; string modifiedUser = Context.User.Identity.GetUserName(); InsightSupplierMerchandising insightSupplierMerchandising = new InsightSupplierMerchandising(); InsightSupplier.DeleteInsightSupplierMerchandisingByInsightSupplierId(this.insightSupplierId); HiddenField hiddenFieldCustomSupplierId = null; foreach (GridViewRow gridViewRow in GridViewResult.Rows) { hiddenFieldCustomSupplierId = (HiddenField)gridViewRow.Cells[1].FindControl("HiddenFieldCustomSupplierId"); HiddenField hiddenFieldSupplierGroupId = (HiddenField)gridViewRow.Cells[1].FindControl("HiddenFieldCustomGroupId"); HiddenField hiddenFieldSupplierMerchId = (HiddenField)gridViewRow.Cells[2].FindControl("HiddenFieldCustomMerchId"); CheckBox checkBoxCustomMerchandisingSelected = (CheckBox)gridViewRow.Cells[4].FindControl("CheckBoxCustomMerchandisingSelected"); if (checkBoxCustomMerchandisingSelected.Checked) { insightSupplierMerchandising.InsightSupplierId = this.insightSupplierId; insightSupplierMerchandising.SupplierParentId = 0; insightSupplierMerchandising.SupplierId = 0; //insightSupplierMerchandising.CustomSupplierId = TextBoxCustomSupplierId.Text; insightSupplierMerchandising.GroupId = Convert.ToInt32(hiddenFieldSupplierGroupId.Value); insightSupplierMerchandising.MerchId = Convert.ToInt32(hiddenFieldSupplierMerchId.Value); insightSupplierMerchandising.IsIncluded = 1; //(RadioButtonInclusion.Checked == true) ? 1 : 2; insightSupplierMerchandising.IsCustom = 2; // 1 - Insight Supplier with Supplier; 2 - Insight Supplier with Custom Supplier insightSupplierMerchandising.ModifiedUser = modifiedUser; insightSupplierMerchandising.Save(); } } InsightSupplierMerchandising.UpdateInsightSupplierMerchandisingCustomSupplierIdByInsightSupplierId(this.insightSupplierId, (hiddenFieldCustomSupplierId.Value.Length > 0) ? hiddenFieldCustomSupplierId.Value : "0"); LabelError.Text = "Save Successful."; PanelError.Visible = true; BindGridViewResult(); } 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 SaveCustom() { if (Page.IsValid) { try { LabelError.Text = ""; string modifiedUser = Context.User.Identity.GetUserName(); string customSupplierId = "100" + this.insightSupplierId.ToString(); InsightSupplierMerchandising insightSupplierMerchandising = new InsightSupplierMerchandising(); InsightSupplier.DeleteInsightSupplierMerchandisingByInsightSupplierId(this.insightSupplierId); foreach (GridViewRow gridViewRow in GridViewResultCustom.Rows) { HiddenField hiddenFieldCustomSupplierId = (HiddenField)gridViewRow.Cells[0].FindControl("HiddenFieldCustomSupplierId"); HiddenField hiddenFieldCustomGroupId = (HiddenField)gridViewRow.Cells[1].FindControl("HiddenFieldCustomGroupId"); HiddenField hiddenFieldCustomMerchId = (HiddenField)gridViewRow.Cells[2].FindControl("HiddenFieldCustomMerchId"); CheckBox checkBoxCustomMerchandisingSelected = (CheckBox)gridViewRow.Cells[4].FindControl("CheckBoxCustomMerchandisingSelected"); if (checkBoxCustomMerchandisingSelected.Checked) { insightSupplierMerchandising.InsightSupplierId = insightSupplierId; insightSupplierMerchandising.SupplierParentId = 0; insightSupplierMerchandising.SupplierId = 0; insightSupplierMerchandising.CustomSupplierId = customSupplierId; insightSupplierMerchandising.GroupId = Convert.ToInt32(hiddenFieldCustomGroupId.Value); insightSupplierMerchandising.MerchId = Convert.ToInt32(hiddenFieldCustomMerchId.Value); insightSupplierMerchandising.ModifiedUser = modifiedUser; insightSupplierMerchandising.Save(); } } } 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; } } }