コード例 #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection();
            databaza_con  db  = new databaza_con();// making connection

            con = new SqlConnection(db.Connection());
            con.Open();

            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                DataGridViewRow dr = dataGridView1.Rows[i];
                if (dr.Selected == true)
                {
                    dataGridView1.Rows.RemoveAt(i);
                    try
                    {
                        SqlCommand da = new SqlCommand("delete from tbl_furnitor where id=@id", con);
                        da.Parameters.AddWithValue("@id", id_f.Text);

                        da.ExecuteNonQuery();
                        dataGridView1.Refresh();
                        //cmd.ExecuteNonQuery();
                        pastro();
                        rifreskoDG();
                        con.Close();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                }
            }
        }
コード例 #2
0
        public void rifreskoDG_klient()
        {
            SqlConnection con = new SqlConnection();
            databaza_con  db  = new databaza_con();// making connection

            con = new SqlConnection(db.Connection());
            con.Open();
            DataTable      tbl  = new DataTable();
            SqlDataAdapter dapt = new SqlDataAdapter("select * from tbl_klient", con);

            dapt.Fill(tbl);
            dgw.Rows.Clear();
            int i;

            for (i = 0; i < tbl.Rows.Count; i++)

            {
                dgw.Rows.Add(tbl.Rows[i].ItemArray[0].ToString(), tbl.Rows[i].ItemArray[1].ToString(), tbl.Rows[i].ItemArray[2].ToString(), tbl.Rows[i].ItemArray[3].ToString());
            }
            dgw.ClearSelection();

            con.Close();
        }
コード例 #3
0
        private void TextBox6_TextChanged(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection();
            databaza_con  db  = new databaza_con();// making connection

            con = new SqlConnection(db.Connection());
            con.Open();
            DataTable      tbl  = new DataTable();
            SqlDataAdapter dapt = new SqlDataAdapter("select * from tbl_klient where emri like '%" + TextBox6.Text + "%'", con);

            dapt.Fill(tbl);
            dgw.Rows.Clear();
            int i;

            for (i = 0; i < tbl.Rows.Count; i++)

            {
                dgw.Rows.Add(tbl.Rows[i].ItemArray[0].ToString(), tbl.Rows[i].ItemArray[1].ToString(), tbl.Rows[i].ItemArray[2].ToString(), tbl.Rows[i].ItemArray[3].ToString());
            }
            dgw.ClearSelection();

            con.Close();
        }
コード例 #4
0
        private void shtofurnitor()
        {
            if (btn_ruaj.Text == "Ruaj")
            {
                SqlConnection con = new SqlConnection();
                databaza_con  db  = new databaza_con();// making connection
                con = new SqlConnection(db.Connection());
                con.Open();
                SqlCommand cmd = new SqlCommand("INSERT INTO tbl_furnitor(emri,adresa, nr_cel,kompania) VALUES('" + emri_f.Text + "','" + adresa_f.Text + "','" + nr_f.Text + "','" + kompania.Text + "')", con);

                cmd.ExecuteNonQuery();
                dataGridView1.Refresh();
                MessageBox.Show("Regjistrimi u krye");
                pastro();
                rifreskoDG();
                con.Close();
            }
            else
            {
                SqlConnection con = new SqlConnection();
                databaza_con  db  = new databaza_con();// making connection
                con = new SqlConnection(db.Connection());
                con.Open();
                SqlCommand cm = new SqlCommand("update  tbl_furnitor SET emri=@k,adresa=@art,nr_cel=@b,kompania=@kp where id=@id", con);
                cm.Parameters.AddWithValue("@id", id_f.Text);
                cm.Parameters.AddWithValue("@k", emri_f.Text);
                cm.Parameters.AddWithValue("@art", adresa_f.Text);
                cm.Parameters.AddWithValue("@b", nr_f.Text);
                cm.Parameters.AddWithValue("@kp", kompania.Text);
                cm.ExecuteNonQuery();
                dataGridView1.Refresh();
                MessageBox.Show("Perditesimi u krye");
                pastro();
                rifreskoDG();
                con.Close();
            }
        }
コード例 #5
0
        private void shtoklient()
        {
            if (btnSave.Text == "Ruaj")
            {
                SqlConnection con = new SqlConnection();
                databaza_con  db  = new databaza_con();// making connection
                con = new SqlConnection(db.Connection());
                con.Open();
                SqlCommand cmd = new SqlCommand("INSERT INTO tbl_klient(emri,adresa, nrcel) VALUES('" + txtSupName.Text + "','" + txtSupAddress.Text + "','" + txtSupPhone.Text + "')", con);

                cmd.ExecuteNonQuery();
                dgw.Refresh();
                MessageBox.Show("Regjistrimi u krye");
                pastro();
                rifreskoDG_klient();
                con.Close();
            }
            else
            {
                SqlConnection con = new SqlConnection();
                databaza_con  db  = new databaza_con();// making connection
                con = new SqlConnection(db.Connection());
                con.Open();
                SqlCommand cm = new SqlCommand("update  tbl_klient SET emri=@k,adresa=@art,nrcel=@b where id=@id", con);
                cm.Parameters.AddWithValue("@id", txtSupID.Text);
                cm.Parameters.AddWithValue("@k", txtSupName.Text);
                cm.Parameters.AddWithValue("@art", txtSupAddress.Text);
                cm.Parameters.AddWithValue("@b", txtSupPhone.Text);
                cm.ExecuteNonQuery();
                dgw.Refresh();
                MessageBox.Show("Perditesimi u krye");
                pastro();
                rifreskoDG_klient();
                con.Close();
            }
        }