public int Update(KategoriteKlubore model)
        {
            try
            {
                SqlConnection sqlcon = new SqlConnection(_connectionString);
                sqlcon.Open();
                SqlCommand command = new SqlCommand("[dbo].[usp_Kategorit_ShtoOseEditoKategori]", sqlcon);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@Emertimi", model.Emertimi);
                command.Parameters.AddWithValue("@Prej", model.Prej);
                command.Parameters.AddWithValue("@Deri", model.Deri);
                command.Parameters.AddWithValue("@InsertBy", 1);
                command.Parameters.AddWithValue("@InsertDate", "06/05/2020");
                command.Parameters.AddWithValue("@LUB", 1);
                command.Parameters.AddWithValue("@LUD", "06/05/2020");
                command.Parameters.AddWithValue("@LUN", 1);
                command.Parameters.AddWithValue("@KategoriaID", model.KategoriaID);
                command.Parameters.AddWithValue("@KlubiID", 1);

                int rowAffected = command.ExecuteNonQuery();
                command.Dispose();
                sqlcon.Close();
                sqlcon.Dispose();
                return(rowAffected);
            }
            catch (Exception e)
            {
                return(-1);
            }
        }
 public void Regjistro(KategoriteKlubore g)
 {
     try
     {
         KategoriteKluboreDAL dal = new KategoriteKluboreDAL();
         dal.Shto(g);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public void Edito(KategoriteKlubore g)
 {
     try
     {
         KategoriteKluboreDAL dal = new KategoriteKluboreDAL();
         dal.Update(g);
     }
     catch (Exception)
     {
         throw;
     }
 }
        private void button1_Click(object sender, EventArgs e)
        {
            var rez = MessageBox.Show("A jeni te sigurt qe deshironi te fshij", "Kujdes", MessageBoxButtons.YesNo);

            if (rez == DialogResult.Yes)
            {
                KategoriteKlubore kl = new KategoriteKlubore();
                kl.KategoriaID = int.Parse(txtGjejmeid.Text.Trim());
                KategoriteKluboreBLL klubiDAL = new KategoriteKluboreBLL();
                klubiDAL.Fshij(kl);
                txtGjejmeid.Text = "";
            }
        }
        private void button2_Click(object sender, EventArgs e)
        {
            KategoriteKlubore kl = new KategoriteKlubore();

            kl.KategoriaID = int.Parse(txtGjejmeid.Text.Trim());
            KategoriteKluboreBLL kategorite = new KategoriteKluboreBLL();

            kategorite.GjejKategorinMeID(kl);
            txtEmertimi.Text = kl.Emertimi;
            txtPrej.Text     = kl.Prej.ToString();
            txtDeri.Text     = kl.Deri.ToString();
            panel2.Visible   = true;
        }
 public int GjejKategorinMeID(KategoriteKlubore g)
 {
     try
     {
         KategoriteKluboreDAL dal = new KategoriteKluboreDAL();
         dal.GjejKlubMeID(g);
         int rowsAffected = g.KategoriaID;
         return(rowsAffected);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public void GjejKlubMeID(KategoriteKlubore kategorite)
        {
            SqlConnection  sqlcon         = new SqlConnection(_connectionString);
            SqlDataAdapter sqlDataAdapter = new SqlDataAdapter("usp_Kategoria_GjejKategoriMeID", sqlcon);

            sqlDataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure;
            sqlDataAdapter.SelectCommand.Parameters.AddWithValue("@KategoriaID", kategorite.KategoriaID);
            DataTable dt = new DataTable();

            sqlDataAdapter.Fill(dt);
            sqlDataAdapter.Dispose();
            sqlcon.Close();

            kategorite.Emertimi = dt.Rows[0]["Emertimi"].ToString();
            kategorite.Prej     = int.Parse(dt.Rows[0]["Prej"].ToString());
            kategorite.Deri     = int.Parse(dt.Rows[0]["Deri"].ToString());
        }
        private void button1_Click(object sender, EventArgs e)
        {
            var rez = MessageBox.Show("A jeni te sigurt qe deshironi te editoni", "Kujdes", MessageBoxButtons.YesNo);

            if (rez == DialogResult.Yes)
            {
                KategoriteKlubore kategorit = new KategoriteKlubore();
                kategorit.Emertimi    = txtEmertimi.Text.Trim();
                kategorit.Deri        = int.Parse(txtDeri.Text.Trim());
                kategorit.Prej        = int.Parse(txtPrej.Text.Trim());
                kategorit.KategoriaID = int.Parse(txtGjejmeid.Text);
                KategoriteKluboreBLL kategori = new KategoriteKluboreBLL();
                kategori.Edito(kategorit);

                txtEmertimi.Text = txtDeri.Text = txtPrej.Text = "";
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (txtEmertimi.Text == " " || txtDeri.Text == "" || txtPrej.Text == "")
            {
                MessageBox.Show("Plotesoni te gjitha fushat");
            }
            else
            {
                KategoriteKlubore kategorit = new KategoriteKlubore();
                kategorit.Emertimi = txtEmertimi.Text.Trim();
                kategorit.Deri     = int.Parse(txtDeri.Text.Trim());
                kategorit.Prej     = int.Parse(txtPrej.Text.Trim());

                KategoriteKluboreBLL kategoria = new KategoriteKluboreBLL();
                kategoria.Regjistro(kategorit);

                txtEmertimi.Text = txtDeri.Text = txtPrej.Text = "";
                MessageBox.Show("U regjistrua me sukses");
            }
        }
 public int FshijMeID(KategoriteKlubore kategorite)
 {
     try
     {
         SqlConnection sqlcon = new SqlConnection(_connectionString);
         sqlcon.Open();
         SqlCommand sqc = new SqlCommand("[dbo].[usp_Kategoria_FshijKategoriMeID]", sqlcon);
         sqc.CommandType = CommandType.StoredProcedure;
         sqc.Parameters.AddWithValue("@KategoriaID", kategorite.KategoriaID);
         int result = sqc.ExecuteNonQuery();
         sqc.Dispose();
         sqlcon.Close();
         sqlcon.Dispose();
         return(result);
     }
     catch (Exception e)
     {
         return(-1);
     }
 }