protected void ButtonSave_Click(object sender, EventArgs e) { if (Page.IsValid) { InsightSupplier insightSupplier = new InsightSupplier(); insightSupplier.InsightSupplierId = this.insightSupplierId; insightSupplier.SupplierName = TextBoxSupplierName.Text; insightSupplier.SupplierNameModel = TextBoxSupplierNameModel.Text; insightSupplier.PastelRef = (TextBoxPastelRef.Text.Length > 0) ? TextBoxPastelRef.Text : ""; insightSupplier.Months = (TextBoxMonths.Text.Length > 0) ? Convert.ToDouble(TextBoxMonths.Text) : 0; insightSupplier.Notes = (TextBoxNotes.Text.Length > 0) ? TextBoxNotes.Text : ""; insightSupplier.ModifiedUser = Context.User.Identity.GetUserName(); insightSupplier.SupplierTypeId = Convert.ToInt32(DropDownListSupplierType.SelectedValue); insightSupplier.SecurityId = Convert.ToInt32(DropDownListSecurity.SelectedValue); insightSupplier.CategoryReductionId = Convert.ToInt32(DropDownListCategoryReduction.SelectedValue); insightSupplier.BuildId = Convert.ToInt32(DropDownListBuild.SelectedValue); insightSupplier.StatusId = Convert.ToInt32(DropDownListStatus.SelectedValue); insightSupplier.CatmanId = Convert.ToInt32(DropDownListCatman.SelectedValue); insightSupplier.CustomId = Convert.ToInt32(DropDownListCustom.SelectedValue); insightSupplier.DailyId = Convert.ToInt32(DropDownListDaily.SelectedValue); insightSupplier.WeeklyId = Convert.ToInt32(DropDownListWeekly.SelectedValue); insightSupplier.PromoId = Convert.ToInt32(DropDownListPromo.SelectedValue); try { insightSupplier.Save(); int insightSupplierId = insightSupplier.InsightSupplierId; SaveInsightSupplierModel(insightSupplierId); SaveInsightSupplierOption(insightSupplierId); SaveInsightSupplierLink(insightSupplierId); Button clickedButton = (Button)sender; switch (clickedButton.ID) { case "ButtonSave": Response.Redirect(String.Format("InsightSupplierList.aspx?SupplierName={0}", insightSupplier.SupplierName)); break; case "ButtonSaveNew": Response.Redirect("InsightSupplierEdit.aspx"); break; case "ButtonSaveEdit": //Response.Redirect(String.Format("InsightSupplierEdit.aspx?InsightSupplierId={0}", insightSupplierId)); Response.Redirect(String.Format("InsightSupplierCategoryEdit.aspx?InsightSupplierId={0}&SupplierTypeId={1}", insightSupplierId, Convert.ToInt32(DropDownListSupplierType.SelectedValue))); break; } } catch (System.Data.SqlClient.SqlException sqlEx) { LabelError.Text = ""; for (int i = 0; i < sqlEx.Errors.Count; i++) { ErrorMessage.Text += (sqlEx.Errors[i].Message + "<br />"); } } } }
protected void ButtonSaveAddSupplier_Click(object sender, EventArgs e) { if (Page.IsValid) { ErrorMessage.Text = ""; //if (this.insightSupplierId != 0) if (Convert.ToInt32(ViewState["InsightSupplierId"]) != 0) { try { SaveInsightSupplieMerchSupplier(Convert.ToInt32(ViewState["InsightSupplierId"])); BindSupplierList(); BindLinkedSupplierGridView(); BindModelTypeSecurity(); //SetPageLayout(); } catch (System.Data.SqlClient.SqlException sqlEx) { LabelError.Text = ""; for (int i = 0; i < sqlEx.Errors.Count; i++) { ErrorMessage.Text += (sqlEx.Errors[i].Message + "<br />"); } } } else { InsightSupplier insightSupplier = new InsightSupplier(); insightSupplier.InsightSupplierId = Convert.ToInt32(ViewState["InsightSupplierId"]); insightSupplier.SupplierName = TextBoxSupplierName.Text; insightSupplier.ModelTypeId = Convert.ToInt32(DropDownListModelType.SelectedValue); insightSupplier.ModifiedUser = Context.User.Identity.GetUserName(); try { insightSupplier.Save(); this.insightSupplierId = insightSupplier.InsightSupplierId; ViewState["InsightSupplierId"] = this.insightSupplierId; SaveInsightSupplieMerchSupplier(insightSupplierId); BindSupplierList(); BindLinkedSupplierGridView(); BindModelTypeSecurity(); //SetPageLayout(); } catch (System.Data.SqlClient.SqlException sqlEx) { LabelError.Text = ""; for (int i = 0; i < sqlEx.Errors.Count; i++) { ErrorMessage.Text += (sqlEx.Errors[i].Message + "<br />"); } } } CloseSupplierAuthorization(); CloseSupplierMerchandisingGridView(); } }
protected void ButtonSave_Click(object sender, EventArgs e) { if (Page.IsValid) { bool hasError = false; LabelError.Text = ""; InsightSupplier insightSupplier = new InsightSupplier(); if (Convert.ToInt32(DropDownListSecurity.SelectedValue) == 1) //Yes { if (Convert.ToInt32(DropDownListSecurityLevel.SelectedValue) == 0) //No Selection { LabelError.Text = "Security Level is required."; hasError = true; } else { insightSupplier.SecurityLevelId = Convert.ToInt32(DropDownListSecurityLevel.SelectedValue); } } else { insightSupplier.SecurityLevelId = 0;//Reset } if (hasError == true) { PanelError.Visible = true; return; } insightSupplier.InsightSupplierId = this.insightSupplierId; insightSupplier.SupplierNameModel = TextBoxSupplierNameModel.Text; insightSupplier.PastelRef = (TextBoxPastelRef.Text.Length > 0) ? TextBoxPastelRef.Text : ""; insightSupplier.Months = (TextBoxMonths.Text.Length > 0) ? Convert.ToDouble(TextBoxMonths.Text) : 0; insightSupplier.Notes = (TextBoxNotes.Text.Length > 0) ? TextBoxNotes.Text : ""; insightSupplier.ModifiedUser = Context.User.Identity.GetUserName(); insightSupplier.SecurityId = Convert.ToInt32(DropDownListSecurity.SelectedValue); insightSupplier.CategoryReductionId = Convert.ToInt32(DropDownListCategoryReduction.SelectedValue); insightSupplier.BuildId = Convert.ToInt32(DropDownListBuild.SelectedValue); insightSupplier.StatusId = Convert.ToInt32(DropDownListStatus.SelectedValue); insightSupplier.CatmanId = Convert.ToInt32(DropDownListCatman.SelectedValue); insightSupplier.CustomId = Convert.ToInt32(DropDownListCustom.SelectedValue); insightSupplier.FieldForceId = Convert.ToInt32(DropDownListFieldForce.SelectedValue); insightSupplier.DailyId = Convert.ToInt32(DropDownListDaily.SelectedValue); insightSupplier.WeeklyId = Convert.ToInt32(DropDownListWeekly.SelectedValue); insightSupplier.PromoId = Convert.ToInt32(DropDownListPromo.SelectedValue); insightSupplier.UpdateDetail = true; try { insightSupplier.Save(); int insightSupplierId = insightSupplier.InsightSupplierId; //SaveInsightSupplierModel(insightSupplierId); //SaveInsightSupplierOption(insightSupplierId); //SaveInsightSupplierLink(insightSupplierId); Button clickedButton = (Button)sender; switch (clickedButton.ID) { case "ButtonSave": Response.Redirect(String.Format("InsightSupplierHeaderEdit.aspx?InsightSupplierId={0}", insightSupplierId)); break; } } catch (System.Data.SqlClient.SqlException sqlEx) { LabelError.Text = ""; for (int i = 0; i < sqlEx.Errors.Count; i++) { ErrorMessage.Text += (sqlEx.Errors[i].Message + "<br />"); } } } }
protected void ButtonSave_Click(object sender, EventArgs e) { //if (Page.IsValid) //{ bool hasError = false; LabelError.Text = ""; PanelError.Visible = false; if (TextBoxSupplierName.Text.Length == 0) { LabelError.Text += " Name is required."; hasError = true; } if (Convert.ToInt32(DropDownListModelType.SelectedValue) == 0) { LabelError.Text += " Model Type is required."; hasError = true; } if (hasError == true) { PanelError.Visible = true; return; } InsightSupplier insightSupplier = new InsightSupplier(); insightSupplier.InsightSupplierId = Convert.ToInt32(ViewState["InsightSupplierId"]); insightSupplier.SupplierName = TextBoxSupplierName.Text; insightSupplier.ModelTypeId = Convert.ToInt32(DropDownListModelType.SelectedValue); insightSupplier.ModifiedUser = Context.User.Identity.GetUserName(); try { insightSupplier.Save(); int insightSupplierId = insightSupplier.InsightSupplierId; if (DropDownListModelType.SelectedValue != "4") { SaveSupplier(); } InsightSupplierMerchandising.UpdateInsightSupplierMerchandisingCustomSupplierIdByInsightSupplierId(insightSupplierId, (TextBoxCustomSupplierId.Text.Length > 0) ? TextBoxCustomSupplierId.Text : "0"); Button clickedButton = (Button)sender; switch (clickedButton.ID) { case "ButtonSave": CloseSupplierAuthorization(); CloseSupplierMerchandisingGridView(); if (Convert.ToInt32(DropDownListModelType.SelectedValue) == 4) { ViewState["InsightSupplierId"] = insightSupplierId; BindModelTypeSecurity(); } //Response.Redirect(String.Format("InsightSupplierList.aspx?SupplierName={0}", insightSupplier.SupplierName)); break; case "ButtonSaveNew": Response.Redirect("InsightSupplierHeaderEdit.aspx"); break; } } catch (System.Data.SqlClient.SqlException sqlEx) { LabelError.Text = ""; for (int i = 0; i < sqlEx.Errors.Count; i++) { ErrorMessage.Text += (sqlEx.Errors[i].Message + "<br />"); } } //} }