protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["User"] != null) { HtmlGenericControl ManageSongs = (HtmlGenericControl)Master.FindControl("ManageSongs"); ManageSongs.Attributes.Add("class", "select"); HtmlGenericControl ManageCompany = (HtmlGenericControl)Master.FindControl("ManageCompany"); ManageCompany.Attributes.Add("class", "current"); HtmlGenericControl ManageLabel = (HtmlGenericControl)Master.FindControl("ManageLabel"); ManageLabel.Attributes.Add("class", "select"); HtmlGenericControl ManageEmergenti = (HtmlGenericControl)Master.FindControl("ManageEmergenti"); ManageEmergenti.Attributes.Add("class", "select"); HtmlGenericControl ImportData = (HtmlGenericControl)Master.FindControl("ImportData"); ImportData.Attributes.Add("class", "select"); HtmlGenericControl audienceFigures = (HtmlGenericControl)Master.FindControl("audienceFigures"); audienceFigures.Attributes.Add("class", "select"); HtmlGenericControl digitalData = (HtmlGenericControl)Master.FindControl("digitalData"); digitalData.Attributes.Add("class", "select"); HtmlGenericControl MoveFiles = (HtmlGenericControl)Master.FindControl("MoveFiles"); MoveFiles.Attributes.Add("class", "select"); HtmlGenericControl Promoter = (HtmlGenericControl)Master.FindControl("Promoter"); Promoter.Attributes.Add("class", "select"); Session["Songs"] = null; Session["eSongs"] = null; if (Request.QueryString != null && Request.QueryString["id"] != null) { hf.Value = Request.QueryString["id"]; clsCompaniesFactory fac = new clsCompaniesFactory(); clsCompaniesKeys key = new clsCompaniesKeys(Convert.ToInt32(hf.Value)); clsCompanies Company = fac.GetByPrimaryKey(key); txtcompany.Text = Company.Company; txtFullName.Text = Company.FullName; ddlFirst.SelectedValue = Company.Data == true ? "0" : "1"; } } else { Response.Redirect("Login.aspx"); } } }
protected void btn_Click(object sender, EventArgs e) { clsCompaniesFactory fac = new clsCompaniesFactory(); if (string.IsNullOrEmpty(hf.Value)) { List <clsCompanies> lbl = fac.GetAllBy(clsCompanies.clsCompaniesFields.Company, txtcompany.Text); if (lbl != null && lbl.Count > 0) { pnlSuccess.Visible = false; pnlError.Visible = true; } else { clsCompanies Company = new clsCompanies(); Company.FullName = txtFullName.Text; Company.Company = txtcompany.Text; Company.Data = ddlFirst.SelectedValue == "1" ? false : true; fac.Insert(Company); pnlSuccess.Visible = true; lblSuccess.Text = "company added successfully"; pnlError.Visible = false; } } else { clsCompaniesKeys key = new clsCompaniesKeys(Convert.ToInt32(hf.Value)); clsCompanies Company = fac.GetByPrimaryKey(key); Company.FullName = txtFullName.Text; Company.Company = txtcompany.Text; Company.Data = ddlFirst.SelectedValue == "1" ? false : true; fac.Update(Company); pnlSuccess.Visible = true; lblSuccess.Text = "company updated successfully"; pnlError.Visible = false; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["User"] != null) { Session["eSongs"] = null; HtmlGenericControl ManageSongs = (HtmlGenericControl)Master.FindControl("ManageSongs"); ManageSongs.Attributes.Add("class", "current"); HtmlGenericControl ManageCompany = (HtmlGenericControl)Master.FindControl("ManageCompany"); ManageCompany.Attributes.Add("class", "select"); HtmlGenericControl ManageLabel = (HtmlGenericControl)Master.FindControl("ManageLabel"); ManageLabel.Attributes.Add("class", "select"); HtmlGenericControl ManageEmergenti = (HtmlGenericControl)Master.FindControl("ManageEmergenti"); ManageEmergenti.Attributes.Add("class", "select"); HtmlGenericControl ImportData = (HtmlGenericControl)Master.FindControl("ImportData"); ImportData.Attributes.Add("class", "select"); HtmlGenericControl audienceFigures = (HtmlGenericControl)Master.FindControl("audienceFigures"); audienceFigures.Attributes.Add("class", "select"); HtmlGenericControl digitalData = (HtmlGenericControl)Master.FindControl("digitalData"); digitalData.Attributes.Add("class", "select"); HtmlGenericControl MoveFiles = (HtmlGenericControl)Master.FindControl("MoveFiles"); MoveFiles.Attributes.Add("class", "select"); HtmlGenericControl Promoter = (HtmlGenericControl)Master.FindControl("Promoter"); Promoter.Attributes.Add("class", "select"); if (Request.QueryString != null && Request.QueryString["id"] != null) { hf.Value = Request.QueryString["id"]; hfprevid.Value = Request.QueryString["id"]; clsSongsFactory fac = new clsSongsFactory(); List <clsSongs> Songs = fac.GetAllByVersions(Convert.ToInt32(hf.Value)); pnlButtons.Visible = true; pnlSave.Visible = false; if (Songs != null && Songs.Count > 0 && Session["Songs"] == null) { grd.DataSource = Songs; grd.DataBind(); Session["Songs"] = Songs; clsSongs Song = Songs.First(x => x.IdSong == Convert.ToInt32(hf.Value)); lblVersion.Text = Song.VERSION; chkAbsoluteBegin.Checked = Song.IncludeInNewTalent; chkAlternativeCharts.Checked = Song.AlternativeChart; chkFirstPlay.Checked = Song.IncludeInFirstPlay; lblGenre.Text = Song.GENRE; lblLanguage.Text = Song.LANGUAGE; lblRadio.Text = Song.RadioDate == null ? "" : Song.RadioDate.Value.ToString("dd/MM/yyyy"); lblTvShow.Text = Song.TVSHOW; lblArtist.Text = Song.ARTIST; lblTitle.Text = Song.TITLE; lblAuthor.Text = Song.Author; lblPublisher.Text = Song.Publisher; lblDuration.Text = Song.Duration; lblISRC.Text = Song.ISRC; lblLabel.Text = Song.LABEL; clsCompaniesFactory facC = new clsCompaniesFactory(); clsCompaniesKeys k = new clsCompaniesKeys(Songs[0].CompanyId.Value); clsCompanies c = facC.GetByPrimaryKey(k); lblCompany.Text = c.FullName; } else { Songs = (List <clsSongs>)Session["Songs"]; grd.DataSource = Songs; grd.DataBind(); clsSongs Song = Songs.Where(x => x.IdSong == Convert.ToInt32(hf.Value)).FirstOrDefault(); pnlButtons.Visible = false; pnlSave.Visible = true; lblVersion.Text = Song.VERSION; chkAbsoluteBegin.Checked = Song.IncludeInNewTalent; chkAlternativeCharts.Checked = Song.AlternativeChart; chkFirstPlay.Checked = Song.IncludeInFirstPlay; lblGenre.Text = Song.GENRE; lblLanguage.Text = Song.LANGUAGE; lblRadio.Text = Song.RadioDate.Value.ToString("dd/MM/yyyy"); lblTvShow.Text = Song.TVSHOW; lblArtist.Text = Song.ARTIST; lblTitle.Text = Song.TITLE; lblAuthor.Text = Song.Author; lblPublisher.Text = Song.Publisher; lblDuration.Text = Song.Duration; lblISRC.Text = Song.ISRC; lblLabel.Text = Song.LABEL; clsCompaniesFactory facC = new clsCompaniesFactory(); clsCompaniesKeys k = new clsCompaniesKeys(Song.CompanyId.Value); clsCompanies c = facC.GetByPrimaryKey(k); lblCompany.Text = c.FullName; } } } else { Response.Redirect("Login.aspx"); } } }