Exemplo n.º 1
0
        public bool CancelLoadTenderEntry(int entryID, DateTime cancelled, string cancelledBy)
        {
            //
            bool result = false;

            try {
                //Apply simple business rules
                LoadTenderEntry entry = ReadLoadTenderEntry(entryID);
                if (entry.PickupNumber > 0)
                {
                    //Get the pickup appointment or request and check if picked up
                    if (entry.PickupNumber.ToString().Substring(0, 1) == "1")
                    {
                        ClientInboundFreight appt = null;
                        if (appt != null && appt.ActualArrival != DateTime.MinValue)
                        {
                            throw new ApplicationException("This load tender has already been picked up.");
                        }
                    }
                    else
                    {
                        PickupRequest pickup = null;
                        if (pickup != null && pickup.ActualPickup != DateTime.MinValue)
                        {
                            throw new ApplicationException("This load tender has already been picked up.");
                        }
                    }
                }

                //Create the TransactionScope to execute the commands, guaranteeing that both commands can commit or roll back as a single unit of work
                using (TransactionScope scope = new TransactionScope()) {
                    if (entry.PickupNumber > 0)
                    {
                        //Get the pickup appointment or request and check if picked up
                        if (entry.PickupNumber.ToString().Substring(0, 1) == "1")
                        {
                            //Cancel the pickup appointment
                            new DispatchGateway().CancelClientInboundFreight(entry.PickupNumber, cancelled, cancelledBy);
                        }
                        else
                        {
                            //Cancel the pickup request
                            new DispatchGateway().CancelPickupRequest(entry.PickupNumber, cancelled, cancelledBy);
                        }
                    }

                    //Cancel the load tender entry
                    result = new DispatchGateway().CancelLoadTenderEntry(entryID, cancelled, cancelledBy);

                    //Commits the transaction; if an exception is thrown, Complete is not called and the transaction is rolled back
                    scope.Complete();
                }
            }
            catch (Exception ex) { throw new FaultException <DispatchFault>(new DispatchFault(ex.Message), "Service Error"); }
            return(result);
        }
Exemplo n.º 2
0
        public bool UpdateLoadTenderEntry(LoadTenderEntry entry)
        {
            //UPdate an existing load tender
            bool updated = false;

            try {
                updated = new DispatchGateway().UpdateLoadTenderEntry(entry);
            }
            catch (Exception ex) { throw new FaultException <DispatchFault>(new DispatchFault(ex.Message), "Service Error"); }
            return(updated);
        }
Exemplo n.º 3
0
        public LoadTenderEntry ReadLoadTenderEntry(int id)
        {
            //Read an existing load tender
            LoadTenderEntry entry = new LoadTenderEntry();

            try {
                DataSet ds = new DispatchGateway().ReadLoadTenderEntry(id);
                if (ds != null && ds.Tables["LoadTenderLogTable"] != null && ds.Tables["LoadTenderLogTable"].Rows.Count > 0)
                {
                    DataRow _entry = ds.Tables["LoadTenderLogTable"].Rows[0];
                    #region Set fields
                    entry.ID                 = int.Parse(_entry["ID"].ToString());
                    entry.Created            = DateTime.Parse(_entry["Created"].ToString());
                    entry.CreateUserID       = _entry["CreateUserID"].ToString();
                    entry.ScheduleDate       = DateTime.Parse(_entry["ScheduleDate"].ToString());
                    entry.ClientNumber       = _entry["ClientNumber"].ToString();
                    entry.Client             = _entry["Client"].ToString();
                    entry.VendorNumber       = _entry["VendorNumber"].ToString();
                    entry.VendorName         = _entry["VendorName"].ToString();
                    entry.VendorAddressLine1 = _entry["VendorAddressLine1"].ToString();
                    entry.VendorAddressLine2 = !_entry.IsNull("VendorAddressLine2") ? _entry["VendorAddressLine2"].ToString() : "";
                    entry.VendorCity         = _entry["VendorCity"].ToString();
                    entry.VendorState        = _entry["VendorState"].ToString();
                    entry.VendorZip          = _entry["VendorZip"].ToString();
                    entry.VendorZip4         = !_entry.IsNull("VendorZip4") ? _entry["VendorZip4"].ToString() : "";
                    entry.ContactName        = !_entry.IsNull("ContactName") ? _entry["ContactName"].ToString() : "";
                    entry.ContactPhone       = !_entry.IsNull("ContactPhone") ? _entry["ContactPhone"].ToString() : "";
                    entry.ContactEmail       = !_entry.IsNull("ContactEmail") ? _entry["ContactEmail"].ToString() : "";
                    entry.WindowOpen         = !_entry.IsNull("WindowOpen") ? int.Parse(_entry["WindowOpen"].ToString()) : 0;
                    entry.WindowClose        = !_entry.IsNull("WindowClose") ? int.Parse(_entry["WindowClose"].ToString()) : 0;
                    entry.Description        = !_entry.IsNull("Description") ? _entry["Description"].ToString() : "";
                    entry.Amount             = !_entry.IsNull("Amount") ? int.Parse(_entry["Amount"].ToString()) : 0;
                    entry.AmountType         = !_entry.IsNull("AmountType") ? _entry["AmountType"].ToString() : "";
                    entry.Weight             = !_entry.IsNull("Weight") ? int.Parse(_entry["Weight"].ToString()) : 0;
                    entry.IsFullTrailer      = !_entry.IsNull("IsFullTrailer") ? bool.Parse(_entry["IsFullTrailer"].ToString()) : false;
                    entry.LoadTenderNumber   = !_entry.IsNull("LoadTenderNumber") ? int.Parse(_entry["LoadTenderNumber"].ToString()) : 0;
                    entry.PickupNumber       = !_entry.IsNull("PickupNumber") ? int.Parse(_entry["PickupNumber"].ToString()) : 0;
                    entry.Cancelled          = !_entry.IsNull("Cancelled") ? DateTime.Parse(_entry["Cancelled"].ToString()) : DateTime.MinValue;
                    entry.CancelledUserID    = !_entry.IsNull("CancelledBy") ? _entry["CancelledBy"].ToString() : "";
                    entry.Comments           = !_entry.IsNull("Comments") ? _entry["Comments"].ToString() : "";
                    entry.LastUpdated        = !_entry.IsNull("LastUpdated") ? DateTime.Parse(_entry["LastUpdated"].ToString()) : DateTime.MinValue;
                    entry.UserID             = !_entry.IsNull("UserID") ? _entry["UserID"].ToString() : "";
                    #endregion
                }
            }
            catch (Exception ex) { throw new FaultException <DispatchFault>(new DispatchFault(ex.Message), "Service Error"); }
            return(entry);
        }
Exemplo n.º 4
0
        public bool UpdateLoadTenderEntry(LoadTenderEntry entry)
        {
            //Update an existing load tender
            bool updated = false;

            try {
                updated = new DataService().ExecuteNonQuery(SQL_CONNID, USP_LOADTENDERENTRY_UPDATE,
                                                            new object[] {
                    entry.ID, entry.ScheduleDate,
                    entry.VendorNumber, entry.VendorName, entry.VendorAddressLine1, entry.VendorAddressLine2, entry.VendorCity, entry.VendorState, entry.VendorZip, entry.VendorZip4,
                    entry.ContactName, entry.ContactPhone, entry.ContactEmail, entry.WindowOpen, entry.WindowClose, entry.Description,
                    entry.Amount, entry.AmountType, entry.Weight, entry.IsFullTrailer, entry.Comments,
                    entry.LastUpdated, entry.UserID
                });
            }
            catch (Exception ex) { throw new ApplicationException(ex.Message, ex); }
            return(updated);
        }
Exemplo n.º 5
0
        public int CreateLoadTenderEntry(LoadTenderEntry entry)
        {
            //Create a new load tender
            int id = 0;

            try {
                object o = new DataService().ExecuteNonQueryWithReturn(SQL_CONNID, USP_LOADTENDERENTRY_CREATE,
                                                                       new object[] {
                    0, entry.Created, entry.CreateUserID, entry.ScheduleDate, entry.ClientNumber, entry.Client,
                    entry.VendorNumber, entry.VendorName, entry.VendorAddressLine1, entry.VendorAddressLine2, entry.VendorCity, entry.VendorState, entry.VendorZip, entry.VendorZip4,
                    entry.ContactName, entry.ContactPhone, entry.ContactEmail, entry.WindowOpen, entry.WindowClose, entry.Description,
                    entry.Amount, entry.AmountType, entry.Weight, entry.IsFullTrailer, entry.Comments,
                    entry.LastUpdated, entry.UserID
                });
                id = (int)o;
            }
            catch (Exception ex) { throw new ApplicationException(ex.Message, ex); }
            return(id);
        }
Exemplo n.º 6
0
        public int CreateLoadTenderEntry(LoadTenderEntry entry)
        {
            //Create a new load tender
            int id = 0;

            try {
                //Apply simple business rules (if applicable)


                //Execute the business transcation
                using (TransactionScope scope = new TransactionScope()) {
                    //Create the LoadTenderQuote
                    id = new DispatchGateway().CreateLoadTenderEntry(entry);

                    //Commit the transaction
                    scope.Complete();
                }
            }
            catch (Exception ex) { throw new FaultException <DispatchFault>(new DispatchFault(ex.Message), "Service Error"); }
            return(id);
        }