Exemple #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            OleDbDataAdapter da1 = new OleDbDataAdapter("select Cus_Name from Customer", 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(cmbCusName.Text))
                {
                    found = 1;
                }
            }
            try
            {
                if (cmbCusName.Text.Equals("") || Amount.Text.Equals("") || rtDiscreption.Text.Equals("") || found != 1)
                {
                    MessageBox.Show("الرجاء ملىء كل الحقول و التأكد من أن اسم العميل مدخل بالفعل");
                    return;
                }
                else
                {
                    con.Open();
                    OleDbCommand cmd = new OleDbCommand("insert into Cus_Pay (C_A_Pay,Cus_Name,C_P_Date,Discreption)" +
                                                        " values ('" + Amount.Text + "','" + cmbCusName.Text + "','" + DateTime.Now.Date.ToShortDateString() + "','" + rtDiscreption.Text + "')", con);
                    cmd.ExecuteNonQuery();
                    con.Close();

                    FRM_CashFromCus cfc = new FRM_CashFromCus();
                    con.Open();
                    OleDbCommand cmd1 = new OleDbCommand("insert into BoxInfo (Proc_type,Proc_Date,Deposit,Withdraw,Discreption)" +
                                                         " values (' قبض من " + cmbCusName.Text + "','" + DateTime.Now.Date.ToShortDateString() + "','" + Amount.Text + "','0','" + rtDiscreption.Text + "')", con);
                    cmd1.ExecuteNonQuery();
                    con.Close();

                    MessageBox.Show("تمت العملية بنجاح");
                    cmbCusName.Items.Clear();
                    cmbCusName.Text = "";
                    Amount.Text     = rtDiscreption.Text = "";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("هناك خطأ في البيانات المدخلة");
            }
        }
        private void TM_FromCus_Click(object sender, EventArgs e)
        {
            FRM_CashFromCus cfc = new FRM_CashFromCus();

            cfc.ShowDialog();
        }