Ejemplo n.º 1
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         rpt.set_Seasonal_disbursements(Convert.ToInt32(txtID.Text), Convert.ToInt32(txtAmonut.Text));
         MessageBox.Show("تمت الاضافة بنجاح", "الاضافة", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Ejemplo n.º 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                int remaining = Convert.ToInt32(txtReamining.Text);
                if (txtName.Text == string.Empty || txtName.Text == "اسم الزبون")
                {
                    MessageBox.Show("الرجاء ادخال اسم الزبون");
                }
                else if (txtAmountReceived.Text == string.Empty)
                {
                    MessageBox.Show("الرجاء ادخال المبلغ الواصل");
                }
                else if (txtSeasonName.Text == string.Empty || txtSeasonName.Text == "اختيار المواسم")
                {
                    MessageBox.Show("الرجاء اختيار الموسم");
                }
                else if (remaining <= 0) // If the invoice is paid
                {
                    //insert the informations of invoive
                    doc.add_doc(Convert.ToInt32(txtCusID.Text), txtID.Text, txtNote.Text, Convert.ToDouble(
                                    txtTotal.Text), Convert.ToDouble(txtAmountReceived.Text), Convert.ToDouble(txtReamining.Text)
                                , Convert.ToInt32(txtSeasonID.Text), bunifuDatepicker1.Value);

                    //insert the detiles of invoive
                    for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
                    {
                        doc.add_doc_detail(Convert.ToInt32(this.dataGridView1.Rows[i].Cells[0].Value),
                                           this.dataGridView1.Rows[i].Cells[1].Value.ToString(),
                                           Convert.ToInt32(txtID.Text), Convert.ToInt32(dataGridView1.Rows[i].Cells[3].Value),
                                           Convert.ToDouble(dataGridView1.Rows[i].Cells[2].Value),
                                           Convert.ToDouble(dataGridView1.Rows[i].Cells[4].Value));
                    }

                    MessageBox.Show("تم الحفظ بنجاح   ", "عملية الحفظ", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                }
                //if there are debt
                else if ((remaining) > 0)
                {
                    //insert the informations of invoive
                    doc.add_doc(Convert.ToInt32(txtCusID.Text), txtID.Text, txtNote.Text, Convert.ToDouble(
                                    txtTotal.Text), Convert.ToDouble(txtAmountReceived.Text), Convert.ToDouble(txtReamining.Text)
                                , Convert.ToInt32(txtSeasonID.Text), bunifuDatepicker1.Value);

                    //insert the detiles of invoive
                    for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
                    {
                        doc.add_doc_detail(Convert.ToInt32(this.dataGridView1.Rows[i].Cells[0].Value),
                                           this.dataGridView1.Rows[i].Cells[1].Value.ToString(),
                                           Convert.ToInt32(txtID.Text), Convert.ToInt32(dataGridView1.Rows[i].Cells[3].Value),
                                           Convert.ToDouble(dataGridView1.Rows[i].Cells[2].Value),
                                           Convert.ToDouble(dataGridView1.Rows[i].Cells[4].Value));
                    }

                    debt.add_debt_detail(Convert.ToInt32(txtID.Text), Convert.ToInt32(txtCusID.Text), Convert.ToDouble(txtReamining.Text));


                    MessageBox.Show("تم الحفظ بنجاح   ", "عملية الحفظ", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                }



                // set seasonal_revenue
                rpt.set_seasonal_revenue(Convert.ToInt32(txtSeasonID.Text), totalMoney);



                // coumput Prices of articles
                for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
                {
                    Seasonal_disbursements += Convert.ToInt32(dataGridView1.Rows[i].Cells[3].Value) *
                                              Convert.ToDouble(rpt.get_purchasing_price(Convert.ToInt32(dataGridView1.Rows[i].Cells[0].Value)).Rows[0][0]);
                }
                // set Seasonal_disbursements
                rpt.set_Seasonal_disbursements(Convert.ToInt32(txtSeasonID.Text), Seasonal_disbursements);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }