private void bEditInfo_Click(object sender, EventArgs e)
        {
            PersianDateFormatter pdf = new PersianDateFormatter();
            CustomerRepository repository = new CustomerRepository();
            Customer customer = repository.getCustomer(customerId);
            EditCustomerForm editCustomerForm = new EditCustomerForm(customer);
            var result = editCustomerForm.ShowDialog();
            if (result == DialogResult.OK)
            {
                CustomerRepository cr = new CustomerRepository();
                customer = cr.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;
                }

            }
        }
        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;
            }
        }
        private void radGridView1_UserDeletingRow(object sender, GridViewRowCancelEventArgs e)
        {
            DialogResult result = MessageBox.Show("آیا از عملیات حذف مطمئن هستید؟", "هشدار", MessageBoxButtons.YesNo);
            if (result == DialogResult.No)
            {
                e.Cancel = true;
            }
            else
            {
                CustomerRepository repository = new CustomerRepository();
                repository.deleteCustomer(Convert.ToInt32(radGridView1.SelectedRows[0].Cells[0].Value.ToString()));

            }
        }
        private void CustomersForm_Load(object sender, EventArgs e)
        {
            CustomerRepository repository = new CustomerRepository();
            radGridView1.DataSource = repository.getAllCustomers().ToList();
            radGridView1.GridViewElement.PagingPanelElement.RightToLeft = true;
            ((GridTableElement)radGridView1.TableElement).AlternatingRowColor = Color.FromArgb(215, 234, 124);
            radGridView1.TableElement.RowHeight = 35;

            saveFileDialog1.FileName = "export";
            saveFileDialog1.Filter = "xlsx files (*.xlsx)|*.xlsx|All files (*.*)|*.*";
        }
 private void bSearch_Click(object sender, EventArgs e)
 {
     CustomerRepository repository = new CustomerRepository();
     radGridView1.DataSource = repository.searchCustomers(tName.Text, tLastName.Text, tPhoneNumber.Text).ToList();
 }
        private void bNewCustomer_Click(object sender, EventArgs e)
        {
            AddCustomerForm acf = new AddCustomerForm();
            var result = acf.ShowDialog();
            if (result == DialogResult.OK)
            {
                CustomerRepository repository = new CustomerRepository();
                radGridView1.DataSource = repository.getAllCustomers().ToList();

            }
        }
        private void bSave_Click(object sender, EventArgs e)
        {
            Customer customer = new Customer();
            CustomerRepository repository = new CustomerRepository();
            if (String.IsNullOrWhiteSpace(tName.Text) || String.IsNullOrWhiteSpace(tLastName.Text) || String.IsNullOrWhiteSpace(tPhoneNumber.Text))
            {
                MessageBox.Show("اطلاعات کامل وارد نشده است");
                return;
            }
            PersianDateFormatter pdf = new PersianDateFormatter();
            customer.CreatedDate = pdf.getDateInteger(DateTime.Now);
            customer.FirstName = tName.Text;
            customer.LastName = tLastName.Text;
            customer.PhoneNumber = tPhoneNumber.Text;
            if (rWoman.Checked)
            {
                customer.Gender = true;
            }
            else
            {
                customer.Gender = false;
            }

            if (!String.IsNullOrWhiteSpace(tDescription.Text))
            {
                customer.Description = tDescription.Text;
            }

            repository.addCustomer(customer);
            //MessageBox.Show("با موفقیت اضافه شد");
        }