Ejemplo n.º 1
0
        private void bSave_Click(object sender, EventArgs e)
        {
            PersianDateFormatter pdf = new PersianDateFormatter();
            AppointmentRepository appRepo = new AppointmentRepository();
            ContractRepository cRepo = new ContractRepository();
            Contract contract = cRepo.getContract(contractId);

            Appointment app = new Appointment();
            string description = "";
            int value = 0;
            foreach (var item in radCheckedDropDownList1.CheckedItems)
            {
                description += item.DisplayValue.ToString() + "/";
                value += Convert.ToInt32(item.Value);
            }
            contract.ContractPayment += value;
            cRepo.updateContract(contract);
            app.ContractId = contractId;
            description = description.Remove(description.Length - 1);
            app.Description = description;

            app.AppointmentDate = pdf.convert(tDate.Text);
            TimeSpan ts = new TimeSpan(tTime.Value.TimeOfDay.Hours, tTime.Value.TimeOfDay.Minutes, 0);
            app.AppointmentTime = ts;
            appRepo.addAppointment(app);
        }
Ejemplo n.º 2
0
 private void bSave_Click(object sender, EventArgs e)
 {
     ContractRepository crep = new ContractRepository();
     Contract contract = crep.getContract(contractId);
     PaymentRepository repository = new PaymentRepository();
     PersianDateFormatter pdf = new PersianDateFormatter();
     Payment payment = new Payment();
     payment.ContractId = contractId;
     payment.AmountOfPayment = Convert.ToInt32(tPayment.Text);
     payment.DateOfPayment = pdf.convert(tPaymentDate.Text);
     DateModel dm = pdf.getSplittedDateIntegers(payment.DateOfPayment.Value);
     payment.Year = dm.Year;
     payment.Month = dm.Month;
     payment.Day = dm.Day;
     contract.Payment += payment.AmountOfPayment;
     repository.addPayment(payment);
     crep.updateContract(contract);
 }
Ejemplo n.º 3
0
 private void radGridView3_CellDoubleClick(object sender, GridViewCellEventArgs e)
 {
     if (e.RowIndex != -1)
     {
         int appointmentId = Convert.ToInt32(radGridView3.Rows[e.RowIndex].Cells[0].Value.ToString());
         EditAppointmentForm edaForm = new EditAppointmentForm(appointmentId);
         var result = edaForm.ShowDialog();
         if (result == DialogResult.OK)
         {
             AppointmentRepository repo = new AppointmentRepository();
             radGridView3.DataSource = repo.getAppointmentByContractId(selectedContractId).ToList();
             ContractRepository repository = new ContractRepository();
             radGridView1.DataSource = repository.getContractsByCustomerId(customerId).ToList();
         }
     }
 }
Ejemplo n.º 4
0
        private void radGridView3_UserDeletingRow(object sender, GridViewRowCancelEventArgs e)
        {
            DialogResult result = MessageBox.Show("آیا از عملیات حذف مطمئن هستید؟", "هشدار", MessageBoxButtons.YesNo);
            if (result == DialogResult.No)
            {
                e.Cancel = true;
            }
            else
            {
                int value = 0;
                DefaultSettingsRepository dRepo = new DefaultSettingsRepository();
                ContractRepository cRepo = new ContractRepository();
                AppointmentRepository rep = new AppointmentRepository();
                int appointmentId = Convert.ToInt32(radGridView3.SelectedRows[0].Cells[0].Value.ToString());
                Appointment appo = rep.getAppointment(appointmentId);
                string[] parts = appo.Description.Split('/');
                foreach (string part in parts)
                {
                    DefaultSetting ds = dRepo.GetSetting(part);
                    value += Convert.ToInt32(ds.Value);

                }
                Contract contract = cRepo.getContract(appo.ContractId.Value);
                contract.ContractPayment -= value;
                cRepo.updateContract(contract);

                rep.deleteAppointment(appointmentId);
                ContractRepository repository = new ContractRepository();
                radGridView1.DataSource = repository.getContractsByCustomerId(customerId).ToList();
            }
        }
Ejemplo n.º 5
0
 private void radGridView1_UserDeletingRow(object sender, GridViewRowCancelEventArgs e)
 {
     DialogResult result = MessageBox.Show("آیا از عملیات حذف مطمئن هستید؟", "هشدار", MessageBoxButtons.YesNo);
     if (result == DialogResult.No)
     {
         e.Cancel = true;
     }
     else
     {
         ContractRepository repository = new ContractRepository();
         //MessageBox.Show(radGridView1.SelectedRows[0].Cells[0].Value.ToString());
         repository.deleteContract(Convert.ToInt32(radGridView1.SelectedRows[0].Cells[0].Value.ToString()));
     }
 }
Ejemplo n.º 6
0
 private void radGridView2_UserDeletingRow(object sender, GridViewRowCancelEventArgs e)
 {
     //payment
     DialogResult result = MessageBox.Show("آیا از عملیات حذف مطمئن هستید؟", "هشدار", MessageBoxButtons.YesNo);
     if (result == DialogResult.No)
     {
         e.Cancel = true;
     }
     else
     {
         ContractRepository repository = new ContractRepository();
         PaymentRepository pRepo = new PaymentRepository();
         int paymentAmount = Convert.ToInt32(radGridView2.SelectedRows[0].Cells[1].Value.ToString());
         int paymentId = Convert.ToInt32(radGridView2.SelectedRows[0].Cells[0].Value.ToString());
         Contract contract = repository.getContract(selectedContractId);
         contract.Payment -= paymentAmount;
         pRepo.deletePayment(paymentId);
         repository.updateContract(contract);
         radGridView1.DataSource = repository.getContractsByCustomerId(customerId).ToList();
     }
 }
Ejemplo n.º 7
0
        private void CustomerInfoForm_Load(object sender, EventArgs e)
        {
            PersianDateFormatter pdf = new PersianDateFormatter();
            CustomerRepository repository = new CustomerRepository();
            Customer customer = repository.getCustomer(customerId);
            lName.Text = customer.FirstName + " " + customer.LastName;
            lPhoneNumber.Text = "شماره تماس:" + "   " + customer.PhoneNumber;
            lCreatedDate.Text = "تاریخ ایجاد:" + "   " + pdf.convert(customer.CreatedDate.Value);
            if (String.IsNullOrWhiteSpace(customer.Description))
            {
                lDescription.Text = "توضیحات:" + "   " + "-";
            }
            else
            {
                lDescription.Text = "توضیحات:" + "   " + customer.Description;
            }
            ContractRepository crepository = new ContractRepository();
            radGridView1.DataSource = crepository.getContractsByCustomerId(customerId).ToList();

            ((GridTableElement)radGridView1.TableElement).AlternatingRowColor = Color.FromArgb(215, 234, 124);
            radGridView1.TableElement.RowHeight = 25;
            ((GridTableElement)radGridView2.TableElement).AlternatingRowColor = Color.FromArgb(255, 205, 139);
            radGridView2.TableElement.RowHeight = 25;
            ((GridTableElement)radGridView3.TableElement).AlternatingRowColor = Color.FromArgb(240, 240, 240);
            radGridView3.TableElement.RowHeight = 25;

            if (radGridView1.SelectedRows.Count > 0)
            {
                //MessageBox.Show(radGridView1.SelectedRows[0].Cells[0].Value.ToString());
                PaymentRepository paymentRepository = new PaymentRepository();
                AppointmentRepository appointmentRepository = new AppointmentRepository();
                selectedContractId = Convert.ToInt32(radGridView1.SelectedRows[0].Cells[0].Value.ToString());
                radGridView2.DataSource = paymentRepository.getPaymentsByContractId(selectedContractId).ToList();
                radGridView3.DataSource = appointmentRepository.getAppointmentByContractId(selectedContractId).ToList();
            }

            if (radGridView1.SelectedRows.Count < 1)
            {
                bNewAppointment.Enabled = false;
                bNewPayment.Enabled = false;
            }
        }
Ejemplo n.º 8
0
        private void radGridView1_CellDoubleClick(object sender, GridViewCellEventArgs e)
        {
            if (e.RowIndex != -1)
            {
                int contractId = Convert.ToInt32(radGridView1.Rows[e.RowIndex].Cells[0].Value.ToString());
                AddEditContractForm contractForm = new AddEditContractForm(false, contractId, customerId);
                var result = contractForm.ShowDialog();
                if (result == DialogResult.OK)
                {
                    ContractRepository repository = new ContractRepository();
                    radGridView1.DataSource = repository.getContractsByCustomerId(customerId).ToList();
                }

            }
        }
Ejemplo n.º 9
0
 private void bNewPayment_Click(object sender, EventArgs e)
 {
     AddPayment addPayment = new AddPayment(selectedContractId);
     var result = addPayment.ShowDialog();
     if (result == DialogResult.OK)
     {
         PaymentRepository paymentRepository = new PaymentRepository();
         ContractRepository repository = new ContractRepository();
         radGridView1.DataSource = repository.getContractsByCustomerId(customerId).ToList();
         radGridView2.DataSource = paymentRepository.getPaymentsByContractId(selectedContractId).ToList();
     }
 }
Ejemplo n.º 10
0
 private void bNewContract_Click(object sender, EventArgs e)
 {
     AddEditContractForm contractForm = new AddEditContractForm(true, -1, customerId);
     var result = contractForm.ShowDialog();
     if (result == DialogResult.OK)
     {
         ContractRepository repository = new ContractRepository();
         radGridView1.DataSource = repository.getContractsByCustomerId(customerId).ToList();
     }
 }
Ejemplo n.º 11
0
 private void bNewAppointment_Click(object sender, EventArgs e)
 {
     AddAppointment addAppointment = new AddAppointment(selectedContractId);
     var result = addAppointment.ShowDialog();
     if (result == DialogResult.OK)
     {
         ContractRepository repo = new ContractRepository();
         AppointmentRepository appointmentRepository = new AppointmentRepository();
         radGridView3.DataSource = appointmentRepository.getAppointmentByContractId(selectedContractId).ToList();
         radGridView1.DataSource = repo.getContractsByCustomerId(customerId).ToList();
     }
 }
        private void bSave_Click(object sender, EventArgs e)
        {
            if (isNewContract)
            {
                PersianDateFormatter pdf = new PersianDateFormatter();
                ContractRepository repository = new ContractRepository();
                Contract contract = new Contract();
                contract.ContractPayment = Convert.ToInt32(tPayment.Text);
                contract.ContractStartDate = pdf.convert(tStartDate.Text);
                contract.CustomerId = this.customerId;
                contract.Description = tDescription.Text;
                contract.IsAppointmentFinished = cIsFinished.Checked;
                if (cIsFinished.Checked)
                {
                    contract.ContractEndDate = pdf.getDateInteger(DateTime.Now);
                }
                if (!String.IsNullOrWhiteSpace(tNextAppointmentDate.Text))
                {
                    contract.NextAppointmentDate = pdf.convert(tNextAppointmentDate.Text);
                }
                if (!String.IsNullOrWhiteSpace(tNextAppointmentTime.Text))
                {
                    TimeSpan ts = new TimeSpan(tNextAppointmentTime.Value.TimeOfDay.Hours, tNextAppointmentTime.Value.TimeOfDay.Minutes, 0);
                    contract.NextAppointmentTime = ts;
                }
                contract.Payment = 0;
                repository.addContract(contract);

            }
            else
            {
                PersianDateFormatter pdf = new PersianDateFormatter();
                ContractRepository repository = new ContractRepository();
                Contract contract = repository.getContract(contractId);
                contract.Id = contractId;
                contract.CustomerId = customerId;
                contract.ContractPayment = Convert.ToInt32(tPayment.Text);
                contract.ContractStartDate = pdf.convert(tStartDate.Text);
                contract.Description = tDescription.Text;
                contract.IsAppointmentFinished = cIsFinished.Checked;
                if (cIsFinished.Checked)
                {
                    contract.ContractEndDate = pdf.getDateInteger(DateTime.Now);
                }
                if (!String.IsNullOrWhiteSpace(tNextAppointmentDate.Text))
                {
                    contract.NextAppointmentDate = pdf.convert(tNextAppointmentDate.Text);
                }
                if (!String.IsNullOrWhiteSpace(tNextAppointmentTime.Text))
                {
                    TimeSpan ts = new TimeSpan(tNextAppointmentTime.Value.TimeOfDay.Hours, tNextAppointmentTime.Value.TimeOfDay.Minutes, 0);
                    contract.NextAppointmentTime = ts;
                }
                repository.updateContract(contract);
            }
        }
        private void AddEditContractForm_Load(object sender, EventArgs e)
        {
            bSave.DialogResult = DialogResult.OK;
            bCancel.DialogResult = DialogResult.Cancel;
            PersianDateFormatter pdf = new PersianDateFormatter();
            tNextAppointmentTime.Format = DateTimePickerFormat.Custom;
            tNextAppointmentTime.CustomFormat = "HH:mm";
            tNextAppointmentTime.ShowUpDown = true;
            if (isNewContract)
            {
                tPayment.Text = "0";
                tStartDate.Text = pdf.getDateString(DateTime.Now);
                tNextAppointmentDate.Text = pdf.getDateString(DateTime.Now.AddMonths(1));

            }
            else
            {
                ContractRepository repository = new ContractRepository();
                Contract contract = repository.getContract(contractId);
                tPayment.Text = contract.ContractPayment.Value.ToString();

                tNextAppointmentDate.Text = pdf.convert(contract.NextAppointmentDate.Value);
                tStartDate.Text = pdf.convert(contract.ContractStartDate.Value);

                if (contract.NextAppointmentTime.Value != null)
                {
                    DateTime dt = new DateTime(2000, 1, 1, 0, 0, 0).Add(contract.NextAppointmentTime.Value);

                    tNextAppointmentTime.Value = dt;
                }
                if (!String.IsNullOrWhiteSpace(contract.Description))
                {
                    tDescription.Text = contract.Description;
                }
                if (contract.IsAppointmentFinished.Value == true)
                {
                    cIsFinished.Checked = true;
                }
            }
        }