private void frmSearchHouse_Load(object sender, EventArgs e)
 {
     houselist = new List <clsHouse>();
     admin.Refresh_Database();
     houselist          = admin.Search_All_Houses();
     gridAll.DataSource = houselist;
     string[] rooms = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11" };
     cboNumRoom.DataSource        = rooms;
     cboNumRoomCombile.DataSource = rooms;
 }
Beispiel #2
0
        private void frmSales_Load(object sender, EventArgs e)
        {
            admin = new clsAdmin();
            DataTable temp = new DataTable();

            // fill cboHouse
            cboHouse.DisplayMember = "Address";
            cboHouse.ValueMember   = "RefHouse";
            cboHouse.DataSource    = admin.HouseListToDataTable(admin.Search_All_Houses());

            // fill cboClient
            cboClient.DisplayMember = "ClientName";
            cboClient.ValueMember   = "RefClient";
            cboClient.DataSource    = admin.ClientListToDataTable(admin.All_Client());

            // fill cboAgent
            cboAgent.DisplayMember = "AgentName";
            cboAgent.ValueMember   = "RefAgent";
            cboAgent.DataSource    = admin.AgentListToDataTable(admin.Search_All_Agents());

            if (permission != 2)
            {
                gridAll.DataSource = admin.All_Sales();
            }
            else
            {
                gridAll.DataSource = admin.Search_Sales_Belong_To_RefAgent(RefAgent);
            }
            gridAll.ReadOnly = true;
            ButtonControl(true, false, false, false, true, false);
        }
        private void frmClient_Load(object sender, EventArgs e)
        {
            agent = new clsAgent();
            admin = new clsAdmin();

            if (permission == 2)
            {
                List <clsClient> temp = new List <clsClient>();
                temp.Add(agent.Searched_Cleint_For_This_Agent(refagent));
                gridAll.DataSource = temp;
            }
            else
            {
                gridAll.DataSource = admin.All_Client();
            }
            gridAll.ReadOnly = true;
            ButtonControl(true, false, false, false, true, false);
            string[]      status    = { "Seller", "Buyer", "Inactive(Buyer)", "Inactive(Seller)" };
            List <string> refhouses = new List <string>();

            refhouses.Add("0");
            foreach (clsHouse i in admin.Search_All_Houses())
            {
                refhouses.Add(i.RefHouse.ToString());
            }
            cboRefHouse.DataSource = refhouses;
            cboStatus.DataSource   = status;
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            clsAdmin admin = new clsAdmin();
            clsHouse house = new clsHouse();

            house.Address = txtAddress.Text;
            house.Area    = Convert.ToInt32(txtArea.Text);
            house.Price   = Convert.ToDecimal(txtPrice.Text);
            house.Floor   = Convert.ToInt32(txtFloor.Text);
            house.NumRoom = Convert.ToInt32(txtRoom.Text);
            house.NumBath = Convert.ToInt32(txtBath.Text);
            if (cboAccess.SelectedItem.ToString() == "Yes")
            {
                house.Accessible = true;
            }
            else
            {
                house.Accessible = false;
            }
            house.Status = cboStatus.Text;

            if (Addmode)
            {
                if (admin.Add_New_House(house))
                {
                    MessageBox.Show("New House on the Address : " + house.Address + " is successfully added", "New House Added");
                }
                else
                {
                    MessageBox.Show("The house of the Address " + house.Address + " is not added.", "Try Again");
                }
                admin.Refresh_Database();
            }
            else
            {
                house.RefHouse = (int)gridAll.Rows[gridAll.CurrentRow.Index].Cells[0].Value;

                if (admin.Edit_House(house))
                {
                    MessageBox.Show("House ID " + house.RefHouse + " is successfully modified", "House Modified");
                }
                else
                {
                    MessageBox.Show("House ID : " + house.RefHouse + " is not modified.", "Try Again");
                }
            }
            if (permission != 2)
            {
                gridAll.DataSource = admin.Search_All_Houses();
            }
            else
            {
                gridAll.DataSource = current.Searched_House_Belong_to_Current_Agent(RefAgent);
            }

            ButtonControl(true, true, false, false, true, false);
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Do You really want to delete this House?", "DELETE", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
            {
                int refhouse = (int)gridAll.Rows[gridAll.CurrentRow.Index].Cells[0].Value;

                if (admin.Delete_House(refhouse))
                {
                    MessageBox.Show("House ID" + refhouse + " is successfully Deleted", "House Deleted");
                }
                else
                {
                    MessageBox.Show("House ID " + refhouse + " is not deleted.", "Try Again");
                }
            }
            admin.Refresh_Database();
            gridAll.DataSource = admin.Search_All_Houses();
            ButtonControl(true, true, false, false, true, false);
        }
 private void frmAdminHouse_Load(object sender, EventArgs e)
 {
     if (permission == 2)
     {
         current            = new clsAgent();
         gridAll.DataSource = current.Searched_House_Belong_to_Current_Agent(RefAgent);
         gridAll.Focus();
     }
     else
     {
         admin = new clsAdmin();
         gridAll.DataSource = admin.Search_All_Houses();
     }
     gridAll.ReadOnly = true;
     ButtonControl(true, false, false, false, true, false);
     string[] access = { "Yes", "No" };
     string[] status = { "Sold", "Onsale" };
     cboAccess.DataSource = access;
     cboStatus.DataSource = status;
 }