protected void btnSave_Click(object sender, EventArgs e) { DistributerUIDetail distributer; try { distributer = new DistributerUIDetail(); distributer = LoadDataFromForm(); CSLOrderingARCBAL.BAL.DistributorBAL bal = new DistributorBAL(); bal.SaveDistributor(distributer); LoadDistributerList(); btnConfirm.Visible = true; string script = "alertify.alert('URLName " + txtUrlName.Text + " update successful.');"; ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script, true); MaintainScrollPositionOnPostBack = false; } catch (Exception ex) { CSLOrderingARCBAL.LinqToSqlDataContext db = new CSLOrderingARCBAL.LinqToSqlDataContext(); db.USP_SaveErrorDetails(Request.Url.ToString(), "btnShowAll_Click", Convert.ToString(ex.Message), Convert.ToString(ex.InnerException), Convert.ToString(ex.StackTrace), "", HttpContext.Current.Request.UserHostAddress, false, Convert.ToString(HttpContext.Current.Session[enumSessions.User_Id.ToString()])); string script = "alertify.alert('URLName " + txtUrlName.Text + " update failed.');"; ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script, true); MaintainScrollPositionOnPostBack = false; } }
public DistributerUIDetail GetDistributerForId(int id) { CSLOrderingARCBAL.LinqToSqlDataContext db = new LinqToSqlDataContext(); DistributerUIDetail distributer = new DistributerUIDetail(); distributer = (from x in db.DistributerUIDetails where x.ID == id select x).SingleOrDefault(); return(distributer); }
public DistributerUIDetail GetDistributerUIByName(string urlName) { CSLOrderingARCBAL.LinqToSqlDataContext db = new CSLOrderingARCBAL.LinqToSqlDataContext(); DistributerUIDetail distributer = new DistributerUIDetail(); distributer = (from x in db.DistributerUIDetails where x.UrlName == urlName select x).SingleOrDefault(); return(distributer); }
public void UpdateForConfirmation(string urlName) { CSLOrderingARCBAL.LinqToSqlDataContext db = new CSLOrderingARCBAL.LinqToSqlDataContext(); DistributerUIDetail distributerObject = new DistributerUIDetail(); distributerObject = (from x in db.DistributerUIDetails where x.UrlName == urlName select x).SingleOrDefault(); distributerObject.Active = true; db.SubmitChanges(); }
private void DeleteFooter4(string urlName) { CSLOrderingARCBAL.LinqToSqlDataContext db = new CSLOrderingARCBAL.LinqToSqlDataContext(); DistributerUIDetail distributer = new DistributerUIDetail(); distributer = (from x in db.DistributerUIDetails where x.UrlName == urlName select x).SingleOrDefault(); distributer.Footer4Image = string.Empty; distributer.Footer4Text = string.Empty; distributer.Footer4URL = string.Empty; db.SubmitChanges(); }
public void SaveDistributor(DistributerUIDetail distributer) { CSLOrderingARCBAL.LinqToSqlDataContext db = new CSLOrderingARCBAL.LinqToSqlDataContext(); DistributerUIDetail distributerObject = new DistributerUIDetail(); if (distributer.ID != -1) { distributerObject = db.DistributerUIDetails.Where(x => x.ID == distributer.ID).FirstOrDefault(); if (distributerObject != null) { // distributerObject = new DistributerUIDetail(); if (!string.IsNullOrEmpty(distributer.Footer1Image)) { distributerObject.Footer1Image = distributer.Footer1Image; } distributerObject.Footer1Text = distributer.Footer1Text; distributerObject.Footer1URL = distributer.Footer1URL; if (!string.IsNullOrEmpty(distributer.Footer2Image)) { distributerObject.Footer2Image = distributer.Footer2Image; } distributerObject.Footer2Text = distributer.Footer2Text; distributerObject.Footer2URL = distributer.Footer2URL; if (!string.IsNullOrEmpty(distributer.Footer3Image)) { distributerObject.Footer3Image = distributer.Footer3Image; } distributerObject.Footer3Text = distributer.Footer3Text; distributerObject.Footer3URL = distributer.Footer3URL; if (!string.IsNullOrEmpty(distributer.Footer4Image)) { distributerObject.Footer4Image = distributer.Footer4Image; } distributerObject.Footer4Text = distributer.Footer4Text; distributerObject.Footer4URL = distributer.Footer4URL; distributerObject.FooterBgColor = distributer.FooterBgColor; distributerObject.FooterTextColor = distributer.FooterTextColor; if (!string.IsNullOrEmpty(distributer.HeaderImage)) { distributerObject.HeaderImage = distributer.HeaderImage; } if (!string.IsNullOrEmpty(distributer.MainImage)) { distributerObject.MainImage = distributer.MainImage; } if (!string.IsNullOrEmpty(distributer.BannerImage)) { distributerObject.BannerImage = distributer.BannerImage; } if (!string.IsNullOrEmpty(distributer.PagetoNavigateafterSignin)) { distributerObject.PagetoNavigateafterSignin = distributer.PagetoNavigateafterSignin; } distributerObject.SignInButtoncolor = distributer.SignInButtoncolor; distributerObject.SignUpHyperlinkcolor = distributer.SignUpHyperlinkcolor; distributerObject.UrlName = distributer.UrlName; distributer.Active = false; db.SubmitChanges(); } } else { distributerObject.Footer1Image = distributer.Footer1Image; distributerObject.Footer1Text = distributer.Footer1Text; distributerObject.Footer1URL = distributer.Footer1URL; distributerObject.Footer2Image = distributer.Footer2Image; distributerObject.Footer2Text = distributer.Footer2Text; distributerObject.Footer2URL = distributer.Footer2URL; distributerObject.Footer3Image = distributer.Footer3Image; distributerObject.Footer3Text = distributer.Footer3Text; distributerObject.Footer3URL = distributer.Footer3URL; distributerObject.Footer4Image = distributer.Footer4Image; distributerObject.Footer4Text = distributer.Footer4Text; distributerObject.Footer4URL = distributer.Footer4URL; distributerObject.FooterBgColor = distributer.FooterBgColor; distributerObject.FooterTextColor = distributer.FooterTextColor; distributerObject.HeaderImage = distributer.HeaderImage; distributerObject.MainImage = distributer.MainImage; distributerObject.BannerImage = distributer.BannerImage; distributerObject.SignInButtoncolor = distributer.SignInButtoncolor; distributerObject.SignUpHyperlinkcolor = distributer.SignUpHyperlinkcolor; distributerObject.UrlName = distributer.UrlName; distributerObject.PagetoNavigateafterSignin = distributer.PagetoNavigateafterSignin; distributer.Active = false; db.DistributerUIDetails.InsertOnSubmit(distributerObject); db.SubmitChanges(); } }
private void GetDistributorForId(int id) { DistributerUIDetail distributer = new DistributerUIDetail(); DistributorBAL bal = new DistributorBAL(); distributer = bal.GetDistributerForId(id); //load the data to the textfield. txtUrlName.Text = distributer.UrlName; txtSignUpHyperlinkcolor.Text = distributer.SignUpHyperlinkcolor; drpDefaultPageToNavigate.SelectedValue = distributer.PagetoNavigateafterSignin; // drpDefaultPageToNavigate.SelectedValue = distributer.PagetoNavigateafterSignin; txtSignInButtoncolor.Text = distributer.SignInButtoncolor; txtFooterTextColor.Text = distributer.FooterTextColor; txtFooterBgColor.Text = distributer.FooterBgColor; if (!string.IsNullOrEmpty(distributer.HeaderImage)) { imgHeaderImage.ImageUrl = ConfigurationManager.AppSettings["DistributerImages"].ToString() + distributer.HeaderImage; } if (!string.IsNullOrEmpty(distributer.BannerImage)) { imgBannerImage.ImageUrl = ConfigurationManager.AppSettings["DistributerImages"].ToString() + distributer.BannerImage; } if (!string.IsNullOrEmpty(distributer.Footer1Image)) { imgFooter1Image.ImageUrl = ConfigurationManager.AppSettings["DistributerImages"].ToString() + distributer.Footer1Image; } txtFooter1Text.Text = distributer.Footer1Text; txtFooter1URL.Text = distributer.Footer1URL; if (!string.IsNullOrEmpty(distributer.Footer2Image)) { imgFooter2Image.ImageUrl = ConfigurationManager.AppSettings["DistributerImages"].ToString() + distributer.Footer2Image; } txtFooter2Text.Text = distributer.Footer2Text; txtFooter2URL.Text = distributer.Footer2URL; if (!string.IsNullOrEmpty(distributer.Footer3Image)) { imgFooter3Image.ImageUrl = ConfigurationManager.AppSettings["DistributerImages"].ToString() + distributer.Footer3Image; } txtFooter3Text.Text = distributer.Footer3Text; txtFooter3URL.Text = distributer.Footer3URL; if (!string.IsNullOrEmpty(distributer.Footer4Image)) { imgFooter4Image.ImageUrl = ConfigurationManager.AppSettings["DistributerImages"].ToString() + distributer.Footer4Image; } txtFooter4Text.Text = distributer.Footer4Text; txtFooter4URL.Text = distributer.Footer4URL; if (!string.IsNullOrEmpty(distributer.MainImage)) { imgMainImage.ImageUrl = ConfigurationManager.AppSettings["DistributerImages"].ToString() + distributer.MainImage; } }
private DistributerUIDetail LoadDataFromForm() { DistributerUIDetail distributer = new DistributerUIDetail(); distributer.ID = Session[enumSessions.DistributerIdToUpdate.ToString()] != null?Convert.ToInt32(Session[enumSessions.DistributerIdToUpdate.ToString()]) : -1; distributer.Footer1Text = txtFooter1Text.Text; distributer.Footer1URL = txtFooter1URL.Text; distributer.Footer2Text = txtFooter2Text.Text; distributer.Footer2URL = txtFooter2URL.Text; distributer.Footer3Text = txtFooter3Text.Text; distributer.Footer3URL = txtFooter3URL.Text; distributer.Footer4Text = txtFooter4Text.Text; distributer.Footer4URL = txtFooter4URL.Text; distributer.FooterBgColor = string.IsNullOrEmpty(txtFooterBgColor.Text)?ConfigurationManager.AppSettings["DefaultFooterBgColor"].ToString(): txtFooterBgColor.Text; distributer.FooterTextColor = string.IsNullOrEmpty(txtFooterTextColor.Text)?ConfigurationManager.AppSettings["DefaultFooterTextColor"].ToString(): txtFooterTextColor.Text; distributer.PagetoNavigateafterSignin = drpDefaultPageToNavigate.SelectedValue; if (fuHeaderImage.HasFile) { try { string filename = txtUrlName.Text + "_" + "HeaderImage" + Path.GetExtension(fuHeaderImage.FileName); if (File.Exists(Server.MapPath("../DistributerImages/") + filename)) { File.Delete(Server.MapPath("../DistributerImages/") + filename); } fuHeaderImage.SaveAs(Server.MapPath("../DistributerImages/") + filename); distributer.HeaderImage = filename; } catch (Exception ex) { string script = "alertify.alert('Upload status for HeaderImage: The file could not be uploaded. The following error occured: '" + ex.Message + ")"; ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script, true); MaintainScrollPositionOnPostBack = false; } } if (fuFooter4Image.HasFile) { try { string filename = txtUrlName.Text + "_" + "Footer4Image" + Path.GetExtension(fuFooter4Image.FileName); if (File.Exists(Server.MapPath("../DistributerImages/") + filename)) { File.Delete(Server.MapPath("../DistributerImages/") + filename); } fuFooter4Image.SaveAs(Server.MapPath("../DistributerImages/") + filename); distributer.Footer4Image = filename; } catch (Exception ex) { string script = "alertify.alert('Upload status for Footer1Image: The file could not be uploaded. The following error occured: '" + ex.Message + ")"; ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script, true); MaintainScrollPositionOnPostBack = false; } } if (fuFooter3Image.HasFile) { try { string filename = txtUrlName.Text + "_" + "Footer3Image" + Path.GetExtension(fuFooter3Image.FileName); if (File.Exists(Server.MapPath("../DistributerImages/") + filename)) { File.Delete(Server.MapPath("../DistributerImages/") + filename); } fuFooter3Image.SaveAs(Server.MapPath("../DistributerImages/") + filename); distributer.Footer3Image = filename; } catch (Exception ex) { string script = "alertify.alert('Upload status for Footer3Image: The file could not be uploaded. The following error occured: '" + ex.Message + ")"; ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script, true); MaintainScrollPositionOnPostBack = false; } } if (fuFooter2Image.HasFile) { try { string filename = txtUrlName.Text + "_" + "Footer2Image" + Path.GetExtension(fuFooter2Image.FileName); if (File.Exists(Server.MapPath("../DistributerImages/") + filename)) { File.Delete(Server.MapPath("../DistributerImages/") + filename); } fuFooter2Image.SaveAs(Server.MapPath("../DistributerImages/") + filename); distributer.Footer2Image = filename; } catch (Exception ex) { string script = "alertify.alert('Upload status for Footer2Image: The file could not be uploaded. The following error occured: '" + ex.Message + ")"; ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script, true); MaintainScrollPositionOnPostBack = false; } } if (fuFooter1Image.HasFile) { try { string filename = txtUrlName.Text + "_" + "Footer1Image" + Path.GetExtension(fuFooter1Image.FileName); if (File.Exists(Server.MapPath("../DistributerImages/") + filename)) { File.Delete(Server.MapPath("../DistributerImages/") + filename); } fuFooter1Image.SaveAs(Server.MapPath("../DistributerImages/") + filename); distributer.Footer1Image = filename; } catch (Exception ex) { string script = "alertify.alert('Upload status for Footer1Image: The file could not be uploaded. The following error occured: '" + ex.Message + ")"; ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script, true); MaintainScrollPositionOnPostBack = false; } } if (fuMainImage.HasFile) { try { string filename = txtUrlName.Text + "_" + "MainImage" + Path.GetExtension(fuMainImage.FileName); if (File.Exists(Server.MapPath("../DistributerImages/") + filename)) { File.Delete(Server.MapPath("../DistributerImages/") + filename); } fuMainImage.SaveAs(Server.MapPath("../DistributerImages/") + filename); distributer.MainImage = filename; } catch (Exception ex) { string script = "alertify.alert('Upload status for MainImage: The file could not be uploaded. The following error occured: '" + ex.Message + ")"; ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script, true); MaintainScrollPositionOnPostBack = false; } } if (fuBannerImage.HasFile) { try { string filename = txtUrlName.Text + "_" + "BannerImage" + Path.GetExtension(fuBannerImage.FileName); if (File.Exists(Server.MapPath("../DistributerImages/") + filename)) { File.Delete(Server.MapPath("../DistributerImages/") + filename);//delete if file exists } fuBannerImage.SaveAs(Server.MapPath("../DistributerImages/") + filename); distributer.BannerImage = filename; } catch (Exception ex) { string script = "alertify.alert('Upload status for MainImage: The file could not be uploaded. The following error occured: '" + ex.Message + ")"; ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script, true); MaintainScrollPositionOnPostBack = false; } } distributer.SignInButtoncolor = string.IsNullOrEmpty(txtSignInButtoncolor.Text)?ConfigurationManager.AppSettings["DefaultSignInButtonColor"].ToString(): txtSignInButtoncolor.Text; distributer.SignUpHyperlinkcolor = string.IsNullOrEmpty(txtSignUpHyperlinkcolor.Text)? ConfigurationManager.AppSettings["DefaultSignUpHyperlinkColor"].ToString() : txtSignUpHyperlinkcolor.Text; distributer.UrlName = txtUrlName.Text; return(distributer); }
protected void btnConfirm_Click(object sender, EventArgs e) { DistributerUIDetail distributer = new DistributerUIDetail(); DistributorBAL distributerBAL = new DistributorBAL(); distributer = distributerBAL.GetDistributerUIByName(txtUrlName.Text); if (!string.IsNullOrEmpty(distributer.HeaderImage)) { try { string sourceFileName = ConfigurationManager.AppSettings["ARCImagesPath"] + distributer.HeaderImage; string destinationFileName = ConfigurationManager.AppSettings["M2MImagesPath"] + distributer.HeaderImage; System.IO.File.Copy(sourceFileName, destinationFileName, true); } catch (Exception ex) { string script1 = "alertify.alert('Upload status for HeaderImage: The file could not be uploaded. The following error occured: '" + ex.Message + ")"; ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script1, true); MaintainScrollPositionOnPostBack = false; } } if (!string.IsNullOrEmpty(distributer.BannerImage)) { try { string sourceFileName = ConfigurationManager.AppSettings["ARCImagesPath"] + distributer.BannerImage; string destinationFileName = ConfigurationManager.AppSettings["M2MImagesPath"] + distributer.BannerImage; System.IO.File.Copy(sourceFileName, destinationFileName, true); } catch (Exception ex) { string script1 = "alertify.alert('Upload status for BannerImage: The file could not be uploaded. The following error occured: '" + ex.Message + ")"; ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script1, true); MaintainScrollPositionOnPostBack = false; } } if (!string.IsNullOrEmpty(distributer.Footer4Image)) { try { string sourceFileName = ConfigurationManager.AppSettings["ARCImagesPath"] + distributer.Footer4Image; string destinationFileName = ConfigurationManager.AppSettings["M2MImagesPath"] + distributer.Footer4Image; System.IO.File.Copy(sourceFileName, destinationFileName, true); } catch (Exception ex) { string script2 = "alertify.alert('Upload status for Footer4Image: The file could not be uploaded. The following error occured: '" + ex.Message + ")"; ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script2, true); MaintainScrollPositionOnPostBack = false; } } if (!string.IsNullOrEmpty(distributer.Footer3Image)) { try { string sourceFileName = ConfigurationManager.AppSettings["ARCImagesPath"] + distributer.Footer3Image; string destinationFileName = ConfigurationManager.AppSettings["M2MImagesPath"] + distributer.Footer3Image; System.IO.File.Copy(sourceFileName, destinationFileName, true); } catch (Exception ex) { string script2 = "alertify.alert('Upload status for Footer3Image: The file could not be uploaded. The following error occured: '" + ex.Message + ")"; ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script2, true); MaintainScrollPositionOnPostBack = false; } } if (!string.IsNullOrEmpty(distributer.Footer2Image)) { try { string sourceFileName = ConfigurationManager.AppSettings["ARCImagesPath"] + distributer.Footer2Image; string destinationFileName = ConfigurationManager.AppSettings["M2MImagesPath"] + distributer.Footer2Image; System.IO.File.Copy(sourceFileName, destinationFileName, true); } catch (Exception ex) { string script3 = "alertify.alert('Upload status for Footer2Image: The file could not be uploaded. The following error occured: '" + ex.Message + ")"; ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script3, true); MaintainScrollPositionOnPostBack = false; } } if (!string.IsNullOrEmpty(distributer.Footer1Image)) { try { string sourceFileName = ConfigurationManager.AppSettings["ARCImagesPath"] + distributer.Footer1Image; string destinationFileName = ConfigurationManager.AppSettings["M2MImagesPath"] + distributer.Footer1Image; System.IO.File.Copy(sourceFileName, destinationFileName, true); } catch (Exception ex) { string script4 = "alertify.alert('Upload status for Footer1Image: The file could not be uploaded. The following error occured: '" + ex.Message + ")"; ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script4, true); MaintainScrollPositionOnPostBack = false; } } if (!string.IsNullOrEmpty(distributer.MainImage)) { try { string sourceFileName = ConfigurationManager.AppSettings["ARCImagesPath"] + distributer.MainImage; string destinationFileName = ConfigurationManager.AppSettings["M2MImagesPath"] + distributer.MainImage; System.IO.File.Copy(sourceFileName, destinationFileName, true); } catch (Exception ex) { string script6 = "alertify.alert('Upload status for MainImage: The file could not be uploaded. The following error occured: '" + ex.Message + ")"; ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script6, true); MaintainScrollPositionOnPostBack = false; } } try { distributerBAL.UpdateForConfirmation(txtUrlName.Text); } catch (Exception ex) { string script5 = "alertify.alert('Failed to update the Active flag. The following error occured: '" + ex.Message + ")"; ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script5, true); MaintainScrollPositionOnPostBack = false; } string script = "alertify.alert('URLName " + txtUrlName.Text + " confirm successful.');"; ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script, true); MaintainScrollPositionOnPostBack = false; }