示例#1
0
        private void DataGridViewLands_SelectionChanged(object sender, EventArgs e)
        {
            LeaseDA leaseDA = new LeaseDA();

            DataGridViewRow selectedRow = DataGridViewLands.CurrentRow;
            List <Tenant>   tenants     = leaseDA.GetCurrentTenantsByLandID(int.Parse(selectedRow.Tag.ToString()));

            DataGridViewTenants.Rows.Clear();

            int i = 0;

            while (i < tenants.Count)
            {
                DataGridViewRow row = new DataGridViewRow();
                row.CreateCells(DataGridViewTenants);
                row.Cells[0].Value = Helper.GetNepaliNumber(i + 1);
                row.Cells[1].Value = tenants[i].Fullname;
                row.Cells[2].Value = tenants[i].Address;
                row.Cells[3].Value = tenants[i].MobileNumber;
                row.Cells[4].Value = tenants[i].Father;

                // Store land_id as Tag
                row.Tag = tenants[i].TenantID.ToString();

                DataGridViewTenants.Rows.Add(row);
                i++;
            }
        }
        private void ComboBoxLand_SelectedIndexChanged(object sender, EventArgs e)
        {
            // List only those tenants who are currently in lease contract
            // not the ones who have transfered their ownership already.

            LeaseDA       leaseDA       = new LeaseDA();
            Land          selectedLand  = (Land)ComboBoxLand.SelectedItem;
            List <Tenant> currentTenant = leaseDA.GetCurrentTenantsByLandID(selectedLand.LandID);

            try
            {
                ComboBoxCurrentTenant.DataSource    = currentTenant;
                ComboBoxCurrentTenant.DisplayMember = "Fullname";
                ComboBoxCurrentTenant.ValueMember   = "TenantID";

                LoadComboBoxNewTenant();
            }
            catch (Exception)
            {
                MessageForm messageForm = new MessageForm();
                messageForm.MessageText = "ओहो! केही आन्तरिक त्रुटीको कारण मोहीको विवरण लोड गर्न सकिएन।";
                messageForm.ShowDialog();
            }

            EnableDisableRadioButtons();
        }