Exemplo n.º 1
0
        //check all columns for matching word
        public static List <client_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 client_order where id_client_order like @word or type_client_order like @word or cin like @word or nom like @word or telephone 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 <client_order> listCl = new List <client_order>();

            while (dr.Read())
            {
                client_order cl = new client_order();
                cl.id_client_order   = (int)dr["id_client_order"];
                cl.type_client_order = (string)dr["type_client_order"];
                cl.cin                = (string)dr["cin"];
                cl.nom                = (string)dr["nom"];
                cl.telephone          = (string)dr["telephone"];
                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);
        }
Exemplo n.º 2
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 && dataGridView1.Rows.Count > 0)
         {
             client_order c = client_order.findById((int)dataGridView1.CurrentRow.Cells[0].Value);
             c.delete();
             history.AddHistory("موكلي الأمر", "حدف", dataGridView1.CurrentRow.Cells[0].Value.ToString());
             MessageBox.Show("تم الحذف بنجاح");
             refresh();
         }
         else
         {
         }
     }
 }
Exemplo n.º 3
0
        //find client order by id_client_order
        public static client_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 client_order where id_client_order = @id";
            cmd.Parameters.Add("@id", id);
            dr = cmd.ExecuteReader();
            client_order cl = new client_order();

            dr.Read();
            cl.id_client_order   = id;
            cl.type_client_order = (string)dr["type_client_order"];
            cl.cin                = (string)dr["cin"];
            cl.nom                = (string)dr["nom"];
            cl.telephone          = (string)dr["telephone"];
            cl.representant_legal = (string)dr["representant_legal"];
            cl.registre_commerce  = (string)dr["registre_commerce"];
            cl.adresse            = (string)dr["adresse"];
            cn.Close();
            dr.Close();
            return(cl);
        }
Exemplo n.º 4
0
        private void btn_ajouter_Click(object sender, EventArgs e)
        {
            client_order cl = new client_order();

            if (txb_name.Text != "" && txb_genre_client.Text != "")
            {
                cl.type_client_order = (string)txb_genre_client.SelectedItem;
                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.telephone = txb_tele.Text;
                int id = cl.save();
                history.AddHistory("موكلي الأمر", "إضافة", id.ToString());
                MessageBox.Show("تمت الإضافة بنجاح");
                refresh();
                btn_ajouter.Enabled = false;
            }
            else
            {
                MessageBox.Show("يجب ادخال البيانات");
            }
        }
Exemplo n.º 5
0
        private void btn_edit_Click(object sender, EventArgs e)
        {
            client_order cl = new client_order();

            if (dataGridView1.Rows.Count > 0 && txb_ident_client.Text != "")
            {
                cl.id_client_order   = int.Parse(txb_ident_client.Text);
                cl.type_client_order = (string)txb_genre_client.SelectedItem;
                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.telephone = txb_tele.Text;
                cl.update();
                history.AddHistory("موكلي الأمر", "تحديث", cl.id_client_order.ToString());
                MessageBox.Show("تم تحديث الملومات");
                refresh();
            }
            else
            {
                MessageBox.Show("المرجو تحديد الحقل المراد تعديله");
            }
        }