Пример #1
0
        private void Btn_printCheken_Click(object sender, EventArgs e)
        {
            try
            {
                if (dataGridView1.Rows.Count > 0)
                {
                    if (cmb_supplier.Text == "")
                    {
                        MessageBox.Show("من فضلك قم باادخال اسم المورد");
                        return;
                    }


                    dt = s.VildateSUppliers(Convert.ToInt32(cmb_supplier.SelectedValue), cmb_supplier.Text);
                    if (dt.Rows.Count > 0)
                    {
                        s.AddPhrichise(Convert.ToInt32(cmb_supplier.SelectedValue), dateTimePicker1.Value);
                        txt_num.Text = s.LastsuppliersID().Rows[0][0].ToString();
                        for (int i = 0; i < dataGridView1.Rows.Count; i++)
                        {
                            s.AddPhrichiseDetails(Convert.ToInt32(txt_num.Text), Convert.ToInt32(dataGridView1.Rows[i].Cells[0].Value), Convert.ToDecimal(dataGridView1.Rows[i].Cells[2].Value));
                        }
                        MessageBox.Show("تم حفظ", "عمليه الحفظ ", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                        clear();
                    }

                    else if (dt.Rows.Count == 0)
                    {
                        s.addSuppliers(cmb_supplier.Text);
                        txt_cust.Text = s.LastsuppliersNameID().Rows[0][0].ToString();
                        s.AddPhrichise(Convert.ToInt32(txt_cust.Text), dateTimePicker1.Value);
                        txt_num.Text = s.LastsuppliersID().Rows[0][0].ToString();
                        for (int i = 0; i < dataGridView1.Rows.Count; i++)
                        {
                            s.AddPhrichiseDetails(Convert.ToInt32(txt_num.Text), Convert.ToInt32(dataGridView1.Rows[i].Cells[0].Value), Convert.ToDecimal(dataGridView1.Rows[i].Cells[2].Value));
                        }

                        MessageBox.Show("تم حفظ", "عمليه الحفظ ", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                        cmb_supplier.DataSource    = s.SelectCompoSupplier();
                        cmb_supplier.DisplayMember = "Name";
                        cmb_supplier.ValueMember   = "Sup_id";
                        clear();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }