示例#1
0
    protected void btnIzbrisi_Click(object sender, EventArgs e)
    {
        if (tbSelected_Id.Text != "")
        {
            SlikaMeni.ImageUrl = "";
            SqlConnection connection = new SqlConnection();
            connection.ConnectionString = ConfigurationManager.ConnectionStrings["Konekcija"].ConnectionString;
            SqlCommand komanda = new SqlCommand();
            komanda.Connection  = connection;
            komanda.CommandText = "DELETE FROM Meni WHERE Meni_Id = " + tbSelected_Id.Text;
            try
            {
                connection.Open();
                komanda.ExecuteNonQuery();
            }
            finally
            {
                connection.Close();
                tbSelected_Id.Text              = "";
                tbPromeniTekst.Text             = "";
                tbPromeniOpis.Text              = "";
                ddlPromeniPodmeni.SelectedIndex = -1;

                DSCeloMeni.ConnectionString      = ConfigurationManager.ConnectionStrings["Konekcija"].ConnectionString;
                DSGlavnoMeni.ConnectionString    = ConfigurationManager.ConnectionStrings["Konekcija"].ConnectionString;
                DSPodmeni.ConnectionString       = ConfigurationManager.ConnectionStrings["Konekcija"].ConnectionString;
                DSSitePodmenija.ConnectionString = ConfigurationManager.ConnectionStrings["Konekcija"].ConnectionString;

                DSCeloMeni.SelectCommand      = "SELECT Meni_Id, Tekst FROM Meni UNION SELECT '',''";
                DSGlavnoMeni.SelectCommand    = "SELECT * FROM Meni Where ParentMeni_Id IS NULL ORDER BY f_Sort";
                DSPodmeni.SelectCommand       = "SELECT * FROM Meni WHERE 1=2";
                DSSitePodmenija.SelectCommand = "SELECT * FROM Meni WHERE 1=2";

                DSCeloMeni.DataBind();
                DSGlavnoMeni.DataBind();
                DSPodmeni.DataBind();
                DSSitePodmenija.DataBind();

                if (Session["VtoroMeni"] != "")
                {
                    lbGlavnoMeni.SelectedIndex = Convert.ToInt32(Session["GlavnoMeni"]);

                    DSPodmeni.SelectCommand    = "SELECT * FROM Meni Where NOT ParentMeni_Id IS NULL AND ParentMeni_Id = " + lbGlavnoMeni.SelectedValue + " ORDER BY f_Sort";
                    DSPodmeni.ConnectionString = ConfigurationManager.ConnectionStrings["Konekcija"].ConnectionString;
                    DSPodmeni.DataBind();
                }
                if (Session["TretoMeni"] != "")
                {
                    lbPodmeni.SelectedIndex          = Convert.ToInt32(Session["VtoroMeni"]);
                    DSSitePodmenija.SelectCommand    = @"select Meni_Id, Tekst, f_Sort from Meni where ParentMeni_Id=" + lbPodmeni.SelectedValue + @"
                                            union select Meni_Id, Tekst, f_Sort from Meni where ParentMeni_Id IN
                                            (select Meni_Id from Meni where ParentMeni_Id=" + lbPodmeni.SelectedValue + ") ORDER BY f_Sort";
                    DSSitePodmenija.ConnectionString = ConfigurationManager.ConnectionStrings["Konekcija"].ConnectionString;
                    DSSitePodmenija.DataBind();
                }

                ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "AlertPopup", "alert('Ставката е избришана!');", true);
            }
        }
    }
示例#2
0
 protected void lbPodmeni_SelectedIndexChanged(object sender, EventArgs e)
 {
     VtoroUp.Enabled                  = true;
     VtoroDown.Enabled                = true;
     DSSitePodmenija.SelectCommand    = @"select Meni_Id, Tekst, f_Sort from Meni where ParentMeni_Id=" + lbPodmeni.SelectedValue + @"
                                         union select Meni_Id, Tekst, f_Sort from Meni where ParentMeni_Id IN
                                         (select Meni_Id from Meni where ParentMeni_Id=" + lbPodmeni.SelectedValue + ") ORDER BY f_Sort";
     DSSitePodmenija.ConnectionString = ConfigurationManager.ConnectionStrings["Konekcija"].ConnectionString;
     DSSitePodmenija.DataBind();
     Session["VtoroMeni"] = lbPodmeni.SelectedIndex;
     Session["TretoMeni"] = "";
     //UpdatePanel2.DataBind();
     NapolniPromena(Convert.ToInt32(lbPodmeni.SelectedValue));
 }
示例#3
0
    protected void lbGlavnoMeni_SelectedIndexChanged(object sender, EventArgs e)
    {
        GlavnoUp.Enabled           = true;
        GlavnoDown.Enabled         = true;
        DSPodmeni.SelectCommand    = "SELECT * FROM Meni Where NOT ParentMeni_Id IS NULL AND ParentMeni_Id = " + lbGlavnoMeni.SelectedValue + "  ORDER BY f_Sort";
        DSPodmeni.ConnectionString = ConfigurationManager.ConnectionStrings["Konekcija"].ConnectionString;
        DSPodmeni.DataBind();

        DSSitePodmenija.SelectCommand    = "SELECT * FROM Meni WHERE 1=2";
        DSSitePodmenija.ConnectionString = ConfigurationManager.ConnectionStrings["Konekcija"].ConnectionString;
        DSSitePodmenija.DataBind();

        //UpdatePanel2.DataBind();
        Session["GlavnoMeni"] = lbGlavnoMeni.SelectedIndex;
        Session["VtoroMeni"]  = "";
        Session["TretoMeni"]  = "";
        NapolniPromena(Convert.ToInt32(lbGlavnoMeni.SelectedValue));
    }
示例#4
0
    protected void TretoDown_Click(object sender, ImageClickEventArgs e)
    {
        int           MaximumSort = 0;
        int           TekovenSort = 0;
        SqlConnection konekcija   = new SqlConnection();

        konekcija.ConnectionString = ConfigurationManager.ConnectionStrings["Konekcija"].ConnectionString;
        string sqlString = @"SELECT isnull(MAX(f_Sort),0) as Maximum FROM Meni WHERE ParentMeni_Id = " + Session["VtoroMeni"];

        SqlCommand komanda = new SqlCommand(sqlString, konekcija);

        try
        {
            konekcija.Open();
            SqlDataReader citac = komanda.ExecuteReader();
            if (citac.Read())
            {
                MaximumSort = Convert.ToInt32(citac["Maximum"]);
            }
            citac.Close();

            komanda.CommandText = "SELECT isnull(f_Sort,0) as f_Sort FROM Meni WHERE Meni_Id = " + lbSitePodmenija.SelectedValue;
            citac = komanda.ExecuteReader();
            if (citac.Read())
            {
                TekovenSort = Convert.ToInt32(citac["f_Sort"]);
            }
            citac.Close();

            if (TekovenSort < MaximumSort)
            {
                komanda.CommandText = "UPDATE Meni SET f_Sort = (isnull(f_Sort,0) - 1) WHERE ParentMeni_Id = " + lbPodmeni.SelectedValue + " AND f_Sort = " + (TekovenSort + 1).ToString() + @" ; 
                                       UPDATE Meni SET f_Sort = (isnull(f_Sort,0) + 1) WHERE Meni_Id = " + lbSitePodmenija.SelectedValue;
                komanda.ExecuteNonQuery();

                DSSitePodmenija.SelectCommand    = @"select Meni_Id, Tekst, f_Sort from Meni where ParentMeni_Id=" + lbPodmeni.SelectedValue + @"
                                            union select Meni_Id, Tekst, f_Sort from Meni where ParentMeni_Id IN
                                            (select Meni_Id from Meni where ParentMeni_Id=" + lbPodmeni.SelectedValue + ") ORDER BY f_Sort";
                DSSitePodmenija.ConnectionString = ConfigurationManager.ConnectionStrings["Konekcija"].ConnectionString;
                DSSitePodmenija.DataBind();
            }
        }
        catch { konekcija.Close(); }
    }
示例#5
0
    protected void btnDodadi_Click(object sender, EventArgs e)
    {
        if (tbPromeniTekst.Text != "")
        {
            String f_Stranica = "0";
            if (cbStranica.Checked)
            {
                f_Stranica = "1";
            }
            SqlConnection connection = new SqlConnection();
            connection.ConnectionString = ConfigurationManager.ConnectionStrings["Konekcija"].ConnectionString;
            SqlCommand komanda = new SqlCommand();
            komanda.Connection = connection;

            String Podmeni = ddlPromeniPodmeni.SelectedValue;
            if (Convert.ToInt32(Podmeni) < 1)
            {
                Podmeni = "NULL";
            }

            if (fuPromeniSlika.PostedFile.ContentLength != 0)
            {
                Bitmap originalBMP = new Bitmap(fuPromeniSlika.FileContent);

                // Calculate the new image dimensions
                int origWidth  = originalBMP.Width;
                int origHeight = originalBMP.Height;
                int sngRatio   = origWidth / origHeight;
                int newWidth   = 20;
                if (sngRatio < 1)
                {
                    sngRatio = 1;
                }
                int newHeight = newWidth / sngRatio;

                int newWidth2 = 70;
                if (sngRatio < 1)
                {
                    sngRatio = 1;
                }
                int newHeight2 = newWidth2 / sngRatio;

                // Create a new bitmap which will hold the previous resized bitmap
                Bitmap   newBMP    = new Bitmap(originalBMP, newWidth, newHeight);
                Graphics oGraphics = Graphics.FromImage(newBMP);
                oGraphics.SmoothingMode = SmoothingMode.AntiAlias; oGraphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
                oGraphics.DrawImage(originalBMP, 0, 0, newWidth, newHeight);
                byte[] data;

                Bitmap   newBMP2    = new Bitmap(originalBMP, newWidth2, newHeight2);
                Graphics oGraphics2 = Graphics.FromImage(newBMP2);
                oGraphics2.SmoothingMode = SmoothingMode.AntiAlias; oGraphics2.InterpolationMode = InterpolationMode.HighQualityBicubic;
                oGraphics2.DrawImage(originalBMP, 0, 0, newWidth2, newHeight2);
                byte[] data2;

                using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
                {
                    newBMP.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
                    stream.Position = 0;
                    data            = new byte[stream.Length];
                    data            = stream.ToArray();

                    newBMP2.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
                    stream.Position = 0;
                    data2           = new byte[stream.Length];
                    data2           = stream.ToArray();
                }

                komanda.CommandText = @"INSERT INTO Meni (Tekst, Opis, ParentMeni_Id, Slika, SlikaGolema, f_Stranica, f_Sort)
                VALUES ( ' " + tbPromeniTekst.Text + "', '" + tbPromeniOpis.Text + @"', " + Podmeni + ", @Slika, @SlikaGolema , " + f_Stranica + @", 
                (SELECT isnull(MAX(f_Sort),0)+1 FROM Meni WHERE ParentMeni_Id = " + Podmeni + ") )";
                komanda.Parameters.Add("@Slika", data);
                komanda.Parameters.Add("@SlikaGolema", data2);
            }
            else
            {
                komanda.CommandText = @"INSERT INTO Meni (Tekst, Opis, ParentMeni_Id, f_Stranica, f_Sort)
                VALUES ( ' " + tbPromeniTekst.Text + "', '" + tbPromeniOpis.Text + @"', " + Podmeni + ", " + f_Stranica + @", 
                (SELECT isnull(MAX(f_Sort),0)+1 FROM Meni WHERE ParentMeni_Id = " + Podmeni + ") )";
            }

            try
            {
                connection.Open();
                komanda.ExecuteNonQuery();
            }
            finally
            {
                connection.Close();

                DSCeloMeni.ConnectionString      = ConfigurationManager.ConnectionStrings["Konekcija"].ConnectionString;
                DSGlavnoMeni.ConnectionString    = ConfigurationManager.ConnectionStrings["Konekcija"].ConnectionString;
                DSPodmeni.ConnectionString       = ConfigurationManager.ConnectionStrings["Konekcija"].ConnectionString;
                DSSitePodmenija.ConnectionString = ConfigurationManager.ConnectionStrings["Konekcija"].ConnectionString;

                DSCeloMeni.SelectCommand      = "SELECT Meni_Id, Tekst FROM Meni UNION SELECT '',''";
                DSGlavnoMeni.SelectCommand    = "SELECT * FROM Meni Where ParentMeni_Id IS NULL ORDER BY f_Sort";
                DSPodmeni.SelectCommand       = "SELECT * FROM Meni WHERE 1=2";
                DSSitePodmenija.SelectCommand = "SELECT * FROM Meni WHERE 1=2";

                DSCeloMeni.DataBind();
                DSGlavnoMeni.DataBind();
                //DSPodmeni.DataBind();
                //DSSitePodmenija.DataBind();

                if (Session["GlavnoMeni"] != "")
                {
                    lbGlavnoMeni.SelectedIndex = Convert.ToInt32(Session["GlavnoMeni"]);
                }

                if (Session["VtoroMeni"] != "")
                {
                    DSPodmeni.SelectCommand    = "SELECT * FROM Meni Where NOT ParentMeni_Id IS NULL AND ParentMeni_Id = " + lbGlavnoMeni.SelectedValue + " ORDER BY f_Sort";
                    DSPodmeni.ConnectionString = ConfigurationManager.ConnectionStrings["Konekcija"].ConnectionString;
                    DSPodmeni.DataBind();
                    lbPodmeni.SelectedIndex = Convert.ToInt32(Session["VtoroMeni"]);
                }
                if (Session["TretoMeni"] != "")
                {
                    DSSitePodmenija.SelectCommand    = @"select Meni_Id, Tekst, f_Sort from Meni where ParentMeni_Id=" + lbPodmeni.SelectedValue + @"
                                            union select Meni_Id, Tekst, f_Sort from Meni where ParentMeni_Id IN
                                            (select Meni_Id from Meni where ParentMeni_Id=" + lbPodmeni.SelectedValue + ") ORDER BY f_Sort";
                    DSSitePodmenija.ConnectionString = ConfigurationManager.ConnectionStrings["Konekcija"].ConnectionString;
                    DSSitePodmenija.DataBind();
                    lbSitePodmenija.SelectedIndex = Convert.ToInt32(Session["TretoMeni"]);
                }

                ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "AlertPopup", "alert('Ставката е додадена!');", true);
            }
        }
    }