private void frmClient_Load(object sender, EventArgs e) { if (frmLogin.agent != null) { cboAgent.Visible = lblCAgent.Visible = false; } else { cboAgent.DataSource = Remax.TabAgents(); cboAgent.DisplayMember = "Name"; cboAgent.ValueMember = "Id"; } if (frmManage.mode == "edit") { client = frmManage.client; txtCName.Text = client.Name; txtCPhone.Text = client.Phone; txtCEmail.Text = client.Email; txtCComment.Text = client.Comment; cboRole.Text = client.Role; foreach (DataRow row in Remax.TabAgents()) { if (row["Id"].ToString() == client.IdAgent) { cboAgent.Text = row["Name"].ToString(); } } } }
private void btnSearch_Click(object sender, EventArgs e) { if (checkBoxID.Checked) { if (txtSearch.Text == "") { MessageBox.Show("Enter a criteria"); } else { string criteria = txtSearch.Text; if (frmRemax.formToManage == "house") { if (frmLogin.admin != null) { DataView dv = HouseDB.getViewHouses("admin"); dv.RowFilter = "CONVERT(Id, System.String) LIKE '%" + criteria + "%'"; dgvResult.DataSource = dv; } else { DataView dv = HouseDB.getViewHouses("user or agent"); dv.RowFilter = "CONVERT(Id, System.String) LIKE '%" + criteria + "%'"; dgvResult.DataSource = dv; } } if (frmRemax.formToManage == "client") { if (frmLogin.agent == null) { DataView dv = ClientDB.getViewClients(""); dv.RowFilter = "CONVERT(Id, System.String) LIKE '%" + criteria + "%'"; dgvResult.DataSource = dv; } else { DataView dv = ClientDB.getViewClients(frmLogin.agent.Name); dv.RowFilter = " CONVERT(Id, System.String) LIKE '%" + criteria + "%'"; dgvResult.DataSource = dv; } } if (frmRemax.formToManage == "employee") { DataView dv = EmployeeDB.getViewEmployees(""); dv.RowFilter = "CONVERT(Id, System.String) LIKE '%" + criteria + "%'"; dgvResult.DataSource = dv; } if (frmRemax.formToManage == "agent") { DataView dv = EmployeeDB.getViewEmployees("agent"); dv.RowFilter = "CONVERT(Id, System.String) LIKE '%" + criteria + "%'"; dgvResult.DataSource = dv; } } } if (checkBoxName.Checked) { if (txtSearch.Text == "") { MessageBox.Show("Enter a criteria"); } else { string criteria = txtSearch.Text; if (frmRemax.formToManage == "house") { if (frmLogin.employee == null) { DataTable dt = Remax.ViewHouses("user"); DataView dv = dt.DefaultView; dv.RowFilter = "Name LIKE '%" + criteria + "%'"; dgvResult.DataSource = dv; } else { DataTable dt = Remax.ViewHouses(); DataView dv = dt.DefaultView; dv.RowFilter = "Name LIKE '%" + criteria + "%'"; dgvResult.DataSource = dv; } } if (frmRemax.formToManage == "client") { if (frmLogin.agent != null) { DataView dv = Remax.ViewClients(frmLogin.agent.Name); dv.RowFilter = "Name LIKE '%" + criteria + "%'"; dgvResult.DataSource = dv; } else { DataTable dt = Remax.ViewClients(); DataView dv = dt.DefaultView; dv.RowFilter = "Name LIKE '%" + criteria + "%'"; dgvResult.DataSource = dv; } } if (frmRemax.formToManage == "employee") { DataTable dt = Remax.ViewEmployees(); DataView dv = dt.DefaultView; dv.RowFilter = "Name LIKE '%" + criteria + "%'"; dgvResult.DataSource = dv; } if (frmRemax.formToManage == "agent") { DataTable dt = Remax.TabAgents(); DataView dv = dt.DefaultView; dv.RowFilter = "Name LIKE '%" + criteria + "%'"; dgvResult.DataSource = dv; } } } if (!checkBoxName.Checked && !checkBoxID.Checked) { MessageBox.Show("Check type of search."); } }