Esempio n. 1
0
    protected void grvSeason_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        try
        {
            int SeasonID = 0;
            string SeasonName = string.Empty;
            TextBox txtControl;

            txtControl = ((TextBox)grvSeason.Rows[e.RowIndex].FindControl("txtSeasonIDE"));
            if (txtControl.Text != null)
            {
                SeasonID = Convert.ToInt32(txtControl.Text.Trim());
            }

            txtControl = ((TextBox)grvSeason.Rows[e.RowIndex].FindControl("txtSeasonE"));
            if (txtControl != null)
            {
                SeasonName = txtControl.Text.Trim();

            }

            int mintReturn = new BLL.Component.SeasonBLL().AddEditSeason(SeasonID, SeasonName);
            if (mintReturn == -1)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Season with same name already exists.');", true);
            }
        }
        catch (Exception ex)
        {
        }

        //ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Updated successfully');", true);
        grvSeason.EditIndex = -1;
        BindSeason();


    }
Esempio n. 2
0
    protected void grvSeason_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        try
        {
            int SeasonID = 0;
            string SeasonName = string.Empty;
            if (e.CommandName.Equals("Add"))
            {
                int retVal = 0;
                TextBox txtControl;

                txtControl = ((TextBox)grvSeason.FooterRow.FindControl("txtSeason"));
                if (txtControl.Text != null)
                {
                    SeasonName = txtControl.Text.Trim();
                }

                retVal = new BLL.Component.SeasonBLL().AddEditSeason(-1, SeasonName);
                if (retVal == -1)
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Season with same name already exists');", true);
                }
                BindSeason();

            }

            if (e.CommandName.Equals("AddEmpty"))
            {
                int retVal = 0;
                TextBox txtControl;

                GridViewRow emptyRow = grvSeason.Controls[0].Controls[0] as GridViewRow;


                txtControl = (TextBox)emptyRow.FindControl("txtSeason1");
                if (txtControl.Text != null)
                {
                    SeasonName = txtControl.Text.Trim();
                }

                retVal = new BLL.Component.SeasonBLL().AddEditSeason(-1, SeasonName);
                if (retVal == -1)
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Season with same name already exists');", true);
                }
                BindSeason();

            }

        }
        catch (Exception ex)
        {

        }

    }
Esempio n. 3
0
 protected void grvSeason_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     int SeasonID = Convert.ToInt32(grvSeason.DataKeys[e.RowIndex].Values[0].ToString());
     int mintReturn = new BLL.Component.SeasonBLL().DeleteSeason(SeasonID);
     if (mintReturn == -1)
     {
         ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Cannot delete.Season is associeted to Product');", true);
     }
     else
     {
         BindSeason();
         PopulateSeason();
     }
     ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "ShowModalDiv('ModalWindow5','dvInnerWindow4',0);", true);
 }
Esempio n. 4
0
 private void BindSeason()
 {
     List<Season> lstSeason = new SeasonBLL().GetSeason();
     grvSeason.DataSource = lstSeason;
     grvSeason.DataBind();
 }
Esempio n. 5
0
 private void PopulateSeason()
 {
     List<Season> lstSeason = new SeasonBLL().GetSeason();
     ddlSeason.DataSource = lstSeason;
     ddlSeason.DataValueField = "SeasonID";
     ddlSeason.DataTextField = "SeasonName";
     ddlSeason.DataBind();
     ddlSeason.Items.Insert(0, new ListItem("--Select--"));
     ddlSeason.SelectedIndex = 0;
 }