Esempio n. 1
0
        /// <summary>
        /// update row in the table
        /// </summary>
        /// <param name="businessObject">business object</param>
        /// <returns>true for successfully updated</returns>
        public bool Update(clsCompanies businessObject)
        {
            SqlCommand sqlCommand = new SqlCommand();

            sqlCommand.CommandText = "dbo.[sp_Companies_Update]";
            sqlCommand.CommandType = CommandType.StoredProcedure;

            // Use connection object of base class
            sqlCommand.Connection = MainConnection;

            try
            {
                sqlCommand.Parameters.Add(new SqlParameter("@Id", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Id));
                sqlCommand.Parameters.Add(new SqlParameter("@Company", SqlDbType.NVarChar, 400, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Company));
                sqlCommand.Parameters.Add(new SqlParameter("@Data", SqlDbType.Bit, 1, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Data));
                sqlCommand.Parameters.Add(new SqlParameter("@FullName", SqlDbType.NVarChar, 2147483647, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.FullName));


                MainConnection.Open();

                sqlCommand.ExecuteNonQuery();
                return(true);
            }
            catch (Exception ex)
            {
                throw new Exception("clsCompanies::Update::Error occured.", ex);
            }
            finally
            {
                MainConnection.Close();
                sqlCommand.Dispose();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Populate business objects from the data reader
        /// </summary>
        /// <param name="dataReader">data reader</param>
        /// <returns>list of clsCompanies</returns>
        internal List <clsCompanies> PopulateObjectsFromReader(IDataReader dataReader)
        {
            List <clsCompanies> list = new List <clsCompanies>();

            while (dataReader.Read())
            {
                clsCompanies businessObject = new clsCompanies();
                PopulateBusinessObjectFromReader(businessObject, dataReader);
                list.Add(businessObject);
            }
            return(list);
        }
Esempio n. 3
0
        /// <summary>
        /// Populate business object from data reader
        /// </summary>
        /// <param name="businessObject">business object</param>
        /// <param name="dataReader">data reader</param>
        internal void PopulateBusinessObjectFromReader(clsCompanies businessObject, IDataReader dataReader)
        {
            businessObject.Id = dataReader.GetInt32(dataReader.GetOrdinal(clsCompanies.clsCompaniesFields.Id.ToString()));

            businessObject.Company = dataReader.GetString(dataReader.GetOrdinal(clsCompanies.clsCompaniesFields.Company.ToString()));

            businessObject.Data = dataReader.GetBoolean(dataReader.GetOrdinal(clsCompanies.clsCompaniesFields.Data.ToString()));

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(clsCompanies.clsCompaniesFields.FullName.ToString())))
            {
                businessObject.FullName = dataReader.GetString(dataReader.GetOrdinal(clsCompanies.clsCompaniesFields.FullName.ToString()));
            }
        }
Esempio n. 4
0
        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");
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Select by primary key
        /// </summary>
        /// <param name="keys">primary keys</param>
        /// <returns>clsCompanies business object</returns>
        public clsCompanies SelectByPrimaryKey(clsCompaniesKeys keys)
        {
            SqlCommand sqlCommand = new SqlCommand();

            sqlCommand.CommandText = "dbo.[sp_Companies_SelectByPrimaryKey]";
            sqlCommand.CommandType = CommandType.StoredProcedure;

            // Use connection object of base class
            sqlCommand.Connection = MainConnection;

            try
            {
                sqlCommand.Parameters.Add(new SqlParameter("@Id", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, keys.Id));


                MainConnection.Open();

                IDataReader dataReader = sqlCommand.ExecuteReader();

                if (dataReader.Read())
                {
                    clsCompanies businessObject = new clsCompanies();

                    PopulateBusinessObjectFromReader(businessObject, dataReader);

                    return(businessObject);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("clsCompanies::SelectByPrimaryKey::Error occured.", ex);
            }
            finally
            {
                MainConnection.Close();
                sqlCommand.Dispose();
            }
        }
Esempio n. 6
0
        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;
            }
        }
Esempio n. 7
0
        protected void btnCompsub_Click(object sender, EventArgs e)
        {
            clsCompaniesFactory fac = new clsCompaniesFactory();
            List <clsCompanies> lbl = fac.GetAllBy(clsCompanies.clsCompaniesFields.Company, txtcompany.Text);

            if (lbl != null && lbl.Count > 0)
            {
                pnlSuccess.Visible = false;
                pnlError.Visible   = true;
                lblError.Text      = "company already exists";
            }
            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;
            }
            LoadData();
        }
Esempio n. 8
0
        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");
                }
            }
        }