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 + "."); } } }
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"))); } }