示例#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();
            }
        }
示例#2
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());
        }
        /// <summary>
        /// Generates the dispatch detail.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        private DispatchDetail GenerateDispatchDetail(DispatchDetailModel c)
        {
            if (c != null)
            {
                DispatchDetail dispatchDetail = new BLL.DispatchDetail()
                {
                    CommodityID = c.CommodityID,
                    Description = c.Description,
                    // DispatchDetailID = c.Id,
                    RequestedQuantityInMT = c.RequestedQuantityMT.Value,
                    //DispatchedQuantityInMT = c.DispatchedQuantityMT,
                    //DispatchedQuantityInUnit = c.DispatchedQuantity,
                    RequestedQunatityInUnit = c.RequestedQuantity.Value,
                    UnitID = c.Unit
                };
                if (c.Id.HasValue)
                {
                    dispatchDetail.DispatchDetailID = c.Id.Value;
                }

                return dispatchDetail;
            }
            else
            {
                return null;
            }
        }