示例#1
0
 public manifestoutgoing InsertAndGetItem(manifestoutgoing t)
 {
     using (var db = new OcphDbContext())
     {
         var transaction = db.BeginTransaction();
         try
         {
             t.Code = Helpers.GenerateOutgoingCode();
             var date = DateTime.Now;
             t.CreatedDate = date;
             t.UpdateDate  = date;
             var manifestId = db.Outgoing.InsertAndGetLastID(t);
             if (manifestId > 0)
             {
                 foreach (var item in t.PackingList)
                 {
                     item.ManifestID = manifestId;
                     item.Id         = db.PackingLists.InsertAndGetLastID(item);
                     if (item.Id <= 0)
                     {
                         throw new SystemException("Error");
                     }
                 }
                 transaction.Commit();
                 return(t);
             }
             throw new SystemException("Error");
         }
         catch (Exception ex)
         {
             transaction.Rollback();
             throw new SystemException(ex.Message);
         }
     }
 }
        public async void SetManifest(manifestoutgoing manifest)
        {
            Source.Clear();
            this._manifest = manifest;
            var stt = _manifest.PackingList.GroupBy(O => O.PenjualanId).ToList();

            foreach (var item in stt)
            {
                var result = await MainVM.PenjualanCollection.GetItemById(item.Key);

                if (result != null)
                {
                    var detail = from b in item.ToList()
                                 join c in result.Details on b.CollyNumber equals c.CollyNumber
                                 select c;

                    var newItem = new Models.ManifestView();
                    newItem.STT         = string.Format("{0:D5}", result.STT);
                    newItem.Code        = _manifest.Code;
                    newItem.PortType    = manifest.PortType.ToString();
                    newItem.PayType     = result.PayType;
                    newItem.Pcs         = item.Count();
                    newItem.WeightView  = detail.Sum(O => O.Weight);
                    newItem.ShiperName  = MainVM.CustomerCollection.Source.Where(O => O.Id == result.ShiperID).FirstOrDefault().Name;
                    newItem.ReciverName = MainVM.CustomerCollection.Source.Where(O => O.Id == result.ReciverID).FirstOrDefault().Name;
                    newItem.AgentName   = _manifest.Agent.Name;
                    newItem.CreatedDate = _manifest.CreatedDate;
                    Source.Add(newItem);
                }
            }
            SourceView.Refresh();
        }
示例#3
0
        public async Task <manifestoutgoing> Add(manifestoutgoing item)
        {
            var result = await client.PostAsync <manifestoutgoing>("Post", item);

            if (result != null)
            {
                Source.Add(result);
            }
            return(result);
        }
示例#4
0
 public static int GetNewOutgoingManifestCode(manifestoutgoing lastitem)
 {
     if (lastitem == null)
     {
         return(1);
     }
     else
     {
         return(lastitem.Code + 1);
     }
 }
示例#5
0
        internal async Task <bool> UpdateDestination(manifestoutgoing selectedItem)
        {
            var result = await client.PutAsync <manifestoutgoing>("UpdateDestination", selectedItem.Id, selectedItem);

            if (result != default(manifestoutgoing))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#6
0
 public manifestoutgoing UpdateDestination(manifestoutgoing manifest)
 {
     using (var db = new OcphDbContext())
     {
         var isUpdated = db.Outgoing.Update(O => new { O.OnDestinationPort }, manifest, O => O.Id == manifest.Id);
         if (isUpdated)
         {
             return(manifest);
         }
         else
         {
             throw new SystemException("Data Tidak tersimpan");
         }
     }
 }
示例#7
0
        private async void SaveAction(object obj)
        {
            try
            {
                manifestoutgoing manifest = (manifestoutgoing)this;
                var result = await context.CreateNewManifest(ScheduleSelected, manifest, Source);

                Success = true;

                var man = new Manifest
                {
                    Complete            = false,
                    CreatedDate         = result.CreatedDate,
                    OriginPortName      = ScheduleSelected.OriginPortName,
                    DestinationPortName = ScheduleSelected.DestinationPortName,
                    DestinationPortCode = ScheduleSelected.DestinationPortCode,
                    OriginPortCode      = ScheduleSelected.OriginPortCode,
                    PlaneName           = ScheduleSelected.PlaneName,
                    PlaneCode           = ScheduleSelected.PlaneCode,
                    End         = ScheduleSelected.End,
                    Start       = ScheduleSelected.Start,
                    IsTakeOff   = false,
                    User        = result.User,
                    Tanggal     = result.CreatedDate,
                    Id          = result.Id,
                    PlaneId     = ScheduleSelected.PlaneId,
                    PortFrom    = ScheduleSelected.PortFrom,
                    PortTo      = ScheduleSelected.PortTo,
                    SchedulesId = SchedulesId
                };

                this.SavedResult = man;
                WindowClose();
            }
            catch (Exception ex)
            {
                Helpers.ShowErrorMessage(ex.Message);
            }
        }
示例#8
0
        public Task <manifestoutgoing> CreateNewManifest(Schedule scheduleSelected, manifestoutgoing manifest, ObservableCollection <SMU> source)
        {
            using (var db = new OcphDbContext())
            {
                var trans = db.BeginTransaction();
                try
                {
                    manifest.Id = db.Manifest.InsertAndGetLastID(manifest);
                    if (manifest.Id <= 0)
                    {
                        throw new SystemException("Manifest Tidak Tersimpan");
                    }

                    foreach (var item in source.Where(O => O.IsSended).ToList())
                    {
                        var detail = new manifestdetails {
                            Id = 0, manifestoutgoingId = manifest.Id, SMUId = item.Id
                        };
                        detail.Id = db.ManifestDetail.InsertAndGetLastID(detail);
                        if (detail.Id <= 0)
                        {
                            throw new SystemException("Manifest Tidak Tersimpan");
                        }
                        //Debet Deposit
                        if (item.PayType == PayType.Deposit)
                        {
                            var date = DateTime.Now;
                            Tuple <bool, double> cukup = CustomerDepositCukup(item.ShiperId, item.Total);
                            var debet = new debetdeposit {
                                CreatedDate = scheduleSelected.Tanggal, SMUId = item.Id
                            };
                            if (cukup.Item1)
                            {
                                var depId = db.DebetDeposit.InsertAndGetLastID(debet);
                                if (depId <= 0)
                                {
                                    throw new SystemException("Gagal Debet Deposit");
                                }

                                var hist = User.GenerateHistory(depId, BussinesType.DebetDeposit, ChangeType.Create, "");
                                if (!db.Histories.Insert(hist))
                                {
                                    throw new SystemException("Gagal Debet Deposit");
                                }
                            }
                            else
                            {
                                throw new SystemException(string.Format(" Saldo Tidak Cukup !\r Sisa Saldo Rp {0:N2}", cukup.Item2));
                            }
                        }



                        //update SMU

                        if (!db.SMU.Update(O => new { O.IsSended }, new smu {
                            Id = item.Id, IsSended = true
                        }, O => O.Id == item.Id))
                        {
                            throw new SystemException("Manifest Tidak Tersimpan");
                        }

                        var his = User.GenerateHistory(item.Id, BussinesType.SMU, ChangeType.Update, string.Format("Ditambahkan Ke Manifest MT{0:D8}", manifest.Id));
                        if (!db.Histories.Insert(his))
                        {
                            throw new SystemException("Manifest Tidak Tersimpan");
                        }
                    }

                    var history = User.GenerateHistory(manifest.Id, BussinesType.Manifest, ChangeType.Create, "");
                    if (!db.Histories.Insert(history))
                    {
                        throw new SystemException("Manifest Tidak Tersimpan");
                    }

                    manifest.User = User.Name;

                    trans.Commit();
                    return(Task.FromResult(manifest));
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    throw new SyntaxErrorException(ex.Message);
                }
            }
        }
示例#9
0
 public manifestoutgoing Post(manifestoutgoing t)
 {
     return(context.InsertAndGetItem(t));
 }
        internal Task <List <penjualan> > GetByParameter(manifestoutgoing manifestoutgoing)
        {
            var uri = "GetByParameter?agentId=" + manifestoutgoing.AgentId + "&type=" + manifestoutgoing.PortType;

            return(client.GetAsync <List <penjualan> >(uri));
        }