private void BindInsightSupplier() { try { InsightSupplier insightSupplier = InsightSupplier.GetInsightSupplierByInsightSupplierId(Convert.ToInt32(ViewState["InsightSupplierId"])); TextBoxSupplierName.Text = insightSupplier.SupplierName; TextBoxCustomSupplierId.Text = InsightSupplierMerchandising.GetCustomSupplierByInsightSupplierId(Convert.ToInt32(ViewState["InsightSupplierId"])).CustomSupplierId; DropDownListModelType.ClearSelection(); DropDownListModelType.Items.FindByValue(insightSupplier.ModelTypeId.ToString()).Selected = true; BindModelTypeSecurity(); CloseSupplierAuthorization(); } 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 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 GridViewResult_RowCommand(object sender, GridViewCommandEventArgs e) { try { switch (e.CommandName.ToLower()) { case "removeinsightsupplier": { int insightSupplierId = Convert.ToInt32(e.CommandArgument); InsightSupplierCustomHeader.DeleteInsightSupplierCustomHeaderByInsightSupplierId(insightSupplierId); InsightSupplierContactDistributionLink.DeleteInsightSupplierContactDistributionLinkByInsightSupplierId(insightSupplierId); InsightSupplierContactDistributionOption.DeleteInsightSupplierContactDistributionOptionByInsightSupplierId(insightSupplierId); InsightSupplierContactDistributionModel.DeleteInsightSupplierContactDistributionModelByInsightSupplierId(insightSupplierId); InsightSupplierContactLicense.DeleteInsightSupplierContactLicenseByInsightSupplierId(insightSupplierId); InsightSupplierContactLink.DeleteInsightSupplierContactLinkByInsightSupplierId(insightSupplierId); InsightSupplierMerchandising.DeleteInsightSupplierMerchandisingByInsightSupplierId(insightSupplierId); InsightSupplierMerchSupplierLink.DeleteInsightSupplierMerchSupplierLinkByInsightSupplierId(insightSupplierId); InsightSupplier.DeleteInsightSupplierByInsightSupplierId(insightSupplierId); BindGridViewResultDefault(); break; } } } catch (System.Data.SqlClient.SqlException sqlEx) { } }
private void BindGridViewResultDefault() { string searchValue = "%"; GridViewResult.DataSource = InsightSupplier.GetInsightSupplierListByFilter(searchValue); GridViewResult.DataBind(); }
//private void SaveInsightSupplieMerchSupplierParent(int insightSupplierId) //{ // InsightSupplierMerchSupplierLink iSMSL = new InsightSupplierMerchSupplierLink(); // iSMSL.InsightSupplierId = insightSupplierId; // iSMSL.SupplierParentId = Convert.ToInt32(DropDownListSupplierParentList.SelectedValue); // iSMSL.ModifiedUser = Context.User.Identity.GetUserName(); // iSMSL.Save(); //} private void SaveSupplier() { //if (Page.IsValid) //{ try { LabelError.Text = ""; string modifiedUser = Context.User.Identity.GetUserName(); InsightSupplierMerchandising insightSupplierMerchandising = new InsightSupplierMerchandising(); InsightSupplier.DeleteInsightSupplierMerchandisingByInsightSupplierIdAndSupplierId(Convert.ToInt32(ViewState["InsightSupplierId"]), Convert.ToInt32(ViewState["SupplierId"])); foreach (GridViewRow gridViewRow in GridViewResultSupplier.Rows) { HiddenField hiddenFieldSupplierSupplierId = (HiddenField)gridViewRow.Cells[0].FindControl("HiddenFieldSupplierSupplierId"); HiddenField hiddenFieldSupplierGroupId = (HiddenField)gridViewRow.Cells[1].FindControl("HiddenFieldSupplierGroupId"); HiddenField hiddenFieldSupplierMerchId = (HiddenField)gridViewRow.Cells[2].FindControl("HiddenFieldSupplierMerchId"); CheckBox checkBoxSupplierMerchandisingSelected = (CheckBox)gridViewRow.Cells[4].FindControl("CheckBoxSupplierMerchandisingSelected"); if (checkBoxSupplierMerchandisingSelected.Checked) { insightSupplierMerchandising.InsightSupplierId = Convert.ToInt32(ViewState["InsightSupplierId"]); insightSupplierMerchandising.SupplierParentId = 0; insightSupplierMerchandising.SupplierId = Convert.ToInt32(hiddenFieldSupplierSupplierId.Value); //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.ModifiedUser = modifiedUser; insightSupplierMerchandising.Save(); } else { insightSupplierMerchandising.InsightSupplierId = Convert.ToInt32(ViewState["InsightSupplierId"]); insightSupplierMerchandising.SupplierParentId = 0; insightSupplierMerchandising.SupplierId = Convert.ToInt32(hiddenFieldSupplierSupplierId.Value); //insightSupplierMerchandising.CustomSupplierId = "Reset"; insightSupplierMerchandising.GroupId = Convert.ToInt32(hiddenFieldSupplierGroupId.Value); insightSupplierMerchandising.MerchId = Convert.ToInt32(hiddenFieldSupplierMerchId.Value); insightSupplierMerchandising.IsIncluded = 2;//(RadioButtonInclusion.Checked == true) ? 1 : 2; 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; } //} }
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; } //} }
protected void GridViewLinkedSupplier_RowCommand(object sender, GridViewCommandEventArgs e) { try { switch (e.CommandName.ToLower()) { case "viewauthorization": { ViewState["SupplierId"] = Convert.ToInt32(e.CommandArgument); BindViewAuthorization(0); break; } case "viewcategories": { ViewState["SupplierId"] = Convert.ToInt32(e.CommandArgument); BindSupplierMerchandisingGridView(); break; } case "removeinsightsuppliermerchsupplierlink": { InsightSupplier.DeleteInsightSupplierMerchandisingByInsightSupplierIdAndSupplierId(Convert.ToInt32(ViewState["InsightSupplierId"]), Convert.ToInt32(ViewState["SupplierId"])); InsightSupplierMerchSupplierLink.DeleteInsightSupplierMerchSupplierLinkByInsightSupplierMerchSupplierLinkId(Convert.ToInt32(e.CommandArgument)); BindSupplierList(); BindLinkedSupplierGridView(); BindSupplierMerchandisingGridView(); CloseSupplierAuthorization(); CloseSupplierMerchandisingGridView(); 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 SaveSupplierGroup() { 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); InsightSupplier.DeleteInsightSupplierMerchandisingByInsightSupplierParentId(this.insightSupplierId, Convert.ToInt32(DropDownListSupplierParentList.SelectedValue)); foreach (GridViewRow gridViewRow in GridViewResultSupplierGroup.Rows) { HiddenField hiddenFieldGroupSupplierParentId = (HiddenField)gridViewRow.Cells[0].FindControl("HiddenFieldGroupSupplierParentId"); HiddenField hiddenFieldGroupSupplierId = (HiddenField)gridViewRow.Cells[1].FindControl("HiddenFieldGroupSupplierId"); HiddenField HiddenFieldGroupGroupId = (HiddenField)gridViewRow.Cells[2].FindControl("HiddenFieldGroupGroupId"); HiddenField hiddenFieldGroupMerchId = (HiddenField)gridViewRow.Cells[3].FindControl("HiddenFieldGroupMerchId"); CheckBox checkBoxGroupMerchandisingSelected = (CheckBox)gridViewRow.Cells[5].FindControl("CheckBoxGroupMerchandisingSelected"); if (checkBoxGroupMerchandisingSelected.Checked) { insightSupplierMerchandising.InsightSupplierId = insightSupplierId; insightSupplierMerchandising.SupplierParentId = Convert.ToInt32(hiddenFieldGroupSupplierParentId.Value); insightSupplierMerchandising.SupplierId = Convert.ToInt32(hiddenFieldGroupSupplierId.Value); insightSupplierMerchandising.CustomSupplierId = customSupplierId; insightSupplierMerchandising.GroupId = Convert.ToInt32(HiddenFieldGroupGroupId.Value); insightSupplierMerchandising.MerchId = Convert.ToInt32(hiddenFieldGroupMerchId.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; } } }
protected void Page_Load(object sender, EventArgs e) { this.insightSupplierId = Common.GetEncryptedQueryStringValue("InsightSupplierId", 0); InsightSupplierCustomHeader customHeader = InsightSupplierCustomHeader.GetInsightSupplierCustomHeaderByInsightSupplierId(this.insightSupplierId); this.customHeaderDescription = customHeader.Description; this.insightSupplierCustomHeaderId = customHeader.InsightSupplierCustomHeaderId; LabelPageTitle.Text = String.Format("{0} - CUSTOM", InsightSupplier.GetInsightSupplierByInsightSupplierId(this.insightSupplierId).SupplierName); Page.Form.DefaultFocus = TextBoxCustomDetail.ClientID; Page.Form.DefaultButton = ButtonSaveNew.UniqueID; if (!IsPostBack) { TextBoxCustomDetail.Focus(); ButtonSaveNew.Visible = true; BindCustomType(); BindCustomFrequency(); BindCustomResponsibility(); BindStatus(); if (ViewState["InsightSupplierId"] != null) { this.insightSupplierId = Convert.ToInt32(ViewState["InsightSupplierId"].ToString()); } if (this.insightSupplierId != 0) { BindInsightSupplierCustomHeader(); BindGridViewCustomDetail(); } } }
private void BindInsightSupplier() { try { InsightSupplier insightSupplier = InsightSupplier.GetInsightSupplierByInsightSupplierId(this.insightSupplierId); TextBoxSupplierName.Text = insightSupplier.SupplierName; TextBoxSupplierNameModel.Text = insightSupplier.SupplierNameModel; TextBoxPastelRef.Text = insightSupplier.PastelRef; TextBoxMonths.Text = insightSupplier.Months.ToString(); TextBoxNotes.Text = insightSupplier.Notes; DropDownListSupplierType.Items.FindByValue(insightSupplier.SupplierTypeId.ToString()).Selected = true; //DropDownListOption.Items.FindByValue(insightSupplier.OptionId.ToString()).Selected = true; DropDownListSecurity.Items.FindByValue(insightSupplier.SecurityId.ToString()).Selected = true; //DropDownListLink.Items.FindByValue(insightSupplier.LinkId.ToString()).Selected = true; DropDownListCategoryReduction.Items.FindByValue(insightSupplier.CategoryReductionId.ToString()).Selected = true; DropDownListBuild.Items.FindByValue(insightSupplier.BuildId.ToString()).Selected = true; DropDownListStatus.Items.FindByValue(insightSupplier.StatusId.ToString()).Selected = true; DropDownListCatman.Items.FindByValue(insightSupplier.CatmanId.ToString()).Selected = true; DropDownListCustom.Items.FindByValue(insightSupplier.CustomId.ToString()).Selected = true; DropDownListDaily.Items.FindByValue(insightSupplier.DailyId.ToString()).Selected = true; DropDownListWeekly.Items.FindByValue(insightSupplier.WeeklyId.ToString()).Selected = true; DropDownListPromo.Items.FindByValue(insightSupplier.PromoId.ToString()).Selected = true; List <InsightSupplierModel> ismList = InsightSupplierModel.GetInsightSupplierModelByInsightSupplierId(this.insightSupplierId); foreach (ListItem listItem in CheckBoxListModel.Items) { foreach (InsightSupplierModel ism in ismList) { if (listItem.Value == ism.ModelId.ToString()) { listItem.Selected = true; } } } List <InsightSupplierOption> isoList = InsightSupplierOption.GetInsightSupplierOptionByInsightSupplierId(this.insightSupplierId); foreach (ListItem listItem in CheckBoxListOption.Items) { foreach (InsightSupplierOption iso in isoList) { if (listItem.Value == iso.OptionId.ToString()) { listItem.Selected = true; } } } List <InsightSupplierLink> islList = InsightSupplierLink.GetInsightSupplierLinkByInsightSupplierId(this.insightSupplierId); foreach (ListItem listItem in CheckBoxListLink.Items) { foreach (InsightSupplierLink isl in islList) { if (listItem.Value == isl.LinkId.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 ButtonSearch_Click(object sender, EventArgs e) { GridViewResult.DataSource = InsightSupplier.GetInsightSupplierListByFilter("%" + TextBoxSearch.Text + "%"); GridViewResult.DataBind(); }
protected async void ButtonValidateLinks_Click(object sender, EventArgs e) { bool hasError = false; HttpClient client = new HttpClient(); string apiAddress = ConfigurationManager.AppSettings["WebApiUrl"].ToString(); List <SupplierNotification> supplierNotificationList = new List <SupplierNotification>(); SupplierNotification supplierNotification = new SupplierNotification(); int optionId = Convert.ToInt32(DropDownListOption.SelectedValue); if (Convert.ToInt32(DropDownListInsightSupplier.SelectedValue) != Convert.ToInt32(allId)) { //string supplierDirectoryPath = "C:\\Development\\SPARInsightManagement\\Trunk\\Source\\Document\\SupplierLinks\\3M";//insightSupplier.SupplierDirectoryPath; //string supplierFolder = "3M";//insightSupplier.SupplierFolder; InsightSupplier insightSupplier = InsightSupplier.GetInsightSupplierByInsightSupplierId(Convert.ToInt32(DropDownListInsightSupplier.SelectedValue)); supplierNotification = new SupplierNotification(); supplierNotification.InsightSupplierId = insightSupplier.InsightSupplierId; supplierNotification.OptionId = optionId; supplierNotification.FolderPath = Path.Combine(insightSupplier.SupplierDirectoryPath, insightSupplier.SupplierFolder); supplierNotificationList = new List <SupplierNotification>(); supplierNotificationList.Add(supplierNotification); string supplierNotificationJSON = JsonConvert.SerializeObject(supplierNotificationList, Formatting.Indented); HttpContent httpContent = new StringContent(supplierNotificationJSON, System.Text.Encoding.UTF8, "application/json"); var response = await client.PostAsync(apiAddress, httpContent); if (response.IsSuccessStatusCode) { string responseString = await response.Content.ReadAsStringAsync(); List <SupplierNotification> supplierNotificationReturnList = JsonConvert.DeserializeObject <List <SupplierNotification> >(responseString); Guid batchId = Guid.NewGuid(); foreach (SupplierNotification supplierNotificationReturn in supplierNotificationReturnList) { SupplierNotification SupplierNotification = new SupplierNotification(); supplierNotification.InsightSupplierId = supplierNotificationReturn.InsightSupplierId; supplierNotification.OptionId = supplierNotificationReturn.OptionId; supplierNotification.FolderPath = supplierNotificationReturn.FolderPath; supplierNotification.File = supplierNotificationReturn.File; supplierNotification.IsValid = supplierNotificationReturn.IsValid; supplierNotification.Note = supplierNotificationReturn.Note; supplierNotification.FileModifiedDate = supplierNotificationReturn.FileModifiedDate; supplierNotification.FileSize = supplierNotificationReturn.FileSize; supplierNotification.BatchId = batchId; supplierNotification.ModifiedUser = Context.User.Identity.GetUserName(); supplierNotification.Save(); if (supplierNotificationReturn.IsValid == false) { hasError = true; } } if (hasError == true) { GridViewResult.DataSource = SupplierNotification.GetSupplierNotificationListByBatchId(batchId); GridViewResult.DataBind(); LabelBatch.Text = String.Format("{0} - {1}", "Batch", batchId); ButtonEmailLinks.Text = String.Format("{0}", "Email below Batch"); } else { LabelBatch.Text = String.Format("{0} - {1}", "Batch", batchId); ButtonEmailLinks.Text = String.Format("{0}", "Email below Batch"); ButtonEmailLinks.Enabled = true; } } } else { supplierNotificationList = new List <SupplierNotification>(); IEnumerable <InsightSupplier> insightSupplierList = InsightSupplier.GetInsightSupplierList(); foreach (InsightSupplier insightSupplier in insightSupplierList) { supplierNotification = new SupplierNotification(); supplierNotification.InsightSupplierId = insightSupplier.InsightSupplierId; supplierNotification.OptionId = optionId; supplierNotification.FolderPath = Path.Combine(insightSupplier.SupplierDirectoryPath, insightSupplier.SupplierFolder); supplierNotificationList.Add(supplierNotification); } string supplierNotificationJSON = JsonConvert.SerializeObject(supplierNotificationList, Formatting.Indented); HttpContent httpContent = new StringContent(supplierNotificationJSON, System.Text.Encoding.UTF8, "application/json"); var response = await client.PostAsync(apiAddress, httpContent); if (response.IsSuccessStatusCode) { string responseString = await response.Content.ReadAsStringAsync(); List <SupplierNotification> supplierNotificationReturnList = JsonConvert.DeserializeObject <List <SupplierNotification> >(responseString); Guid batchId = Guid.NewGuid(); foreach (SupplierNotification supplierNotificationReturn in supplierNotificationReturnList) { SupplierNotification SupplierNotification = new SupplierNotification(); supplierNotification.InsightSupplierId = supplierNotificationReturn.InsightSupplierId; supplierNotification.OptionId = supplierNotificationReturn.OptionId; supplierNotification.FolderPath = supplierNotificationReturn.FolderPath; supplierNotification.File = supplierNotificationReturn.File; supplierNotification.IsValid = supplierNotificationReturn.IsValid; supplierNotification.Note = supplierNotificationReturn.Note; supplierNotification.FileModifiedDate = supplierNotificationReturn.FileModifiedDate; supplierNotification.FileSize = supplierNotificationReturn.FileSize; supplierNotification.BatchId = batchId; supplierNotification.ModifiedUser = Context.User.Identity.GetUserName(); supplierNotification.Save(); if (supplierNotificationReturn.IsValid == false) { hasError = true; } } if (hasError == true) { GridViewResult.DataSource = SupplierNotification.GetSupplierNotificationListByBatchId(batchId); GridViewResult.DataBind(); } else { LabelBatch.Text = String.Format("{0} - {1}", "Batch", batchId); ButtonEmailLinks.Text = String.Format("{0} - {1}", "Email Batch", batchId); ButtonEmailLinks.Enabled = true; } } } }
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 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 = ""; 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 />"); } } //} }