예제 #1
0
        private Lease ConvertDataTabeToLease(DataTable dataTable)
        {
            int      leaseID      = Convert.ToInt32(dataTable.Rows[0]["LeaseID"]);
            int      branchID     = Convert.ToInt32(dataTable.Rows[0]["BranchID"]);
            DateTime creationDate = Convert.ToDateTime(dataTable.Rows[0]["CreationDate"]);
            string   debtorID     = (string)dataTable.Rows[0]["DebtorID"];
            string   status       = (string)dataTable.Rows[0]["Status"];
            string   activeString = (string)dataTable.Rows[0]["Active"];
            bool     active       = true;

            if (activeString == "0")
            {
                active = false;
            }

            Lease lease = new Lease(debtorID, branchID, leaseID, creationDate, active);

            try
            {
                string contactFirstName = (string)dataTable.Rows[0]["ContactFname"];
                string contactLastName  = (string)dataTable.Rows[0]["ContactLname"];
                string contactPhone     = (string)dataTable.Rows[0]["ContactPhone"];

                lease.SetContactDetails(contactFirstName, contactLastName, contactPhone);
            }
            catch { }

            lease.SetStatus(status);

            foreach (DataRow dataRow in dataTable.Rows)
            {
                if (dataRow["StartDate"] == DBNull.Value)
                {
                    continue;
                }
                DateTime startDate   = Convert.ToDateTime(dataRow["StartDate"]);
                DateTime endDate     = Convert.ToDateTime(dataRow["EndDate"]);
                int      resourcesID = Convert.ToInt32(dataRow["ResourcesID"]);
                decimal  leasePrice  = Convert.ToDecimal(dataRow["LeasePrice"]);

                LeaseOrder leaseOrder = new LeaseOrder(startDate, endDate, leasePrice, resourcesID);

                string  deliveryStreet     = dataRow["DeliveryStreet"].ToString();
                int     deliveryPostalCode = Convert.ToInt32(dataRow["DeliveryPostalCode"]);
                string  deliveryCity       = dataRow["DeliveryCity"].ToString();
                decimal deliveryPrice      = Convert.ToDecimal(dataRow["DeliveryPrice"]);

                leaseOrder.SetDeliveryAddress(deliveryStreet, deliveryPostalCode, deliveryCity, deliveryPrice);
                leaseOrder.SetModelName(dataRow["ModelName"].ToString());

                lease.AddLeaseOrder(leaseOrder);
            }

            return(lease);
        }
예제 #2
0
파일: Lease.cs 프로젝트: JCMcGraw/DelpinUCL
        private DelpinCore.Lease GetLeaseFromForm()
        {
            bool active = false;

            if (leaseStatus.SelectedText != "Slettet")
            {
                active = true;
            }

            DelpinCore.Lease lease = new DelpinCore.Lease(debtorIDTextBox.Text, Utility.BranchID, active);

            lease.SetContactDetails(contactFirstName.Text, contactLastName.Text, contactPhone.Text);

            foreach (DataGridViewRow row in leaseOrders.Rows)
            {
                if (row.Cells["ResurseID"].Value == null)
                {
                    continue;
                }
                int      resouceID     = Convert.ToInt32(row.Cells["ResurseID"].Value.ToString());
                DateTime deliveryDate  = Convert.ToDateTime(row.Cells["Leveringsdato"].Value.ToString());
                DateTime returnDate    = Convert.ToDateTime(row.Cells["Slutdato"].Value.ToString());
                decimal  price         = Convert.ToDecimal(row.Cells["Dagspris"].Value.ToString());
                decimal  deliveryPrice = Convert.ToDecimal(row.Cells["Levering"].Value.ToString());

                string deliveryAddrress = row.Cells["Gade"].Value.ToString();

                int deliveryPostCode = 0;
                try
                {
                    deliveryPostCode = Convert.ToInt32(row.Cells["Postkode"].Value.ToString());
                }
                catch { }
                string deliveryCity = row.Cells["By"].Value.ToString();

                LeaseOrder leaseOrder = new LeaseOrder(deliveryDate, returnDate, price, resouceID);
                leaseOrder.SetDeliveryAddress(deliveryAddrress, deliveryPostCode, deliveryCity, deliveryPrice);
                lease.SetStatus("Åben");

                lease.AddLeaseOrder(leaseOrder);
            }

            return(lease);
        }