Beispiel #1
0
        /// <summary>
        /// Updates the specified inserted.
        /// </summary>
        /// <param name="inserted">The inserted.</param>
        /// <param name="updated">The updated.</param>
        /// <param name="deleted">The deleted.</param>
        public void Update(List <BLL.DispatchDetail> inserted, List <BLL.DispatchDetail> updated,
                           List <BLL.DispatchDetail> deleted)
        {
            CTSContext db = new CTSContext();

            BLL.Dispatch orginal = db.Dispatches.Where(p => p.DispatchID == this.DispatchID).SingleOrDefault();
            if (orginal != null)
            {
                orginal.BidNumber       = this.BidNumber;
                orginal.DispatchDate    = this.DispatchDate;
                orginal.DriverName      = this.DriverName;
                orginal.FDPID           = this.FDPID;
                orginal.GIN             = this.GIN;
                orginal.PeriodYear      = this.PeriodYear;
                orginal.PeriodMonth     = this.PeriodMonth;
                orginal.PlateNo_Prime   = this.PlateNo_Prime;
                orginal.PlateNo_Trailer = this.PlateNo_Trailer;
                //orginal.ProgramID = this.ProgramID;
                orginal.RequisitionNo = this.RequisitionNo;
                orginal.Round         = this.Round;
                //orginal.StackNumber = this.StackNumber;
                //orginal.StoreID = this.StoreID;
                orginal.TransporterID = this.TransporterID;
                orginal.UserProfileID = this.UserProfileID;
                //orginal.WarehouseID = this.WarehouseID;
                orginal.WeighBridgeTicketNumber = this.WeighBridgeTicketNumber;
                orginal.Remark = this.Remark;
                orginal.DispatchedByStoreMan = this.DispatchedByStoreMan;
                //orginal.ProjectNumber = this.ProjectNumber;
                //orginal.SINumber = this.SINumber;



                foreach (BLL.DispatchDetail update in updated)
                {
                    BLL.DispatchDetail updatedCommodity = db.DispatchDetails.Where(p => p.DispatchDetailID == update.DispatchDetailID).SingleOrDefault();
                    if (updatedCommodity != null)
                    {
                        updatedCommodity.CommodityID = update.CommodityID;
                        updatedCommodity.Description = update.Description;
                        //updatedCommodity.DispatchedQuantityInUnit = update.DispatchedQuantityInUnit;
                        //updatedCommodity.DispatchedQuantityInMT = update.DispatchedQuantityInMT;
                        updatedCommodity.RequestedQunatityInUnit = update.RequestedQunatityInUnit;
                        updatedCommodity.RequestedQuantityInMT   = update.RequestedQuantityInMT;
                        updatedCommodity.UnitID = update.UnitID;
                    }
                }
                db.SaveChanges();
            }
        }
Beispiel #2
0
        /// <summary>
        /// Generates the dispatch model.
        /// </summary>
        /// <param name="dispatch">The dispatch.</param>
        /// <param name="Repository">The repository.</param>
        /// <returns></returns>
        public static Models.DispatchModel GenerateDispatchModel(BLL.Dispatch dispatch, Transaction transactionObj)
        {
            DispatchModel model = new DispatchModel();

            model.BidNumber            = dispatch.BidNumber;
            model.DispatchDate         = dispatch.DispatchDate;
            model.DispatchID           = dispatch.DispatchID;
            model.DriverName           = dispatch.DriverName;
            model.DispatchedByStoreMan = dispatch.DispatchedByStoreMan;
            model.FDPID           = dispatch.FDPID;
            model.GIN             = dispatch.GIN;
            model.Month           = dispatch.PeriodMonth;
            model.Year            = dispatch.PeriodYear;
            model.PlateNo_Prime   = dispatch.PlateNo_Prime;
            model.PlateNo_Trailer = dispatch.PlateNo_Trailer;
            model.RequisitionNo   = dispatch.RequisitionNo;
            model.Type            = dispatch.Type;
            //model.StackNumber = dispatch.StackNumber;
            //model.StoreID = dispatch.StoreID;
            model.TransporterID = dispatch.TransporterID;
            model.WarehouseID   = dispatch.HubID;
            //model.ProgramID = dispatch.ProgramID;
            model.WeighBridgeTicketNumber = dispatch.WeighBridgeTicketNumber;
            model.Remark = dispatch.Remark;

            model.OtherDispatchAllocationID = dispatch.OtherDispatchAllocationID;
            model.DispatchAllocationID      = dispatch.DispatchAllocationID;

            // model.ProjectNumber = dispatch.ProjectNumber;
            //model.SINumber = dispatch.SINumber;
            //TODO:Check modification have any impact
            BLL.Transaction transaction = transactionObj;// Repository.Dispatch.GetDispatchTransaction(dispatch.DispatchID);
            if (transaction != null)
            {
                if (transaction.Stack != null)
                {
                    model.StackNumber = transaction.Stack.Value;
                }
                model.StoreID         = transaction.StoreID;
                model.ProgramID       = transaction.ProgramID;
                model.ProjectNumber   = transaction.ProjectCode.Value;
                model.SINumber        = transaction.ShippingInstruction.Value;
                model.CommodityTypeID = transaction.Commodity.CommodityTypeID;
            }
            model.DispatchDetails = DispatchDetailModel.GenerateDispatchDetailModels(dispatch.DispatchDetails);
            return(model);
        }
Beispiel #3
0
        /// <summary>
        /// Gets the SMS text.
        /// </summary>
        /// <returns></returns>
        public string GetSMSText()
        {
            StringBuilder builder  = new StringBuilder();
            CTSContext    entities = new CTSContext();

            BLL.Dispatch dispatch = entities.Dispatches.Where(d => d.DispatchID == this.DispatchID).SingleOrDefault();
            if (dispatch != null)
            {
                BLL.DispatchDetail com = dispatch.DispatchDetails.FirstOrDefault();
                if (com != null)
                {
                    builder.Append(string.Format("There is a Dispatch with an ammount of {0}(MT) - {1} to your FDP({2}) ", com.RequestedQuantityInMT, com.Commodity.Name, dispatch.FDP.Name));
                    builder.Append(string.Format("on a car with plate no - {0}", dispatch.PlateNo_Prime));
                }
            }

            return(builder.ToString());
        }
Beispiel #4
0
        /// <summary>
        /// Generates the dipatch.
        /// </summary>
        /// <returns></returns>
        public BLL.Dispatch GenerateDipatch(UserProfile user)
        {
            //TODO:Check if any impact converting default constructor to injuct user
            //BLL.UserProfile user = Repository.UserProfile.GetUser(HttpContext.Current.User.Identity.Name);
            BLL.Dispatch dispatch = new BLL.Dispatch()
            {
                BidNumber    = this.BidNumber,
                CreatedDate  = DateTime.Now,
                DispatchDate = this.DispatchDate,

                DriverName           = this.DriverName,
                DispatchedByStoreMan = DispatchedByStoreMan,
                FDPID           = this.FDPID,
                GIN             = this.GIN,
                PeriodYear      = this.Year,
                PeriodMonth     = this.Month,
                PlateNo_Prime   = this.PlateNo_Prime,
                PlateNo_Trailer = this.PlateNo_Trailer,
                RequisitionNo   = this.RequisitionNo,
                //HubID = user.DefaultHub.HubID;
                // StackNumber = this.StackNumber,
                // StoreID = this.StoreID,
                TransporterID = this.TransporterID,
                HubID         = this.WarehouseID,
                //ProgramID = this.ProgramID,
                WeighBridgeTicketNumber = this.WeighBridgeTicketNumber,
                Round  = this.Round,
                Remark = this.Remark,
                //ProjectNumber = this.ProjectNumber,
                // SINumber = this.SINumber
            };
            if (this.DispatchID.HasValue)
            {
                dispatch.DispatchID = this.DispatchID.Value;
            }
            return(dispatch);
        }
        /// <summary>
        /// Generates the dipatch.
        /// </summary>
        /// <returns></returns>
        public BLL.Dispatch GenerateDipatch()
        {
            BLL.UserProfile user = Repository.UserProfile.GetUser(HttpContext.Current.User.Identity.Name);
            BLL.Dispatch dispatch = new BLL.Dispatch()
            {
                BidNumber = this.BidNumber,
                CreatedDate = DateTime.Now,
                DispatchDate = this.DispatchDate,

                DriverName = this.DriverName,
                DispatchedByStoreMan = DispatchedByStoreMan,
                FDPID = this.FDPID,
                GIN = this.GIN,
                PeriodYear = this.Year,
                PeriodMonth = this.Month,
                PlateNo_Prime = this.PlateNo_Prime,
                PlateNo_Trailer = this.PlateNo_Trailer,
                RequisitionNo = this.RequisitionNo,
                //HubID = user.DefaultHub.HubID;
               // StackNumber = this.StackNumber,
               // StoreID = this.StoreID,
                TransporterID = this.TransporterID,
                HubID = this.WarehouseID,
                //ProgramID = this.ProgramID,
                WeighBridgeTicketNumber = this.WeighBridgeTicketNumber,
                Round = this.Round,
                Remark = this.Remark,
                //ProjectNumber = this.ProjectNumber,
               // SINumber = this.SINumber
            };
            if(this.DispatchID.HasValue)
            {
                dispatch.DispatchID = this.DispatchID.Value;
            }
            return dispatch;
        }