Beispiel #1
0
        //check all columns for a matching word
        public static List <adv_order> find(string word)
        {
            SqlConnection cn  = connection.getConnection();
            SqlCommand    cmd = new SqlCommand();
            SqlDataReader dr;

            if (cn.State == ConnectionState.Closed)
            {
                cn.Open();
            }
            cmd.Connection  = cn;
            cmd.CommandText = "select * from adv_order where id_adv_order like @word or type_adv_order like @word or cin like @word or nom like @word or representant_legal like @word or registre_commerce like @word or adresse like @word";
            cmd.Parameters.Add("@word", word);
            dr = cmd.ExecuteReader();
            List <adv_order> listCl = new List <adv_order>();

            while (dr.Read())
            {
                adv_order cl = new adv_order();
                cl.id_adv_order       = (int)dr["id_adv_order"];
                cl.type_adv_order     = (string)dr["type_adv_order"];
                cl.cin                = (string)dr["cin"];
                cl.nom                = (string)dr["nom"];
                cl.representant_legal = (string)dr["representant_legal"];
                cl.registre_commerce  = (string)dr["registre_commerce"];
                cl.adresse            = (string)dr["adresse"];
                listCl.Add(cl);
            }
            dr.Close();
            cn.Close();
            return(listCl);
        }
Beispiel #2
0
        //find a record by it's id
        public static adv_order findById(int id)
        {
            SqlConnection cn  = connection.getConnection();
            SqlCommand    cmd = new SqlCommand();
            SqlDataReader dr;

            if (cn.State == ConnectionState.Closed)
            {
                cn.Open();
            }
            cmd.Connection  = cn;
            cmd.CommandText = "select * from adv_order where id_adv_order = @id";
            cmd.Parameters.Add("@id", id);
            dr = cmd.ExecuteReader();
            dr.Read();
            adv_order advOrd = new adv_order();

            advOrd.id_adv_order       = id;
            advOrd.type_adv_order     = (string)dr["type_adv_order"];
            advOrd.cin                = (string)dr["cin"];
            advOrd.nom                = (string)dr["nom"];
            advOrd.representant_legal = (string)dr["representant_legal"];
            advOrd.registre_commerce  = (string)dr["registre_commerce"];
            advOrd.adresse            = (string)dr["adresse"];
            cn.Close();
            dr.Close();
            return(advOrd);
        }
Beispiel #3
0
 private void btn_remove_Click(object sender, EventArgs e)
 {
     if (dataGridView1.Rows.Count == 0)
     {
         MessageBox.Show("الجدول غير ممتلئ");
     }
     else
     {
         MessageBoxManager.Yes = "نعم";
         MessageBoxManager.No  = "لا";
         MessageBoxManager.Register();
         DialogResult dr = MessageBox.Show("هل أنت متأكد من الحدف ؟؟", "تنبيه", MessageBoxButtons.YesNo);
         MessageBoxManager.Unregister();
         if (dr == DialogResult.Yes)
         {
             adv_order ad = adv_order.findById((int)dataGridView1.CurrentRow.Cells[0].Value);
             ad.delete();
             history.AddHistory("خصوم الأمر", "حذف", dataGridView1.CurrentRow.Cells[0].Value.ToString());
             MessageBox.Show("تم الحذف بنجاح");
             refresh();
         }
         else
         {
         }
     }
 }
Beispiel #4
0
        private void btn_ajouter_Click(object sender, EventArgs e)
        {
            adv_order adv = new adv_order();

            if (CB_genre_Adv.Text != "" && txb_name.Text != "")
            {
                adv.type_adv_order     = CB_genre_Adv.Text;
                adv.cin                = txb_cin.Text;
                adv.nom                = txb_name.Text;
                adv.representant_legal = txb_juridique.Text;
                adv.registre_commerce  = txb_num_societe.Text;
                adv.adresse            = txb_adresse.Text;
                int id = adv.save();
                history.AddHistory("خصوم الأمر", "إضافة", id.ToString());
                MessageBox.Show("تمت الإضافة بنجاح");
                refresh();
                btn_ajouter.Enabled = false;
            }
            else
            {
                MessageBox.Show("يجب ادخال البيانات");
            }
        }
Beispiel #5
0
        private void btn_edit_Click(object sender, EventArgs e)
        {
            adv_order cl = new adv_order();

            if (dataGridView1.Rows.Count > 0 && TxB_ident.Text != "")
            {
                cl.id_adv_order      = int.Parse(TxB_ident.Text);
                cl.type_adv_order    = CB_genre_Adv.Text;
                cl.registre_commerce = txb_num_societe.Text;
                cl.nom = txb_name.Text;
                cl.representant_legal = txb_juridique.Text;
                cl.cin     = txb_cin.Text;
                cl.adresse = txb_adresse.Text;
                cl.update();
                history.AddHistory("خصوم الأمر", "تحديث", cl.id_adv_order.ToString());
                MessageBox.Show("تم تحديث الملومات");
                refresh();
            }
            else
            {
                MessageBox.Show("المرجو تحديد الحقل المراد تعديله");
            }
        }