Beispiel #1
0
        private void PopulateTenants()
        {
            TenantDA      tenantDA = new TenantDA();
            List <Tenant> tenants  = tenantDA.GetAllTenants();

            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++;
            }
        }
Beispiel #2
0
        private void ButtonDeregisterTenant_Click(object sender, EventArgs e)
        {
            // Retrieve the LeaseID to deregister
            DataGridViewRow row = DataGridViewLeases.CurrentRow;

            ConfirmationForm confirmForm = new ConfirmationForm();

            confirmForm.ConfirmationText = "के तपाई वास्तवमै मोही दर्ता खारेज गर्न चाहनुहुन्छ?";

            DialogResult result = confirmForm.ShowDialog();

            if (result == DialogResult.OK)
            {
                TenantDA tenantDA = new TenantDA();
                bool     success  = tenantDA.DeregisterLease(int.Parse(row.Tag.ToString()));

                MessageForm messageForm = new MessageForm();

                if (success)
                {
                    messageForm.MessageText = "मोही दर्ता सफलतापूर्वक खारेज गरियो।";
                    messageForm.ShowDialog();
                }
                else
                {
                    messageForm.MessageText = "प्राविधिक कारणले गर्दा र्मोही दर्ता खारेज गर्न सकिएन।";
                    messageForm.ShowDialog();
                }
            }
        }
        private void PopulateTenants()
        {
            TenantDA tenantDA = new TenantDA();

            ComboBoxTenant.DataSource    = tenantDA.GetActiveTenants();
            ComboBoxTenant.DisplayMember = "Fullname";
            ComboBoxTenant.ValueMember   = "TenantID";
        }
Beispiel #4
0
        private void ButtonEditTenant_Click(object sender, EventArgs e)
        {
            DataGridViewRow selectedRow  = DataGridViewTenants.CurrentRow;
            int             tenantID     = int.Parse(selectedRow.Tag.ToString());
            TenantDA        tenantDA     = new TenantDA();
            Tenant          tenantToEdit = tenantDA.GetTenantByID(tenantID);

            NewTenantForm editTenantForm = new NewTenantForm(tenantToEdit);

            editTenantForm.ShowDialog();
        }
        private void LoadComboBoxNewTenant()
        {
            TenantDA tenantDA = new TenantDA();

            if (ComboBoxCurrentTenant.Items.Count > 0)
            {
                Tenant tenant = (Tenant)ComboBoxCurrentTenant.SelectedItem;
                ComboBoxNewTenant.DataSource = tenantDA.GetAllTenantsExcept(tenant.TenantID);
            }
            else
            {
                ComboBoxNewTenant.DataSource = tenantDA.GetAllTenants();
            }

            ComboBoxNewTenant.DisplayMember = "Fullname";
            ComboBoxNewTenant.ValueMember   = "TenantID";
        }
Beispiel #6
0
        private void ButtonDeleteTenant_Click(object sender, EventArgs e)
        {
            DataGridViewRow selectedRow = DataGridViewTenants.CurrentRow;

            DialogResult     dlgResult;
            ConfirmationForm confirmForm = new ConfirmationForm();

            confirmForm.ConfirmationText = "के तपाई मोहीको विवरण मेटाउन चाहनु हुन्छ ?";
            dlgResult = confirmForm.ShowDialog();
            if (dlgResult == DialogResult.OK)
            {
                MessageForm messageForm;
                bool        result = false;

                Tenant tenantToDelete = new Tenant();
                tenantToDelete.TenantID = int.Parse(selectedRow.Tag.ToString());

                try
                {
                    TenantDA tenantDA = new TenantDA();
                    result = tenantDA.DeleteTenant(tenantToDelete);
                }
                catch (Exception)
                {
                    messageForm             = new MessageForm();
                    messageForm.MessageText = "आन्तरिक त्रुटीको कारण कार्य सम्पन्न गर्न सकिएन।";
                    messageForm.ShowDialog();
                }

                if (result)
                {
                    messageForm             = new MessageForm();
                    messageForm.MessageText = "छनौट गरिएको मोहीको विवरण सफलतापूर्वक मेटाइयो।";
                    messageForm.ShowDialog();
                }
            }
        }
        private void ButtonSave_Click(object sender, EventArgs e)
        {
            // Check if the land is duplicate
            TenantDA    tenantDA    = new TenantDA();
            MessageForm messageForm = new MessageForm();

            // If tenant.TenantID is null, it is new tenant. So proceed with Save.
            // Otherwise, proceed with updating tenant.
            bool result = false;

            tenant.Fullname     = TextBoxFullname.Text;
            tenant.Address      = TextBoxAddress.Text;
            tenant.MobileNumber = TextBoxMobileNumber.Text;
            tenant.Father       = TextBoxFather.Text;

            if (tenant.TenantID < 1)
            {
                if (!tenantDA.IsDuplicateTenant(tenant))
                {
                    try
                    {
                        result = tenantDA.SaveTenant(tenant);
                    }
                    catch (Exception)
                    {
                        messageForm.MessageText = "ओहो! केही आन्तरिक त्रुटीको कारण नयाँ मोहीको विवरण सुरक्षित गर्न सकिएन।";
                        messageForm.ShowDialog();
                    }

                    if (result)
                    {
                        messageForm.MessageText = "नयाँ मोहीको विवरण सफलतापूर्वक सुरक्षित गरियो।";
                        messageForm.ShowDialog();
                    }

                    // Clear fields for new entry
                    ClearFields();
                }
                else
                {
                    messageForm.MessageText = "उक्त मोहीको विवरण पहिले नै सुरक्षित गरिसकेको छ।";
                    messageForm.ShowDialog();
                }
            }
            else
            {
                try
                {
                    result = tenantDA.UpdateTenant(tenant);
                }
                catch (Exception)
                {
                    messageForm.MessageText = "केही आन्तरिक त्रुटीको कारण मोहीको विवरण सच्याउन सकिएन।";
                    messageForm.ShowDialog();
                }

                if (result)
                {
                    messageForm.MessageText = "उक्त मोहीको विवरण सफलतापूर्वक अद्यावधिक गरियो।";
                    messageForm.ShowDialog();
                }
            }

            // If edit mode, then self close the form
            if (tenant.TenantID > 0)
            {
                this.Close();
            }
        }