Пример #1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (!valOffer.Validate())
            {
                return;
            }

            if (!changeOffer)
            {
                a.addTraineeProfile(traineeID, cmbOffers, dtBegin, dtEnd, txtPrice, txtPaid, txtCarry, sessionNum, freezing, invitations, spa, massage, others, inbody,
                                    radioGroup1, type, ref logID, cmbTrainers, cmbEmployees);

                if (Convert.ToDouble(txtPaid.Text) == 0)
                {
                    a.addCash(1, "تجديد إشتراك", "", txtPaid.Text, "", traineeName, cmbOffers.Text);
                }
                else if (Convert.ToDouble(txtPaid.Text) > 0)
                {
                    a.addCash(1, "تجديد إشتراك", Properties.Settings.Default.RecieptID.ToString(), txtPaid.Text, radioGroup1.Text, traineeName, cmbOffers.Text);
                    if (radioGroup1.SelectedIndex == 0)
                    {
                        u.updateTraffic(Convert.ToDouble(txtPaid.Text), 0);
                    }
                    f.fillRpt(traineeName, txtPaid, offerName, Convert.ToDateTime(dtBegin.EditValue), Convert.ToDateTime(dtEnd.EditValue), txtCarry.Text, radioGroup1.SelectedIndex);
                    Properties.Settings.Default.RecieptID = ++Properties.Settings.Default.RecieptID;
                    Properties.Settings.Default.Save();
                }
                XtraMessageBox.Show("تمت الإضافة بنجاح", "إضافة", MessageBoxButtons.OK, MessageBoxIcon.Information);
                DialogResult = DialogResult.OK;
            }
            if (changeOffer)
            {
                var tp = db.TraineeProfiles.Find(logID);
                tp.OfferID     = Convert.ToInt32(cmbOffers.EditValue);
                tp.From        = Convert.ToDateTime(dtBegin.EditValue);
                tp.To          = Convert.ToDateTime(dtEnd.EditValue);
                tp.Price       = Convert.ToDouble(txtPrice.Text);
                tp.Paid        = Convert.ToDouble(txtPaid.Text);
                tp.Carry       = Convert.ToDouble(txtCarry.Text);
                tp.SessionsNum = sessionNum - tp.SessionsNum;
                tp.Invitations = invitations - tp.Invitations;
                tp.Massage     = massage - tp.Massage;
                tp.SPA         = spa - tp.SPA;
                tp.Others      = others - tp.Others;
                tp.Freezing    = freezing - tp.Freezing;
                db.SaveChanges();

                if (Convert.ToInt32(txtPaid.Text) == 0)
                {
                    a.addCash(1, "تغيير إشتراك", "", txtPaid.Text, "", traineeName, cmbOffers.Text);
                }
                if (Convert.ToInt32(txtPaid.Text) > 0)
                {
                    if (Convert.ToDouble(txtCarry.Text) > 0)
                    {
                        a.addCash(1, "تغيير إشتراك", Properties.Settings.Default.RecieptID.ToString(), txtPaid.Text, radioGroup1.Text, traineeName, cmbOffers.Text);
                        Properties.Settings.Default.RecieptID = ++Properties.Settings.Default.RecieptID;
                        Properties.Settings.Default.Save();
                    }
                    else if (Convert.ToDouble(txtCarry.Text) < 0)
                    {
                        a.addOutcome(1, "تغيير إشتراك", "R" + Properties.Settings.Default.RecieptIDOut, txtPaid.Text, DateTime.Now);
                        Properties.Settings.Default.RecieptIDOut = ++Properties.Settings.Default.RecieptIDOut;
                        Properties.Settings.Default.Save();
                    }

                    f.fillRpt(traineeName, txtPaid, offerName, Convert.ToDateTime(dtBegin.EditValue), Convert.ToDateTime(dtEnd.EditValue), txtCarry.Text, radioGroup1.SelectedIndex);
                }
                XtraMessageBox.Show("تم التعديل بنجاح", "إضافة", MessageBoxButtons.OK, MessageBoxIcon.Information);
                DialogResult = DialogResult.OK;
            }

            frmMain frm = new frmMain();

            frm.checkTraineesProfile();
        }