private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { using (var db = new LandxEntities()) { AllLands = db.Lands.Include("Person").ToList(); } }
private void bwLogin_DoWork(object sender, DoWorkEventArgs e) { if (string.IsNullOrWhiteSpace(txtUsername.Text)) { error = "The Username field is compulsory."; } else { if (string.IsNullOrWhiteSpace(txtPassword.Text)) { error = "The Password field is compulsory."; } else { using (var db = new LandxEntities()) { var user = db.Accounts.SingleOrDefault(x => x.Username == txtUsername.Text.Trim() && x.Password == txtPassword.Text.Trim() ); if (user == null) { error = "No account exists with this username and password."; } else { loggedIn = true; } } } } }
protected void ProcessVerify(DPFP.Sample Sample) { try { // Draw fingerprint sample image. DrawPicture(ConvertSampleToBitmap(Sample)); // Process the sample and create a feature set for the enrollment purpose. DPFP.FeatureSet features = ExtractFeatures(Sample, DPFP.Processing.DataPurpose.Verification); // Check quality of the sample and start verification if it's good // TODO: move to a separate task if (features != null) { DPFP.Verification.Verification.Result result = new DPFP.Verification.Verification.Result(); bool found = false; int index = 0; // Compare the feature set with each of our template foreach (var llt in Owners) { Verificator.Verify(features, llt, ref result); if (result.Verified) { found = true; using (var db = new LandxEntities()) { Dlandlord = db.People.Find(psnId); } MakeReport("The fingerprint was VERIFIED."); displayMsg("Welcome " + Dlandlord.ApplicantsFullname); enableNextFP(); break; } index++; } if (!found) { MakeReport("The fingerprint was NOT VERIFIED."); } } Capturer.StartCapture(); } catch (Exception ex) { MessageBox.Show("An error occured while comparing with fingerprint database. \n\r\n\r" + ex.ToString()); } }
private void btnSave_Click(object sender, EventArgs e) { DialogResult rtn = MessageBox.Show("Are you sure you want to transfer ownership of this Land from " + Dlandlord.ApplicantsFullname + " to " + NewOwner.ApplicantsFullname + "?", "Transfer Ownership", MessageBoxButtons.YesNo); if (rtn == DialogResult.Yes) { Land land = (Land)Tag; using (var db = new LandxEntities()) { land = db.Lands.Find(land.Id); land.PersonId = NewOwner.Id; db.SaveChanges(); MessageBox.Show("Ownership of this land has been transfered to " + NewOwner.ApplicantsFullname + "."); } } }
protected void btnSearch_Click(object sender, EventArgs e) { if (!string.IsNullOrWhiteSpace(txtSearch.Text)) { using (var db = new LandxEntities()) { string searchText = txtSearch.Text.Trim().ToLower(); if (searchText.StartsWith("land")) { int id; try { id = Convert.ToInt32(searchText.Replace("land", "").Trim()); } catch (Exception) { litError.Text = "The Input text is not a valid ID."; return; } Models.Land land = db.Lands.Find(id); if (land == null) { litError.Text = "No land was found with this ID."; return; } else { panFound.Visible = true; litDescription.Text = land.LandDescription; litId.Text = searchText; litOwnerName.Text = land.Person.ApplicantsFullname; litPhone.Text = land.Person.PhoneNumber; } } } } }
private void lstFound_SelectedIndexChanged(object sender, EventArgs e) { try { string selectedString = lstFound.SelectedItem.ToString(); string selectedId = selectedString.Replace(selectedString.Substring(selectedString.IndexOf(' ')), ""); using (var db = new LandxEntities()) { if (selectedId.Trim().StartsWith("land")) { int id = Convert.ToInt32(selectedId.Replace("land", "").Trim()); Models.Land land = db.Lands.Find(id); if (land == null) { MessageBox.Show("No land was found with this ID."); return; } else { lblLandDescription.Text = land.LandDescription; lblLandLocation.Text = land.Town; lblLandOwnerName.Text = land.Person.ApplicantsFullname; lblLandOwnerNumber.Text = land.Person.PhoneNumber; //08157026571 btnLandDetails.Tag = land; var ms = new MemoryStream(land.Person.Pic); picProfile.Image = Image.FromStream(ms); animPan.HideSync(panSearch); animPan.ShowSync(panLand); } } else if (selectedId.Trim().StartsWith("psn")) { int id = Convert.ToInt32(selectedId.Replace("psn", "").Trim()); Models.Person psn = db.People.Find(id); if (psn == null) { MessageBox.Show("No Person was found with this ID."); return; } else { lblOwnerName.Text = psn.ApplicantsFullname; lblOwnerNumber.Text = psn.PhoneNumber; btnOwnerDetail.Tag = psn; var ms = new MemoryStream(psn.Pic); picOwner.Image = Image.FromStream(ms); panLands4Owner.Controls.Clear(); Models.Land[] land = psn.Lands.ToArray(); for (int i = 0; i < land.Count(); i++) { UClands pLand = new UClands(); pLand.Tag = land[i]; pLand.Top = (i * pLand.Height) + ((i + 1) * 10); panLands4Owner.Controls.Add(pLand); } animPan.HideSync(panSearch); animPan.ShowSync(panOwner); } } } } catch (Exception) { } }
private void btnSearch_Click(object sender, EventArgs e) { using (var db = new LandxEntities()) { if (txtSearch.Text.Trim().ToLower().StartsWith("land")) { int id; try { id = Convert.ToInt32(txtSearch.Text.Replace("land", "").Trim()); } catch (Exception) { MessageBox.Show("The Input text is not a valid ID."); return; } Models.Land land = db.Lands.Find(id); if (land == null) { MessageBox.Show("No land was found with this ID."); return; } else { lstFound.Items.Add(string.Format("land{0} ({1})", land.Id.ToString("d4"), land.Person.ApplicantsFullname)); } } else if (txtSearch.Text.Trim().ToLower().StartsWith("psn")) { int id; try { id = Convert.ToInt32(txtSearch.Text.Replace("psn", "").Trim()); } catch (Exception) { MessageBox.Show("The Input text is not a valid ID."); return; } Models.Person psn = db.People.Find(id); if (psn == null) { MessageBox.Show("No Person was found with this ID."); return; } else { lstFound.Items.Add(string.Format("psn{0} ({1})", psn.Id.ToString("d4"), psn.ApplicantsFullname)); } } else { List <Person> ppl = db.People.Where(x => x.ApplicantsFullname.Contains(txtSearch.Text.Trim().ToLower())).ToList(); if (ppl.Count < 1) { MessageBox.Show("No Person was found with this Name."); return; } else { foreach (var psn in ppl) { lstFound.Items.Add(string.Format("psn{0} ({1})", psn.Id.ToString("d4"), psn.ApplicantsFullname)); } } } } }
private void btnSubmit_Click(object sender, EventArgs e) { using (var db = new LandxEntities()) { land = db.Lands.Find(land.Id); if (doc1changed) { if (string.IsNullOrWhiteSpace(txtDocument1Name.Text) && lblDocument1.Tag == null) { } else if (string.IsNullOrWhiteSpace(txtDocument1Name.Text) && lblDocument1.Tag != null) { MessageBox.Show("Please enter the TYPE for Document 1."); return; } else if (!string.IsNullOrWhiteSpace(txtDocument1Name.Text) && lblDocument1.Tag == null) { MessageBox.Show("Please select the FILE for Document 1."); return; } else { string ext = lblDocument1.Tag.ToString().Split('.').Last(); string ddate = DateTime.Now.ToShortDateString().Replace("/", "") + DateTime.Now.ToShortTimeString().Replace(":", "").Replace(" ", ""); string newFileName = txtDocument1Name.Text.Trim() + "_" + ddate + "." + ext; File.Copy(lblDocument1.Tag.ToString(), docPath + newFileName); land.LandDoc1 = newFileName; } } if (doc2changed) { if (string.IsNullOrWhiteSpace(txtDocument2Name.Text) && lblDocument2.Tag == null) { } else if (string.IsNullOrWhiteSpace(txtDocument2Name.Text) && lblDocument2.Tag != null) { MessageBox.Show("Please enter the TYPE for Document 2."); return; } else if (!string.IsNullOrWhiteSpace(txtDocument2Name.Text) && lblDocument2.Tag == null) { MessageBox.Show("Please select the FILE for Document 2."); return; } else { string ext = lblDocument2.Tag.ToString().Split('.').Last(); string ddate = DateTime.Now.ToShortDateString().Replace("/", "") + DateTime.Now.ToShortTimeString().Replace(":", "").Replace(" ", ""); string newFileName = txtDocument2Name.Text.Trim() + "_" + ddate + "." + ext; File.Copy(lblDocument2.Tag.ToString(), docPath + newFileName); land.LandDoc2 = newFileName; } } if (doc3changed) { if (string.IsNullOrWhiteSpace(txtDocument3Name.Text) && lblDocument3.Tag == null) { } else if (string.IsNullOrWhiteSpace(txtDocument3Name.Text) && lblDocument3.Tag != null) { MessageBox.Show("Please enter the TYPE for Document 3."); return; } else if (!string.IsNullOrWhiteSpace(txtDocument3Name.Text) && lblDocument3.Tag == null) { MessageBox.Show("Please select the FILE for Document 3."); return; } else { string ext = lblDocument3.Tag.ToString().Split('.').Last(); string ddate = DateTime.Now.ToShortDateString().Replace("/", "") + DateTime.Now.ToShortTimeString().Replace(":", "").Replace(" ", ""); string newFileName = txtDocument3Name.Text.Trim() + "_" + ddate + "." + ext; File.Copy(lblDocument3.Tag.ToString(), docPath + newFileName); land.LandDoc3 = newFileName; } } if (doc4changed) { if (string.IsNullOrWhiteSpace(txtDocument4Name.Text) && lblDocument4.Tag == null) { } else if (string.IsNullOrWhiteSpace(txtDocument4Name.Text) && lblDocument4.Tag != null) { MessageBox.Show("Please enter the TYPE for Document 4."); return; } else if (!string.IsNullOrWhiteSpace(txtDocument4Name.Text) && lblDocument4.Tag == null) { MessageBox.Show("Please select the FILE for Document 4."); return; } else { string ext = lblDocument4.Tag.ToString().Split('.').Last(); string ddate = DateTime.Now.ToShortDateString().Replace("/", "") + DateTime.Now.ToShortTimeString().Replace(":", "").Replace(" ", ""); string newFileName = txtDocument4Name.Text.Trim() + "_" + ddate + "." + ext; File.Copy(lblDocument4.Tag.ToString(), docPath + newFileName); land.LandDoc4 = newFileName; } } if (doc5changed) { if (string.IsNullOrWhiteSpace(txtDocument5Name.Text) && lblDocument5.Tag == null) { } else if (string.IsNullOrWhiteSpace(txtDocument5Name.Text) && lblDocument5.Tag != null) { MessageBox.Show("Please enter the TYPE for Document 5."); return; } else if (!string.IsNullOrWhiteSpace(txtDocument5Name.Text) && lblDocument5.Tag == null) { MessageBox.Show("Please select the FILE for Document 5."); return; } else { string ext = lblDocument5.Tag.ToString().Split('.').Last(); string ddate = DateTime.Now.ToShortDateString().Replace("/", "") + DateTime.Now.ToShortTimeString().Replace(":", "").Replace(" ", ""); string newFileName = txtDocument5Name.Text.Trim() + "_" + ddate + "." + ext; File.Copy(lblDocument5.Tag.ToString(), docPath + newFileName, true); land.LandDoc5 = newFileName; } } land.LandDescription = txtLandDescription.Text; land.LeaseTerm = txtLeaseTerm.Text; land.Town = txtTown.Text; if (radCustomaryOccupancy.Checked) { land.TypeofOccupancy = "Customary"; } else if (radStatutoryOccupancy.Checked) { land.TypeofOccupancy = "Statutory"; } land.VendorGuarantorAddress = txtVendorAddress.Text; land.VendorGuarantorName = txtVendoName.Text; land.VendorGuarantorPhone = txtVenorNumber.Text; db.SaveChanges(); MessageBox.Show("Changes were saved successfully."); Close(); } }
private void btnSave_Click(object sender, EventArgs e) { if (LLTemplate == null) { MessageBox.Show("Enrol the Landlord's Fingerprint."); return; } if (NoKTemplate == null) { MessageBox.Show("Enrol the Next of Kin's Fingerprint."); return; } if (picProfile.Image == null) { MessageBox.Show("Select a Profile Picture."); return; } if (string.IsNullOrWhiteSpace(txtFullName.Text)) { MessageBox.Show("The Fullname Field is Compulsory."); return; } if (string.IsNullOrWhiteSpace(txtNokName.Text)) { MessageBox.Show("The Next of Kin's Name Field is Compulsory."); return; } if (!Directory.Exists(LLFPpath)) { Directory.CreateDirectory(LLFPpath); } if (!Directory.Exists(NoKFPpath)) { Directory.CreateDirectory(NoKFPpath); } using (var db = new LandxEntities()) { Person person = new Person(); person.Address = txtAddress.Text; person.ApplicantsFullname = txtFullName.Text; person.DoB = txtDob.Text; person.Email = txtEmail.Text; person.LGA = txtLGA.Text; person.Nationality = txtNationality.Text; person.NoKName = txtNokName.Text; person.NoKPhone = txtNokPhone.Text; person.Occupation = txtOccupation.Text; person.PhoneNumber = txtPhone.Text; person.TypeofCompany = txtCompanytype.Text; using (MemoryStream ms = new MemoryStream()) { picProfile.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); person.Pic = ms.ToArray(); } person = db.People.Add(person); db.SaveChanges(); using (FileStream fs = new FileStream(LLFPpath + "/" + person.Id.ToString() + ".fpt", FileMode.Create, FileAccess.Write)) { LLTemplate.Serialize(fs); } using (FileStream fs = new FileStream(NoKFPpath + "/" + person.Id.ToString() + ".fpt", FileMode.Create, FileAccess.Write)) { NoKTemplate.Serialize(fs); } MessageBox.Show(string.Format("Landlord was Added Successfully.\n The Person ID is psn{0}", person.Id.ToString("d4"))); } }