示例#1
0
        private void btnDelete_Click(object sender, EventArgs e)//DELETE MORTGAGE
        {
            //get the current record's Id from text box.
            currentMortgageId = Convert.ToInt32(txtCurrentMortgage.Text);
            var itemToDelete = db.Mortgages.Where(c => c.Id == currentMortgageId).Select(c => c).Single();

            //now delete from the record
            Mortgage mortgage = (Mortgage)itemToDelete;

            db.Mortgages.DeleteOnSubmit(mortgage); db.SubmitChanges();

            //now update
            PopulateComboBoxPropertyIDs();
            PopulateComboBoxMortgageRecords();
            DisplayAllMortgages();
        }
示例#2
0
        private void btnCreateMortgage_Click(object sender, EventArgs e)//CREATE MORTGAGE
        {
            //Trying to get the IDs of the property based on the selected index; there can only be only. where index equal this, then return the id.

            Mortgage newMortgage = new Mortgage()
            {
                PropertyID = propertyIdToAttach
            };                                                                         //must use comboBox

            db.Mortgages.InsertOnSubmit(newMortgage);
            db.SubmitChanges();
            currentMortgageId       = newMortgage.Id;
            txtCurrentMortgage.Text = Convert.ToString(currentMortgageId);

            //now update the properties datbase
            MessageBox.Show("New Mortgage Created, now complete the text boxes.");
            grpMortgagePurchase.Visible = true;
            DisplayCreateMortgageSingleRecord();
            PopulateComboBoxMortgageRecords();
            PopulateComboBoxPropertyIDs();
            DisplayAllMortgages();
        }
 partial void UpdateMortgage(Mortgage instance);
 partial void DeleteMortgage(Mortgage instance);
 partial void InsertMortgage(Mortgage instance);