private bool retrieveEntity() { token = (Token)Session["token"]; survey = surveyCRUD.readById(token.SubjectKey); if (survey != null) { supplier = supplierCRUD.readById(survey.SupplierMasterKey); if (supplier != null) { SessionObject soSupplier = new SessionObject(); supplier.SupplierSurvey = survey; soSupplier.Content = supplier; soSupplier.Status = "forUpdate"; Session["supplierObject"] = soSupplier; return(true); } } return(false); }
public void updateByID(object sender, CommandEventArgs e) { long id = long.Parse((string)e.CommandArgument); SupplierSurvey survey = new SupplierSurvey(); survey = surveyCRUD.readById(id); if (survey != null) { supplier.SupplierSurvey = survey; SessionObject so = new SessionObject(); so.Content = supplier; so.Status = "forUpdate"; Session["supplierObject"] = so; uscSurveyForm.load(); panelPopup.Visible = true; } else { Navigator.goToPage("~/Error.aspx", "ERROR:Could not retrieve survey with id = " + id); } }
public bool save() { SupplierSurvey survey = new SupplierSurvey(); survey.SupplierMasterKey = supplier.Id; survey.StreetAddress = txtAddress.Text; survey.City = txtCity.Text; survey.State = txtState.Text; survey.ZipCode = txtZip.Text; survey.Website = txtWebsite.Text; survey.LastSurvey = DateTime.Now; if (lblNDARec.Text.Trim() != "") { survey.NDARec = DateTime.Parse(lblNDARec.Text); } survey.PrimaryBusiness = txtPrimaryBusiness.Text; survey.SecundaryBusiness = txtSecundaryBusiness.Text; survey.UnionYN = radUnion.Checked; survey.Local = txtLocal.Text; survey.ContractExpiration = txtContractExpiration.Text; survey.CurrentCapacity = txtCurrentCapacity.Text; survey.ManufacturingMetod = txtManufacturingMethod.Text; survey.ToolingNewInHouseYN = chkNewInHouseManufacture.Checked; survey.ToolingNewOutsourcedYN = chkNewOutsourced.Checked; survey.ToolingInHouseYN = chkRepairInHouse.Checked; survey.ToolingOutsourcedYN = chkRepairOutsource.Checked; survey.Notes = txtNotes.Text; ConnectionManager CM = new ConnectionManager(); Data_Base_MNG.SQL DM = CM.getDataManager(); /*Begin Transaction*/ DM.Open_Connection("Survey Save"); certification_CRUD.deleteByParentId(supplier.SupplierSurvey.Id, ref DM); foreach (SupplierSurveyCertification certification in supplier.SupplierSurvey.Certifications) { certification.SupplierSurveyKey = supplier.SupplierSurvey.Id; certification_CRUD.create(certification, ref DM); } industries_CRUD.deleteByParentId(supplier.SupplierSurvey.Id, ref DM); foreach (SupplierSurveyIndustriesSupplied industrie in supplier.SupplierSurvey.IndustriesSupplied) { industrie.SupplierSurveyKey = supplier.SupplierSurvey.Id; industries_CRUD.create(industrie, ref DM); } forecast_CRUD.deleteByParentId(supplier.SupplierSurvey.Id, ref DM); foreach (SupplierSurveyForecastSales forecastSale in supplier.SupplierSurvey.ForecastSales) { forecast_CRUD.create(forecastSale, ref DM); } SupplierSurveyContacts executive = uscContactExecutive.getEntity(); executive.SupplierSurveyKey = supplier.SupplierSurvey.Id; if (supplier.SupplierSurvey.ContactExecutive != null) { contacts_CRUD.update(executive, ref DM); } else { contacts_CRUD.create(executive, ref DM); } SupplierSurveyContacts sales = uscContactSales.getEntity(); sales.SupplierSurveyKey = supplier.SupplierSurvey.Id; if (supplier.SupplierSurvey.ContactSales != null) { contacts_CRUD.update(sales, ref DM); } else { contacts_CRUD.create(sales, ref DM); } SupplierSurveyContacts quality = uscContactQuality.getEntity(); quality.SupplierSurveyKey = supplier.SupplierSurvey.Id; if (supplier.SupplierSurvey.ContactQuality != null) { contacts_CRUD.update(quality, ref DM); } else { contacts_CRUD.create(quality, ref DM); } SupplierSurveyContacts support = uscContactCustomerSupport.getEntity(); support.SupplierSurveyKey = supplier.SupplierSurvey.Id; if (supplier.SupplierSurvey.ContactCustomerSupport != null) { contacts_CRUD.update(support, ref DM); } else { contacts_CRUD.create(support, ref DM); } SupplierSurveyContacts afterHours = uscContactAfterHours.getEntity(); afterHours.SupplierSurveyKey = supplier.SupplierSurvey.Id; if (supplier.SupplierSurvey.ContactAfterHoursContact != null) { contacts_CRUD.update(afterHours, ref DM); } else { contacts_CRUD.create(afterHours, ref DM); } if (lblMode.Text == "New") { if (!survey_CRUD.create(survey, ref DM)) { Navigator.goToPage("~/Error.aspx", "ERROR:" + survey_CRUD.ErrorMessage); return(false); } //else //{ // BOM bom = new BOM(); // bom.SifId = 21; // bomCRUD bomCrud = new bomCRUD(); // if (!bomCrud.create(bom)) // { // Navigator.goToPage("~/Error.aspx",""); // } //} } else if (lblMode.Text == "Update") { survey.Id = long.Parse(lblID.Text); if (!survey_CRUD.update(survey, ref DM)) { Navigator.goToPage("~/Error.aspx", "ERROR:" + survey_CRUD.ErrorMessage); return(false); } } DM.CommitTransaction(); DM.Close_Open_Connection(); if (DM.ErrorOccur) { Navigator.goToPage("~/Error.aspx", "ERROR:" + DM.Error_Mjs); return(false); } return(true); }
protected void btnSendSurvey_Click(object sender, EventArgs e) { if (supplier.ContactEmail.Trim() != txtEmail.Text.Trim()) { SupplierCRUD supplierCRUD = new SupplierCRUD(); supplier.ContactEmail = txtEmail.Text.Trim(); if (!supplierCRUD.update(supplier)) { Navigator.goToPage("~/Error.aspx", "ERROR:" + supplierCRUD.ErrorMessage); return; } } SupplierSurveyCRUD surveyCRUD = new SupplierSurveyCRUD(); SupplierSurvey survey = new SupplierSurvey(); survey.SupplierMasterKey = supplier.Id; survey.SentToVendor = DateTime.Now; supplier.SupplierSurvey = survey; ConnectionManager CM = new ConnectionManager(); Data_Base_MNG.SQL DM = CM.getDataManager(); /*Begin Transaction*/ DM.Open_Connection("Survey Save"); string idGenerated = surveyCRUD.createAndReturnIdGenerated(survey, ref DM); if (!surveyCRUD.ErrorOccur) { TokenCRUD token_CRUD = new TokenCRUD(); Token token = new Token(); token.Subject = "SURVEY"; token.SubjectKey = long.Parse(idGenerated); token.TokenNumber = MD5HashGenerator.GenerateKey(DateTime.Now); if (token_CRUD.create(token, ref DM)) { Email NewMail = new Email(); MailMessage Message = new MailMessage(); Message.From = new MailAddress("*****@*****.**", "*****@*****.**"); Message.To.Add(new MailAddress(supplier.ContactEmail.ToString())); Message.Subject = "Survey"; Message.IsBodyHtml = true; Message.BodyEncoding = System.Text.Encoding.UTF8; //Message.Body = "Aqui va el link con el token= " + " <a href:\"http://localhost:29724/APQM/Vendor/RFQ.aspx?token=" + token.TokenNumber + "\">Link</a>"; //Message.Body = "Aqui va el link con el token= " + " <a href:\"http://www.google.com\">Google</a>"; string strEmailContent = "Dear Potential Supplier," + Environment.NewLine + "Please click the following link to fill out our supplier survey form. Please fill out as completely as possible. Once we have received your completed survey, a representative will contact you to discuss the next steps." + Environment.NewLine + Environment.NewLine + "http://" + Request.Url.Authority + Request.ApplicationPath + "/Vendor/Survey.aspx?token=" + token.TokenNumber + Environment.NewLine + Environment.NewLine + "Thank you for your time. We look forward to hearing from you." + Environment.NewLine + Environment.NewLine + "Sincerely," + Environment.NewLine + Environment.NewLine + "The Capsonic Advanced Purchasing Team"; AlternateView htmlView = AlternateView.CreateAlternateViewFromString(strEmailContent); Message.AlternateViews.Add(htmlView); try { NewMail.SendMail(Message); } catch { DM.RollBack(); Navigator.goToPage("~/Error.aspx", "ERROR:Could not send email to: " + supplier.ContactEmail.ToString()); return; } } else { Navigator.goToPage("~/Error.aspx", "ERROR:" + token_CRUD.ErrorMessage); return; } } else { Navigator.goToPage("~/Error.aspx", "ERROR:" + surveyCRUD.ErrorMessage); return; } DM.CommitTransaction(); DM.Close_Open_Connection(); if (DM.ErrorOccur) { Navigator.goToPage("~/Error.aspx", "ERROR:" + DM.Error_Mjs); return; } supplier = null; Ok_Click(this, e); }