Пример #1
0
        //inserts new Lease in database
        public string CreateLease(Lease lease)
        {
            string active = "1";

            if (lease.active == false)
            {
                active = "0";
            }

            string insertLease = $"insert into Lease (CreationDate, Active, DebtorID, BranchID, ContactFname, ContactLname, ContactPhone, Status) output inserted.LeaseID " +
                                 $"Values (CONVERT (date, CURRENT_TIMESTAMP), {active}, '{lease.debtorID}', {lease.branchID}, '{lease.contactFirstName.Replace("'", "''")}'," +
                                 $" '{lease.contactLastName.Replace("'", "''")}', '{lease.contactPhone.Replace("'", "''")}', '{lease.status}')";

            DataTable dataTable = DatabaseManager.ReadFromDatabase(insertLease);

            int leaseID = (int)dataTable.Rows[0][0];

            if (lease.GetLeaseOrders().Count > 0)
            {
                lease.SetLeaseID(leaseID);

                string insertLeaseOrder = GetLeaseOrderInsertString(lease);

                string isInsertSuccess = DatabaseManager.CreateUpdateDeleteInDatabase(insertLeaseOrder);

                return(leaseID.ToString() + ";" + isInsertSuccess);
            }
            else
            {
                return(leaseID.ToString() + ";Success");
            }
        }
Пример #2
0
        private void buttonUpdateOrder_Click(object sender, EventArgs e)
        {
            DelpinCore.Lease lease = GetLeaseFromForm();
            lease.SetLeaseID(Convert.ToInt32(leaseNumber.Text));
            string isUpdateSuccess = controller.UpdateLease(lease);

            MessageBox.Show(isUpdateSuccess);
        }