private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         this.Cursor = Cursors.WaitCursor;
         OnePurchaseBill myRep = new OnePurchaseBill();
         int             id    = Convert.ToInt32(dgSupp.CurrentRow.Cells[0].Value);
         myRep.SetDataSource(clsPurchase.PrintOne(id));
         FrmCry frm = new FrmCry();
         frm.crystalReportViewer1.ReportSource = myRep;
         this.Cursor = Cursors.Hand;
         frm.ShowDialog();
     }
     catch
     {
         return;
     }
 }
Exemple #2
0
        private void BtnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtOrderID.Text == string.Empty || txtSalesMan.Text == string.Empty || txtDesc.Text == string.Empty ||
                    txtSuppId.Text == string.Empty || txtSuppName.Text == string.Empty || dgPurchase.Rows.Count < 1)
                {
                    MessageBox.Show("احدي الحقول فارغة", "super market", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
                clsPurchase.AddPurchace(Convert.ToInt32(txtOrderID.Text), dateOrder.Value, txtDesc.Text, Convert.ToInt32(txtSuppId.Text), txtSalesMan.Text);

                try
                {
                    for (int i = 0; i < dgPurchase.Rows.Count; i++)
                    {
                        clsPurchase.InsertPurshaceOrderDetails(
                            Convert.ToInt32(txtOrderID.Text),
                            dgPurchase.Rows[i].Cells[0].Value.ToString(),
                            dgPurchase.Rows[i].Cells[1].Value.ToString(),
                            dgPurchase.Rows[i].Cells[2].Value.ToString(),
                            dgPurchase.Rows[i].Cells[3].Value.ToString(),
                            Convert.ToInt32(dgPurchase.Rows[i].Cells[4].Value.ToString()),
                            dgPurchase.Rows[i].Cells[6].Value.ToString(),
                            lastStatus.Text,
                            dgPurchase.Rows[i].Cells[5].Value.ToString());
                    }
                }
                catch
                {
                    return;
                }

                MessageBox.Show("تم حفظ الفاتورة", "Super Market", MessageBoxButtons.OK, MessageBoxIcon.Information);

                try
                {
                    if (MessageBox.Show("هل تريد طباعة هذه الفاتورة", "Super Market", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        this.Cursor = Cursors.WaitCursor;
                        OnePurchaseBill myRep = new OnePurchaseBill();
                        int             id    = Convert.ToInt32(txtOrderID.Text);
                        myRep.SetParameterValue("@Id", id);
                        FrmCry frm = new FrmCry();
                        frm.crystalReportViewer1.ReportSource = myRep;
                        this.Cursor = Cursors.Hand;
                        frm.ShowDialog();
                    }
                }
                catch
                {
                    return;
                }
                ClearAll();
                BtnAdd.Enabled = false;
                BtnNew.Enabled = true;
            }
            catch
            {
                return;
            }
        }