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); } }
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("يجب ملئ الخانات"); } }