private void btnSave_Click(object sender, EventArgs e) { OleDbDataAdapter da1 = new OleDbDataAdapter("select Sup_Name from Supplier", con); DataTable dt1 = new DataTable(); da1.Fill(dt1); int found = 0; for (int i = 0; i < dt1.Rows.Count; i++) { if (dt1.Rows[i][0].ToString().Equals(cmbSupName.Text)) { found = 1; } } try { if (cmbSupName.Text.Equals("") || Amount.Text.Equals("") || rtDiscreption.Text.Equals("") || found != 1) { MessageBox.Show("الرجاء ملىء كل الحقول و التأكد من اسم العميل انه موجود بالاصل"); return; } else { con.Open(); OleDbCommand cmd = new OleDbCommand("insert into Sup_Pay (Sup_Pay,Sup_Name,S_P_Date,Discreption)" + " values ('" + Amount.Text + "','" + cmbSupName.Text + "','" + DateTime.Now.Date.ToShortDateString() + "','" + rtDiscreption.Text + "')", con); cmd.ExecuteNonQuery(); con.Close(); FRM_PaytoSup pts = new FRM_PaytoSup(); con.Open(); OleDbCommand cmd1 = new OleDbCommand("insert into BoxInfo (Proc_type,Proc_Date,Deposit,Withdraw,Discreption)" + " values (' دفع الى " + cmbSupName.Text + "','" + DateTime.Now.Date.ToShortDateString() + "','0','" + Amount.Text + "','" + rtDiscreption.Text + "')", con); cmd1.ExecuteNonQuery(); con.Close(); MessageBox.Show("تمت العملية بنجاح"); cmbSupName.Items.Clear(); cmbSupName.Text = ""; Amount.Text = rtDiscreption.Text = ""; } } catch (Exception ex) { MessageBox.Show("هناك خطأ في البيانات المدخلة"); } }
private void TM_ToSup_Click(object sender, EventArgs e) { FRM_PaytoSup ps = new FRM_PaytoSup(); ps.ShowDialog(); }