Ejemplo n.º 1
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            // if (e.ColumnIndex == ((sender as DataGridView).Columns.Count) - 1)
            if (e.ColumnIndex == 0)
            {
                Guid             id = Guid.Parse(dataGridView1.Rows[e.RowIndex].Cells["InstallementId"].Value.ToString());
                PayedInstallment f  = new PayedInstallment();
                f.InsId = id;
                f.ShowDialog();


                InstallementsService.InstallementsServiceClient b = new InstallementsService.InstallementsServiceClient();
                dataGridView1.DataSource = b.GetPeopleInstallements().Select(x => new { x.InstallementId, x.Fullname, x.NationalCode, x.Amount, x.PaymentDate, x.InstallementIsPayed }).Where(x => x.InstallementIsPayed == false).ToList();
            }
        }
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            Guid id = Guid.Parse(dataGridView1.Rows[e.RowIndex].Cells["Id"].Value.ToString());

            InstallementsService.InstallementsServiceClient a = new InstallementsService.InstallementsServiceClient();
            if (e.ColumnIndex == 0) // Edit mode
            {
                InstallmentsAE f = new InstallmentsAE();
                f.id    = Id1;
                f.idIns = id;
                f.rol   = 1;
                f.ShowDialog();
                a = new InstallementsService.InstallementsServiceClient();
                dataGridView1.DataSource = a.GetLoanInstallements(Id1).Select(x => new { x.Id, x.Amount, x.PaymentDate, x.IsPayed }).ToList();
                MyFormLoad();
                //InstallmentsAddOrEdit f = new InstallmentsAddOrEdit();
                //f.IdInstalment = id;
                //f.Type = 0;
                //f.ShowDialog();
            }
            else if (e.ColumnIndex == 1) // Delete mode
            {
                if (MessageBox.Show("آیا از حذف این قسط اطمینان دارید؟", "خطا", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    InstallementsService.InstallementsServiceClient b = new InstallementsService.InstallementsServiceClient();
                    b.DeleteInstallements(id);
                    MessageBox.Show("با موفقیت حذف شد");
                    a = new InstallementsService.InstallementsServiceClient();
                    dataGridView1.DataSource = a.GetLoanInstallements(Id1).Select(x => new { x.Id, x.Amount, x.PaymentDate, x.IsPayed }).ToList();
                    MyFormLoad();
                }
            }
            else if (e.ColumnIndex == 2) // Done mode
            {
                PayedInstallment f = new PayedInstallment();
                f.InsId = id;
                f.ShowDialog();

                MyFormLoad();
            }
        }