private void EditAppointmentForm_Load(object sender, EventArgs e)
        {
            DefaultSettingsRepository dRepo = new DefaultSettingsRepository();
            radCheckedDropDownList1.DataSource = dRepo.GetSetingsByType("price").ToList();
            radCheckedDropDownList1.DisplayMember = "Name";
            radCheckedDropDownList1.ValueMember = "Value";

            PersianDateFormatter pdf = new PersianDateFormatter();
            tTime.Format = DateTimePickerFormat.Custom;
            tTime.CustomFormat = "HH:mm";
            tTime.ShowUpDown = true;
            bSave.DialogResult = DialogResult.OK;
            bCancel.DialogResult = DialogResult.Cancel;
            AppointmentRepository repo = new AppointmentRepository();
            Appointment appo = repo.getAppointment(appointmentId);
            DateTime dt = new DateTime(2000, 1, 1, 0, 0, 0).Add(appo.AppointmentTime.Value);
            tTime.Value = dt;
            tDate.Text = pdf.convert(appo.AppointmentDate.Value);
            string[] parts = appo.Description.Split('/');

            foreach (RadCheckedListDataItem item in radCheckedDropDownList1.Items)
            {
                if (parts.Contains(item.DisplayValue.ToString()))
                {
                    item.Checked = true;
                    unchangedValue += Convert.ToInt32(item.Value.ToString());
                }
            }
        }
        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();
            }
        }
 private void bSave_Click(object sender, EventArgs e)
 {
     PersianDateFormatter pdf = new PersianDateFormatter();
     AppointmentRepository appRepo = new AppointmentRepository();
     Appointment app = appRepo.getAppointment(appointmentId);
     //app.Description = tDescription.Text;
     app.AppointmentDate = pdf.convert(tDate.Text);
     TimeSpan ts = new TimeSpan(tTime.Value.TimeOfDay.Hours, tTime.Value.TimeOfDay.Minutes, 0);
     app.AppointmentTime = ts;
     string description = "";
     foreach (var item in radCheckedDropDownList1.CheckedItems)
     {
         description += item.DisplayValue.ToString() + "/";
     }
     description = description.Remove(description.Length - 1);
     app.Description = description;
     appRepo.updateAppointment(app);
     ContractRepository cRepo = new ContractRepository();
     Contract contract = cRepo.getContract(app.ContractId.Value);
     contract.ContractPayment += valueChange - unchangedValue;
     cRepo.updateContract(contract);
 }