public void select() { if (clsGlobal.power != "Admin") { var Employees = from DataRow Cr in remaxDatabaseDataSet1.Houses.Rows where Cr.Field <Int32>("refEmployee") == clsGlobal.loggedId select new { refHouse = Cr.Field <Int32>("refHouse"), Bathrooms = Cr.Field <string>("Bathrooms"), NumberOfRooms = Cr.Field <string>("NumberOfRooms"), LivingArea = Cr.Field <string>("LivingArea"), ParkingSpot = Cr.Field <string>("ParkingSpot"), BuiltDate = Cr.Field <string>("BuiltDate"), Bedrooms = Cr.Field <string>("Bedrooms"), Price = Cr.Field <string>("Price"), Address = Cr.Field <string>("Address"), Comments = Cr.Field <string>("Comments") }; grdResult.DataSource = Employees.ToList(); } else { this.housesTableAdapter1.Fill(this.remaxDatabaseDataSet1.Houses); } }
private void frmAgentInfo_Load(object sender, EventArgs e) { txtComment.Enabled = false; picAgent.SizeMode = PictureBoxSizeMode.StretchImage; // TODO: This line of code loads data into the 'remaxDatabaseDataSet1.EmployeeSkills' table. You can move, or remove it, as needed. this.employeeSkillsTableAdapter.Fill(this.remaxDatabaseDataSet1.EmployeeSkills); this.skillsTableAdapter.Fill(this.remaxDatabaseDataSet1.Skills); this.employeesTableAdapter1.Fill(this.remaxDatabaseDataSet1.Employees); if (Application.OpenForms.OfType <frmAdmAgents>().Count() == 1) { Abcd = frm1.grdResult.SelectedRows[0].Cells[3].Value.ToString(); } if (Application.OpenForms.OfType <frmSearch>().Count() == 1) { Abcd = frm2.grdResult.SelectedRows[0].Cells[2].Value.ToString(); } int refnumber = 0; foreach (DataRow Cr in remaxDatabaseDataSet1.Employees.Rows) { if (Cr.Field <String>("Phone") == Abcd) { txtName.Text = Cr["Name"].ToString(); txtPhone.Text = Cr["Phone"].ToString(); txtEmail.Text = Cr["Email"].ToString(); cmbGender.Text = Cr["Gender"].ToString(); cmbPosition.Text = Cr["Position"].ToString(); txtComment.Text = Cr["Comment"].ToString(); refnumber = Convert.ToInt32(Cr["refEmployee"].ToString()); string imgpath = Cr["Picture"].ToString(); if (imgpath.Length != 0 && (System.IO.File.Exists(@"..\..\Images\" + imgpath))) { picAgent.Image = System.Drawing.Image.FromFile(@"..\..\Images\" + imgpath); } else { picAgent.Image = System.Drawing.Image.FromFile(@"..\..\Images\sorry.png"); } } } foreach (DataRow ab in remaxDatabaseDataSet1.EmployeeSkills.Rows) { if (ab.Field <Int32>("refEmployee") == refnumber) { foreach (DataRow cd in remaxDatabaseDataSet1.Skills.Rows) { if (ab.Field <Int32>("refSkill") == cd.Field <Int32>("refSkill")) { string[] row = { ab.Field <Int32>("refSkill").ToString(), cd.Field <String>("SkillName") }; var listViewItem = new ListViewItem(row); listSkills.Items.Add(listViewItem); } } } } }
private void frmNewClient_Load(object sender, EventArgs e) { this.clientsTableAdapter.Fill(this.remaxDatabaseDataSet.Clients); this.employeesTableAdapter.Fill(this.remaxDatabaseDataSet.Employees); picAgent.SizeMode = PictureBoxSizeMode.StretchImage; imgpath = @"..\..\Images\sorry.png"; refnumber = 0; if (clsGlobal.mode == "edit") { if (frm1.grdResult.SelectedRows.Count <= 0) { MetroMessageBox.Show(this, "You did not select any client to modify.\nThe form is being executed in the ADD mode.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning); clsGlobal.mode = "add"; return; } btnCreate.Text = "Confirm\nEdit"; String Abcd = frm1.grdResult.SelectedRows[0].Cells[2].Value.ToString(); foreach (DataRow Cr in remaxDatabaseDataSet.Clients.Rows) { if (Cr.Field <String>("Phone") == Abcd) { this.Text = "Editing the client: " + Cr["Name"].ToString(); txtName.Text = Cr["Name"].ToString(); txtPhone.Text = Cr["Phone"].ToString(); txtEmail.Text = Cr["Email"].ToString(); cmbGender.Text = Cr["Gender"].ToString(); txtComment.Text = Cr["Comment"].ToString(); imgpath = Cr["Picture"].ToString(); refnumber = Convert.ToInt32(Cr["refClient"].ToString()); refagent = Convert.ToInt32(Cr["refEmployee"].ToString()); txtAddress.Text = Cr["Address"].ToString(); txtPassword.Text = Cr["Password"].ToString(); cmbAgent.SelectedValue = Cr["refEmployee"].ToString(); if (imgpath.Length != 0 && (System.IO.File.Exists(@"..\..\Images\" + imgpath))) { picAgent.Image = System.Drawing.Image.FromFile(@"..\..\Images\" + imgpath); } else { picAgent.Image = System.Drawing.Image.FromFile(@"..\..\Images\sorry.png"); } } } } }
private void rdAgents_CheckedChanged(object sender, EventArgs e) { if (rdAgents.Checked) { var Employees = from DataRow Cr in remaxDatabaseDataSet.Employees.Rows select new { ID = Cr.Field <Int32>("RefEmployee"), Name = Cr.Field <string>("Name"), Phone = Cr.Field <string>("Phone"), Email = Cr.Field <string>("Email"), Gender = Cr.Field <string>("Gender"), Position = Cr.Field <string>("Position"), Comment = Cr.Field <string>("Comment") }; grdResult.DataSource = Employees.ToList(); } }
public void select() { if (clsGlobal.power != "Admin") { var Employees = from DataRow Cr in remaxDatabaseDataSet.Clients.Rows where Cr.Field <Int32>("refEmployee") == clsGlobal.loggedId select new { Name = Cr.Field <string>("Name"), Gender = Cr.Field <string>("Gender"), Phone = Cr.Field <string>("Phone"), Email = Cr.Field <string>("Email"), }; grdResult.DataSource = Employees.ToList(); } else { this.clientsTableAdapter.Fill(this.remaxDatabaseDataSet.Clients); this.employeesTableAdapter.Fill(this.remaxDatabaseDataSet.Employees); } }
private void rdHouses_CheckedChanged(object sender, EventArgs e) { if (rdHouses.Checked) { var Employees = from DataRow Cr in remaxDatabaseDataSet.Houses.Rows select new { ID = Cr.Field <Int32>("refHouse"), Bathrooms = Cr.Field <string>("Bathrooms"), Bedrooms = Cr.Field <string>("Bedrooms"), Rooms = Cr.Field <string>("NumberOfRooms"), Area = Cr.Field <string>("LivingArea"), Parking = Cr.Field <string>("ParkingSpot"), BuiltDate = Cr.Field <string>("BuiltDate"), Price = Cr.Field <string>("Price"), Address = Cr.Field <string>("Address"), Comment = Cr.Field <string>("Comments") }; grdResult.DataSource = Employees.ToList(); } }
private void frmClientInfo_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'remaxDatabaseDataSet1.Clients' table. You can move, or remove it, as needed. this.clientsTableAdapter.Fill(this.remaxDatabaseDataSet1.Clients); txtComment.Enabled = false; picAgent.SizeMode = PictureBoxSizeMode.StretchImage; this.employeeSkillsTableAdapter.Fill(this.remaxDatabaseDataSet1.EmployeeSkills); this.skillsTableAdapter.Fill(this.remaxDatabaseDataSet1.Skills); this.employeesTableAdapter1.Fill(this.remaxDatabaseDataSet1.Employees); this.clientsTableAdapter.Fill(this.remaxDatabaseDataSet1.Clients); Abcd = frm1.grdResult.SelectedRows[0].Cells[2].Value.ToString(); int refnumber = 0; foreach (DataRow Cr in remaxDatabaseDataSet1.Clients.Rows) { if (Cr.Field <String>("Phone") == Abcd) { txtName.Text = Cr["Name"].ToString(); txtPhone.Text = Cr["Phone"].ToString(); txtEmail.Text = Cr["Email"].ToString(); cmbGender.Text = Cr["Gender"].ToString(); txtComment.Text = Cr["Comment"].ToString(); refnumber = Convert.ToInt32(Cr["refEmployee"].ToString()); string imgpath = Cr["Picture"].ToString(); if (imgpath.Length != 0 && (System.IO.File.Exists(@"..\..\Images\" + imgpath))) { picAgent.Image = System.Drawing.Image.FromFile(@"..\..\Images\" + imgpath); } else { picAgent.Image = System.Drawing.Image.FromFile(@"..\..\Images\sorry.png"); } } } }
private void frmNewAgent_Load(object sender, EventArgs e) { picAgent.SizeMode = PictureBoxSizeMode.StretchImage; this.skillsTableAdapter.Fill(this.remaxDatabaseDataSet.Skills); this.employeeSkillsTableAdapter.Fill(this.remaxDatabaseDataSet.EmployeeSkills); this.employeesTableAdapter.Fill(this.remaxDatabaseDataSet.Employees); imgpath = @"..\..\Images\sorry.png"; refnumber = 0; if (clsGlobal.mode == "edit") { if (frm1.grdResult.SelectedRows.Count <= 0) { MetroMessageBox.Show(this, "You did not select any agent to modify.\nThe form is being executed in the ADD mode.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning); clsGlobal.mode = "add"; return; } String Abcd = frm1.grdResult.SelectedRows[0].Cells[3].Value.ToString(); foreach (DataRow Cr in remaxDatabaseDataSet.Employees.Rows) { if (Cr.Field <String>("Phone") == Abcd) { this.Text = "Editing the agent: " + Cr["Name"].ToString(); btnCreate.Text = "Confirm\nEdit"; txtName.Text = Cr["Name"].ToString(); txtPhone.Text = Cr["Phone"].ToString(); txtEmail.Text = Cr["Email"].ToString(); cmbGender.Text = Cr["Gender"].ToString(); cmbPosition.Text = Cr["Position"].ToString(); txtComment.Text = Cr["Comment"].ToString(); imgpath = Cr["Picture"].ToString(); refnumber = Convert.ToInt32(Cr["refEmployee"].ToString()); txtAddress.Text = Cr["Address"].ToString(); txtPassword.Text = Cr["Password"].ToString(); if (imgpath.Length != 0 && (System.IO.File.Exists(@"..\..\Images\" + imgpath))) { picAgent.Image = System.Drawing.Image.FromFile(@"..\..\Images\" + imgpath); } else { picAgent.Image = System.Drawing.Image.FromFile(@"..\..\Images\sorry.png"); } } } } foreach (DataRow ab in remaxDatabaseDataSet.EmployeeSkills.Rows) { if (ab.Field <Int32>("refEmployee") == refnumber) { foreach (DataRow cd in remaxDatabaseDataSet.Skills.Rows) { if (ab.Field <Int32>("refSkill") == cd.Field <Int32>("refSkill")) { string[] row = { ab.Field <Int32>("refSkill").ToString(), cd.Field <String>("SkillName") }; var listViewItem = new ListViewItem(row); listSkills.Items.Add(listViewItem); } } } } }
private void frmHousesInfo_Load(object sender, EventArgs e) { this.housesPicturesTableAdapter.Fill(this.remaxDatabaseDataSet.HousesPictures); this.featuresTableAdapter.Fill(this.remaxDatabaseDataSet.Features); this.houseTypeTableAdapter.Fill(this.remaxDatabaseDataSet.HouseType); this.listingTableAdapter.Fill(this.remaxDatabaseDataSet.Listing); this.clientsTableAdapter.Fill(this.remaxDatabaseDataSet.Clients); this.employeesTableAdapter.Fill(this.remaxDatabaseDataSet.Employees); this.housesFeaturesTableAdapter.Fill(this.remaxDatabaseDataSet.HousesFeatures); this.picturesTableAdapter.Fill(this.remaxDatabaseDataSet.Pictures); this.housesTableAdapter.Fill(this.remaxDatabaseDataSet.Houses); if (Application.OpenForms.OfType <frmAdmHouses>().Count() == 1) { Abcd = frm1.grdResult.SelectedRows[0].Cells[8].Value.ToString(); } if (Application.OpenForms.OfType <frmSearch>().Count() == 1) { Abcd = frm2.grdResult.SelectedRows[0].Cells[8].Value.ToString(); } foreach (DataRow Cr in remaxDatabaseDataSet.Houses.Rows) { if (Cr.Field <String>("Address") == Abcd) { refHouse = Convert.ToInt32(Cr["refHouse"].ToString()); this.Text = "Info on house: " + Cr["Address"].ToString(); cmbListing.SelectedValue = Cr["refListing"].ToString(); cmbType.SelectedValue = Cr["refType"].ToString(); cmbClient.SelectedValue = Cr["refClient"].ToString(); cmbEmployee.SelectedValue = Cr["refEmployee"].ToString(); cmbBathroom.Text = Cr["Bathrooms"].ToString(); cmbTotalRoom.Text = Cr["NumberOfRooms"].ToString(); txtLivingArea.Text = Cr["LivingArea"].ToString(); cmbParkingSpot.Text = Cr["ParkingSpot"].ToString(); cmbDate.Text = Cr["BuiltDate"].ToString(); txtAddress.Text = Cr["Address"].ToString(); cmbBedroom.Text = Cr["Bedrooms"].ToString(); txtComment.Text = Cr["Comments"].ToString(); txtPrice.Text = Cr["Price"].ToString(); } } foreach (DataRow ab in remaxDatabaseDataSet.HousesFeatures.Rows) { if (ab.Field <Int32>("refHouse") == refHouse) { foreach (DataRow cd in remaxDatabaseDataSet.Features.Rows) { if (ab.Field <Int32>("refFeature") == cd.Field <Int32>("refFeature")) { string[] row = { ab.Field <Int32>("refFeature").ToString(), cd.Field <String>("FeatureName") }; var listViewItem = new ListViewItem(row); listSkills.Items.Add(listViewItem); } } } } foreach (DataRow ab in remaxDatabaseDataSet.HousesPictures.Rows) { if (ab.Field <Int32>("refHouse") == refHouse) { foreach (DataRow cd in remaxDatabaseDataSet.Pictures.Rows) { if (ab.Field <Int32>("refPicture") == cd.Field <Int32>("refPicture")) { string[] row = { cd.Field <String>("PicturePath").ToString(), cd.Field <String>("PictureComment") }; var listViewItem = new ListViewItem(row); listPic.Items.Add(listViewItem); } } } } }
private void btnSearch_Click(object sender, EventArgs e) { if (rdAgents.Checked) { if (txtKeyword.Text != "") { var Employees = from DataRow Cr in remaxDatabaseDataSet.Employees.Rows where ( Convert.ToString(Cr.Field <Int32>("refEmployee")).Contains(txtKeyword.Text) || Cr.Field <string>("name").Contains(txtKeyword.Text) || Cr.Field <string>("phone").Contains(txtKeyword.Text) || Cr.Field <string>("gender").Contains(txtKeyword.Text) || Cr.Field <string>("email").Contains(txtKeyword.Text) || Cr.Field <string>("position").Contains(txtKeyword.Text) || Cr.Field <string>("comment").Contains(txtKeyword.Text) ) select new { ID = Cr.Field <Int32>("RefEmployee"), Name = Cr.Field <string>("Name"), Phone = Cr.Field <string>("Phone"), Email = Cr.Field <string>("Email"), Gender = Cr.Field <string>("Gender"), Position = Cr.Field <string>("Position"), Comment = Cr.Field <string>("Comment") }; grdResult.DataSource = Employees.ToList(); } else { var Employees = from DataRow Cr in remaxDatabaseDataSet.Employees.Rows select new { ID = Cr.Field <Int32>("RefEmployee"), Name = Cr.Field <string>("Name"), Phone = Cr.Field <string>("Phone"), Email = Cr.Field <string>("Email"), Gender = Cr.Field <string>("Gender"), Position = Cr.Field <string>("Position"), Comment = Cr.Field <string>("Comment") }; grdResult.DataSource = Employees.ToList(); } } else if (rdHouses.Checked) { if (txtKeyword.Text != "") { var Employees = from DataRow Cr in remaxDatabaseDataSet.Houses.Rows where ( Convert.ToString(Cr.Field <Int32>("refHouse")).Contains(txtKeyword.Text) || Cr.Field <string>("Bathrooms").Contains(txtKeyword.Text) || Cr.Field <string>("Bedrooms").Contains(txtKeyword.Text) || Cr.Field <string>("NumberOfRooms").Contains(txtKeyword.Text) || Cr.Field <string>("LivingArea").Contains(txtKeyword.Text) || Cr.Field <string>("ParkingSpot").Contains(txtKeyword.Text) || Cr.Field <string>("BuiltDate").Contains(txtKeyword.Text) || Cr.Field <string>("Price").Contains(txtKeyword.Text) || Cr.Field <string>("Address").Contains(txtKeyword.Text) || Cr.Field <string>("Comments").Contains(txtKeyword.Text) ) select new { ID = Cr.Field <Int32>("refHouse"), Bathrooms = Cr.Field <string>("Bathrooms"), Bedrooms = Cr.Field <string>("Bedrooms"), Rooms = Cr.Field <string>("NumberOfRooms"), Area = Cr.Field <string>("LivingArea"), Parking = Cr.Field <string>("ParkingSpot"), BuiltDate = Cr.Field <string>("BuiltDate"), Price = Cr.Field <string>("Price"), Address = Cr.Field <string>("Address"), Comment = Cr.Field <string>("Comments") }; grdResult.DataSource = Employees.ToList(); } else { var Employees = from DataRow Cr in remaxDatabaseDataSet.Houses.Rows select new { ID = Cr.Field <Int32>("refHouse"), Bathrooms = Cr.Field <string>("Bathrooms"), Bedrooms = Cr.Field <string>("Bedrooms"), Rooms = Cr.Field <string>("NumberOfRooms"), Area = Cr.Field <string>("LivingArea"), Parking = Cr.Field <string>("ParkingSpot"), BuiltDate = Cr.Field <string>("BuiltDate"), Price = Cr.Field <string>("Price"), Address = Cr.Field <string>("Address"), Comment = Cr.Field <string>("Comments") }; grdResult.DataSource = Employees.ToList(); } } else { MetroMessageBox.Show(this, "Please select either Houses or Agents to search from."); } }
private void frmHouseAddEdit_Load(object sender, EventArgs e) { this.housesPicturesTableAdapter.Fill(this.remaxDatabaseDataSet.HousesPictures); this.featuresTableAdapter.Fill(this.remaxDatabaseDataSet.Features); this.houseTypeTableAdapter.Fill(this.remaxDatabaseDataSet.HouseType); this.listingTableAdapter.Fill(this.remaxDatabaseDataSet.Listing); this.clientsTableAdapter.Fill(this.remaxDatabaseDataSet.Clients); this.employeesTableAdapter.Fill(this.remaxDatabaseDataSet.Employees); this.housesFeaturesTableAdapter.Fill(this.remaxDatabaseDataSet.HousesFeatures); this.picturesTableAdapter.Fill(this.remaxDatabaseDataSet.Pictures); this.housesTableAdapter.Fill(this.remaxDatabaseDataSet.Houses); if (clsGlobal.mode == "edit") { if (frm1.grdResult.SelectedRows.Count <= 0) { MetroMessageBox.Show(this, "You did not select any house to modify.\nThe form is being executed in the ADD mode.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning); clsGlobal.mode = "add"; return; } Abcd = frm1.grdResult.SelectedRows[0].Cells[8].Value.ToString(); foreach (DataRow Cr in remaxDatabaseDataSet.Houses.Rows) { if (Cr.Field <String>("Address") == Abcd) { refHouse = Convert.ToInt32(Cr["refHouse"].ToString()); refEmployee = Convert.ToInt32(Cr["refEmployee"].ToString()); refListing = Convert.ToInt32(Cr["refListing"].ToString()); refType = Convert.ToInt32(Cr["refType"].ToString()); refClient = Convert.ToInt32(Cr["refClient"].ToString()); this.Text = "Editing the house: " + Cr["Address"].ToString(); btnCreate.Text = "Confirm\nEdit"; cmbEmployee.SelectedValue = Cr["refEmployee"].ToString(); cmbListing.SelectedValue = Cr["refListing"].ToString(); cmbType.SelectedValue = Cr["refType"].ToString(); cmbClient.SelectedValue = Cr["refClient"].ToString(); cmbBathroom.Text = Cr["Bathrooms"].ToString(); cmbTotalRoom.Text = Cr["NumberOfRooms"].ToString(); txtLivingArea.Text = Cr["LivingArea"].ToString(); cmbParkingSpot.Text = Cr["ParkingSpot"].ToString(); cmbDate.Text = Cr["BuiltDate"].ToString(); txtAddress.Text = Cr["Address"].ToString(); cmbBedroom.Text = Cr["Bedrooms"].ToString(); txtComment.Text = Cr["Comments"].ToString(); txtPrice.Text = Cr["Price"].ToString(); } } foreach (DataRow ab in remaxDatabaseDataSet.HousesFeatures.Rows) { if (ab.Field <Int32>("refHouse") == refHouse) { foreach (DataRow cd in remaxDatabaseDataSet.Features.Rows) { if (ab.Field <Int32>("refFeature") == cd.Field <Int32>("refFeature")) { string[] row = { ab.Field <Int32>("refFeature").ToString(), cd.Field <String>("FeatureName") }; var listViewItem = new ListViewItem(row); listSkills.Items.Add(listViewItem); } } } } foreach (DataRow ab in remaxDatabaseDataSet.HousesPictures.Rows) { if (ab.Field <Int32>("refHouse") == refHouse) { foreach (DataRow cd in remaxDatabaseDataSet.Pictures.Rows) { if (ab.Field <Int32>("refPicture") == cd.Field <Int32>("refPicture")) { string[] row = { cd.Field <String>("PicturePath").ToString(), cd.Field <String>("PictureComment") }; var listViewItem = new ListViewItem(row); listPic.Items.Add(listViewItem); } } } } } }