private void btnDelete_Click(object sender, EventArgs e) { if (CompanyID != Convert.ToInt32(System.Configuration.ConfigurationSettings.AppSettings.Get("OryxCompanyID"))) { //Delete Company BPCompanies bp = new BPCompanies(); BECompanies.tbl_CompaniesRow Company; DSCompanies = bp.SelectCompaniesByID(CompanyID); Company = DSCompanies.tbl_Companies.FindByCompanyID(CompanyID); Company.Delete(); bp.Update(DSCompanies); //Delete Company Aliases BPCompanyAliases bpAliases = new BPCompanyAliases(); DSCompanies = bpAliases.SelectCompanyAliasesByCompanyID(CompanyID); foreach (BECompanies.tbl_CompanyAliasesRow row in DSCompanies.tbl_CompanyAliases.Rows) { row.Delete(); } bpAliases.Update(DSCompanies); //Delete Company Emails BPCompanyEmails bpEmails = new BPCompanyEmails(); DSCompanies = bpEmails.SelectCompanyEmailsByCompanyID(CompanyID); foreach (BECompanies.tbl_CompanyEmailsRow row in DSCompanies.tbl_CompanyEmails.Rows) { row.Delete(); } bpEmails.Update(DSCompanies); Response.Redirect("BrowseCompanies.aspx"); } else { //TODO: Insert Message here stating that Oryx company Cannot be deleted, please see your web master } }
private void btnSubmit_ServerClick(object sender, EventArgs e) { if (chkCompanyRentalInventory.Checked) { pnlColumnAliases.Visible = false; } BPCompanies bp = new BPCompanies(); BECompanies.tbl_CompaniesRow Company; DSCompanies = new BECompanies(); if (CompanyID == 0) { // Add new Company Company = DSCompanies.tbl_Companies.Newtbl_CompaniesRow(); } else { // Edit a Company DSCompanies = bp.SelectCompaniesByID(CompanyID); Company = DSCompanies.tbl_Companies.FindByCompanyID(CompanyID); } //all content to be updated/inserted between here Company.CompanyName = txtCompanyName.Text; ImageWizard ddlCompanyImage = Page.FindControl("ddlCompanyImage") as ImageWizard; if (ddlCompanyImage.SelectedImage > 0) { Company.CompanyImageID = Convert.ToInt32(ddlCompanyImage.SelectedImage); } else { Company.SetCompanyImageIDNull(); } Company.CompanyDescription = txtCompanyDescription.Text + " "; Company.CompanyAddress1 = txtCompanyAddress1.Text; Company.CompanyAddress2 = txtCompanyAddress2.Text; Company.CompanyCity = txtCompanyCity.Text; Company.CompanyProvince = txtCompanyProvince.Text; Company.CompanyCountry = txtCompanyCountry.Text; Company.CompanyPostalCode = txtCompanyPostalCode.Text; Company.CompanyPhone = txtCompanyPhone.Text; Company.CompanyFax = txtCompanyFax.Text; Company.CompanyActive = chkCompanyActive.Checked; if (CompanyID != Convert.ToInt32(System.Configuration.ConfigurationSettings.AppSettings.Get("OryxCompanyID"))) { Company.CompanyRentalInventory = chkCompanyRentalInventory.Checked; } else { Company.CompanyRentalInventory = true; } Company.DateModified = DateTime.Now; Company.ModifiedByAdminID = Convert.ToInt32(OryxUser.OryxIdentity.MemberID); //all content to be updated/inserted between here if (CompanyID == 0) { //Add new Application Category Company.DateCreated = DateTime.Now; DSCompanies.tbl_Companies.Addtbl_CompaniesRow(Company); } bp.Update(DSCompanies); //CreateResizedImage(BEImages DSImages, int ImageID, string prefix, int width, int height, Page page) if (!Company.IsCompanyImageIDNull()) { MWUtility.CreateResizedImage(Company.CompanyImageID, "l", "", imageSize, 0, this); } if (chkCompanyRentalInventory.Checked && CompanyID != Convert.ToInt32(System.Configuration.ConfigurationSettings.AppSettings["OryxCompanyID"])) { BPCompanyAliases bpAliases = new BPCompanyAliases(); //delete all of the company Aliases incase they have more aliases than Oryx, otherwise those extra columns would not get over-ridden. DSNewCompanyAliases = bpAliases.SelectCompanyAliasesByCompanyID(CompanyID); if (DSNewCompanyAliases.tbl_CompanyAliases.Count > 0) { BECompanies.tbl_CompanyAliasesRow deletealias = DSNewCompanyAliases.tbl_CompanyAliases[0]; deletealias.Delete(); bpAliases.Update(DSNewCompanyAliases); } //Get Oryx's Aliases first DSCompanyAliases = bpAliases.SelectCompanyAliasesByCompanyID(Convert.ToInt32(System.Configuration.ConfigurationSettings.AppSettings.Get("OryxCompanyID"))); if (DSCompanyAliases.tbl_CompanyAliases.Count > 0) { BECompanies.tbl_CompanyAliasesRow alias = DSCompanyAliases.tbl_CompanyAliases[0]; //replace the company Aliases with Oryx's aliases BECompanies.tbl_CompanyAliasesRow newalias; DSNewCompanyAliases = bpAliases.SelectCompanyAliasesByCompanyID(Company.CompanyID); if (DSNewCompanyAliases.tbl_CompanyAliases.Count > 0) { CompanyHasAliases = true; newalias = DSNewCompanyAliases.tbl_CompanyAliases[0]; } else { CompanyHasAliases = false; newalias = DSNewCompanyAliases.tbl_CompanyAliases.Newtbl_CompanyAliasesRow(); } newalias.CompanyID = Company.CompanyID; if (! alias.IsDescriptionNull()) newalias.Description = alias.Description; if (! alias.IsBoxNull()) newalias.Box = alias.Box; if (! alias.IsPinNull()) newalias.Pin = alias.Pin; if (! alias.IsItemNumberNull()) newalias.ItemNumber = alias.ItemNumber; if (! alias.IsBox2Null()) newalias.Box2 = alias.Box2; if (! alias.IsMajorODNull()) newalias.MajorOD = alias.MajorOD; if (! alias.IsMinorODNull()) newalias.MinorOD = alias.MinorOD; if (! alias.IsInsideDiameterNull()) newalias.InsideDiameter = alias.InsideDiameter; if (! alias.IsSealtoSealLengthNull()) newalias.SealtoSealLength = alias.SealtoSealLength; if (! alias.IsFloatBoreNull()) newalias.FloatBore = alias.FloatBore; if (! alias.IsGeneralCommentsNull()) newalias.GeneralComments = alias.GeneralComments; if (! alias.IsExtraColumn1Null()) newalias.ExtraColumn1 = alias.ExtraColumn1; if (! alias.IsExtraColumn2Null()) newalias.ExtraColumn2 = alias.ExtraColumn2; if (! alias.IsExtraColumn3Null()) newalias.ExtraColumn3 = alias.ExtraColumn3; if (! alias.IsExtraColumn4Null()) newalias.ExtraColumn4 = alias.ExtraColumn4; if (! alias.IsExtraColumn5Null()) newalias.ExtraColumn5 = alias.ExtraColumn5; if (! alias.IsExtraColumn6Null()) newalias.ExtraColumn6 = alias.ExtraColumn6; if (! alias.IsExtraColumn7Null()) newalias.ExtraColumn7 = alias.ExtraColumn7; if (! alias.IsExtraColumn8Null()) newalias.ExtraColumn8 = alias.ExtraColumn8; if (! alias.IsExtraColumn9Null()) newalias.ExtraColumn9 = alias.ExtraColumn9; if (! alias.IsExtraColumn10Null()) newalias.ExtraColumn10 = alias.ExtraColumn10; if (CompanyHasAliases == false) { DSNewCompanyAliases.tbl_CompanyAliases.Rows.Add(newalias); } bpAliases.Update(DSNewCompanyAliases); } } if (CompanyID == 0) { Response.Redirect("EditCompanies.aspx?CompanyID=" + Company.CompanyID); } else { Response.Redirect("BrowseCompanies.aspx"); } }