Пример #1
0
    protected void btnPromeni_Click(object sender, EventArgs e)
    {
        String UpdateIDs = "";

        foreach (GridViewRow row in GridView1.Rows)
        {
            CheckBox CheckBoxGrid = (CheckBox)row.Cells[1].FindControl("CheckBox1");
            if (CheckBoxGrid.Checked)
            {
                if (UpdateIDs != "")
                {
                    UpdateIDs += ", ";
                }
                UpdateIDs += row.Cells[0].Text;
            }
        }

        SqlConnection connection = new SqlConnection();

        connection.ConnectionString = ConfigurationManager.ConnectionStrings["Konekcija"].ConnectionString;
        SqlCommand komanda = new SqlCommand();

        komanda.Connection = connection;
        if (UpdateIDs != "")
        {
            String DatumVreme = DateTime.Now.ToString("dd.MM.yyyy hh:mm", CultureInfo.InvariantCulture);

            if (cbVednash.Checked == false)
            {
                tbVreme.Text = tbVreme.Text.Trim();
                if (tbVreme.Text.Length == 0)
                {
                    tbVreme.Text = DateTime.Now.ToShortTimeString();
                }
                DatumVreme = tbDatum.Text + " " + tbVreme.Text;
            }

            komanda.CommandText += @" UPDATE Vest SET f_Odobrena = 1, Datum_Dozvola = GETDATE(),
                                Datum_Objava_Prikaz = convert(datetime,'" + DatumVreme + @"',104), 
                                Odobrena_Od = " + Session["Korisnik"].ToString() + " WHERE Vest_Id IN (" + UpdateIDs + ") ; ";
            try
            {
                connection.Open();
                komanda.ExecuteNonQuery();
                //ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "AlertPopup", "alert('Вестите се активирани!');", true);
            }

            finally
            { connection.Close(); }

            DS_NeaktivniVesti.DataBind();
            GridView1.DataBind();

            PrikazNaPaneli();
        }
    }
Пример #2
0
    protected void btnIzbrishi_Click(object sender, EventArgs e)
    {
        String SelectedIDs = "";

        foreach (GridViewRow row in GridView1.Rows)
        {
            CheckBox CheckBoxGrid = (CheckBox)row.Cells[1].FindControl("CheckBox1");
            if (CheckBoxGrid.Checked)
            {
                if (SelectedIDs != "")
                {
                    SelectedIDs += ", ";
                }
                SelectedIDs += row.Cells[0].Text;
            }
        }

        SqlConnection connection = new SqlConnection();

        connection.ConnectionString = ConfigurationManager.ConnectionStrings["Konekcija"].ConnectionString;
        SqlCommand komanda = new SqlCommand();

        komanda.Connection = connection;
        if (SelectedIDs != "")
        {
            komanda.CommandText += @" DELETE FROM Vest WHERE Vest_Id IN (" + SelectedIDs + ") ; ";
            try
            {
                connection.Open();
                komanda.ExecuteNonQuery();
            }

            finally
            { connection.Close(); }

            DS_NeaktivniVesti.DataBind();
            GridView1.DataBind();

            PrikazNaPaneli();
        }
    }