Beispiel #1
0
        //find an order files by it's ID
        public static List <PjOrder> findOrderPj(string idOrder)
        {
            SqlConnection  cn  = connection.getConnection();
            SqlCommand     cmd = new SqlCommand();
            SqlDataReader  dr;
            List <PjOrder> listPj = new List <PjOrder>();

            if (cn.State == ConnectionState.Closed)
            {
                cn.Open();
            }
            cmd.Connection  = cn;
            cmd.CommandText = "select * from PJ_order where id_order like @order";

            cmd.Parameters.Add("@order", idOrder);
            dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                PjOrder pj = new PjOrder();
                pj.id_pj = (int)dr["id_pj"];
                pj.photo = (byte[])dr["photo"];
                pj.titre = (string)dr["titre"];
                DateTime d = new DateTime();
                d = (DateTime)dr["date_enregistrement"];
                pj.date_enregistrement = d.ToShortDateString();
                pj.id_order            = (string)dr["id_order"];
                listPj.Add(pj);
            }
            dr.Close();
            cn.Close();
            return(listPj);
        }
Beispiel #2
0
        private void btn_ajouter_Click(object sender, EventArgs e)
        {
            try
            {
                //order setup
                ord.id_order              = txb_num_order.Text;
                ord.type                  = (string)comboBox1.SelectedItem;
                ord.type_tribuna          = (string)cb_genre_trubinal.SelectedValue;
                ord.signe_order           = textBox1.Text;
                ord.id_ville              = (string)cb_ville.SelectedValue;
                ord.commissaire_judicaire = txb_mofawed.Text;
                ord.decision              = txb_disesion.Text;
                ord.date_order            = DateTime.Parse(DateTime.Now.ToShortDateString());
                if (textBox2.Text == "" || txb_ide_adv.Text == "")
                {
                    MessageBox.Show("المرجو إعادة ملئ البيانات");
                }
                else
                {
                    ord.id_client_order     = int.Parse(textBox2.Text.ToString());
                    ord.id_adversaire_order = int.Parse(txb_ide_adv.Text.ToString());
                    ord.save();


                    //save PJ setup
                    if (u == 1)
                    {
                        foreach (string fileName in of.FileNames)
                        {
                            try
                            {
                                FileInfo     fi       = new FileInfo(fileName);
                                PjOrder      pjOrder1 = new PjOrder();
                                byte[]       img      = null;
                                FileStream   f        = new FileStream(of.FileName, FileMode.Open);
                                BinaryReader br       = new BinaryReader(f);
                                img = br.ReadBytes((int)f.Length);
                                f.Close();
                                pjOrder1.photo = img;
                                pjOrder1.titre = Path.GetFileName(of.FileName);
                                pjOrder1.date_enregistrement = DateTime.Now.ToShortDateString();
                                pjOrder1.id_order            = ord.id_order;
                                pjOrder1.save();
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
                            }
                        }
                        u = 0;
                    }
                    history.AddHistory("الأمر", "إضافة", ord.id_order);
                    MessageBox.Show("تمت الإضافة بنجاح");
                }
            }
            catch (Exception nn)
            {
                MessageBox.Show("المرجو إعادة ملئ البيانات" + nn.Message);
            }
        }
Beispiel #3
0
 private void textBox1_TextChanged(object sender, EventArgs e)
 {
     if (textBox1.Text == "")
     {
         refresh();
     }
     else
     {
         string         order = textBox1.Text;
         List <PjOrder> list  = PjOrder.findOrderPj(order);
         dataGridView1.DataSource = list;
         dataGridView1.Refresh();
     }
 }
Beispiel #4
0
        //find a file by it's id
        public PjOrder find(int id)
        {
            if (cn.State == ConnectionState.Closed)
            {
                cn.Open();
            }
            cmd.Connection  = cn;
            cmd.CommandText = "select * from where id_pj = @id";
            cmd.Parameters.Add("@id", id);
            dr = cmd.ExecuteReader();
            PjOrder pj = new PjOrder();

            pj.id_pj = (int)dr["id_pj"];
            pj.photo = (byte[])dr["photo"];
            pj.titre = (string)dr["titre"];
            pj.date_enregistrement = (string)dr["date_enregistrement"];
            pj.id_order            = (string)dr["id_order"];
            dr.Close();
            return(pj);
        }
Beispiel #5
0
 private void btn_add_Click(object sender, EventArgs e)
 {
     //save
     if (u == 1 && cb_num_cause.Text != "")
     {
         foreach (string fileName in of.FileNames)
         {
             try
             {
                 FileInfo     fi       = new FileInfo(fileName);
                 PjOrder      pjOrder1 = new PjOrder();
                 byte[]       img      = null;
                 FileStream   f        = new FileStream(of.FileName, FileMode.Open);
                 BinaryReader br       = new BinaryReader(f);
                 img = br.ReadBytes((int)f.Length);
                 f.Close();
                 pjOrder1.photo = img;
                 pjOrder1.titre = Path.GetFileName(of.FileName);
                 pjOrder1.date_enregistrement = DateTime.Now.ToShortDateString();
                 pjOrder1.id_order            = (string)cb_num_cause.SelectedValue;
                 int id = pjOrder1.save();
                 history.AddHistory("وثائق الامر", "إضافة", id.ToString());
             }
             catch (Exception ex)
             {
                 MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
             }
         }
         MessageBox.Show("تمت الإضافة بنجاح");
         u = 0;
     }
     else
     {
         MessageBox.Show("يجب ملئ الخانات");
     }
 }