Example #1
0
        public ProxyResponse <UpdateItemTransferResult> UpdateItemTransfer(TransferDetail detail, int id)
        {
            OperationMethod = HttpMethod.Put;
            var uri = base.GetRequestUri(id.ToString());

            return(base.GetResponse <TransferDetail, UpdateItemTransferResult>(uri, detail));
        }
Example #2
0
 public void DeleteDetail(TransferDetail ob)
 {
     if (IsExist(ob.TransferId))
     {
         db.TransferDetail.Remove(ob);
     }
 }
Example #3
0
        private void CreateTestTransfers()
        {
            var transferItem  = _transferHelper.GetTransferItem((int)_item.Id, 2, _assetAccountId, (decimal)_item.BuyingPrice, (decimal)(2 * _item.BuyingPrice));
            var transferItem2 = _transferHelper.GetTransferItem((int)_item.Id, -2, _incomeAccountId, (decimal)_item.BuyingPrice, (decimal)(-2 * _item.BuyingPrice));

            var detail = _transferHelper.GetTransferDetail(new List <TransferItem>()
            {
                transferItem, transferItem2
            });

            var proxy    = new ItemTransferProxy();
            var response = proxy.InsertItemTransfer(detail);

            _testTransfer = proxy.GetItemTransfer(response.DataObject.InsertedEntityId).DataObject;

            var transferItem3  = _transferHelper.GetTransferItem((int)_item.Id, 2, _assetAccountId, (decimal)_item.BuyingPrice, (decimal)(2 * _item.BuyingPrice));
            var transferItem4  = _transferHelper.GetTransferItem((int)_item.Id, -2, _incomeAccountId, (decimal)_item.BuyingPrice, (decimal)(-2 * _item.BuyingPrice));
            var detailToDelete = _transferHelper.GetTransferDetail(new List <TransferItem>()
            {
                transferItem3, transferItem4
            });

            response = proxy.InsertItemTransfer(detailToDelete);

            _testTransferToDeleteId = proxy.InsertItemTransfer(detailToDelete).DataObject.InsertedEntityId;
        }
        public void TransferDetailInsertTest()
        {
            OpenQbitInventoryContext db = new OpenQbitInventoryContext();
            TransferDetail           newTransferDetail = new TransferDetail {
                ID = 1, BatchID = 1, LocationID = 1, DistributerID = 1
            };

            newTransferDetail.Batch = new Batch {
                Date = DateTime.Today, Qty = 50, UnitPrice = 42.00, ItemID = 1, SupplierID = 1
            };
            newTransferDetail.Location = new Location {
                ID = 1, Name = "Branch"
            };
            newTransferDetail.Distributer = new Distributer {
                ID = 1, Name = "Lasantha", Telephone = "0717896543"
            };

            db.TransferDetail.Add(newTransferDetail);
            db.SaveChanges();

            Distributer findDistributer = db.Distributer.Where(C => C.Name == "Lasantha").FirstOrDefault();

            Assert.AreEqual(newTransferDetail.Distributer.Name, findDistributer.Name);

            //if(findTransferDetail != null)
            //{
            //   db.TransferDetail.Remove(findTransferDetail);
            //}
        }
Example #5
0
        public ProxyResponse <InsertItemTransferResult> InsertItemTransfer(TransferDetail detail)
        {
            OperationMethod = HttpMethod.Post;
            var uri = base.GetRequestUri(null);

            return(base.GetResponse <TransferDetail, InsertItemTransferResult>(uri, detail));
        }
Example #6
0
        public async Task <TransferDetail> Get(int id)
        {
            TransferDetail transferDetail = null;
            string         url            = "http://" + PATHSERVER + "/tshirt/producttransfer/Get";
            string         _id            = "?id=" + id;
            string         uri            = string.Concat(url, _id);

            try
            {
                HttpResponseMessage result = null;

                result = await client.GetAsync(uri);

                if (result.IsSuccessStatusCode)
                {
                    var x = await result.Content.ReadAsStringAsync();

                    transferDetail = JsonConvert.DeserializeObject <TransferDetail>(x);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(@"				ERROR {0}", ex.Message);
            }
            return(transferDetail);
        }
Example #7
0
        public async Task <ActionResult> Detail(string id)
        {
            TransferDetail transfer = new TransferDetail();

            try
            {
                _productTransferServices = new ProductTransferServices();

                var result = await _productTransferServices.Get(int.Parse(id));

                if (result == null)
                {
                    ModelState.AddModelError("", "Error al cargar la lista de almacenes");
                }
                else
                {
                    transfer = result;
                }
            }
            catch (System.Exception)
            {
                return(null);

                throw;
            }

            return(View("Detail", transfer));
        }
Example #8
0
        public ActionResult DeleteConfirmed(int id)
        {
            TransferDetail transferDetail = db.TransferDetail.Find(id);

            db.TransferDetail.Remove(transferDetail);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #9
0
        public void UpdateDetail(TransferDetail ob)
        {
            db.Entry(ob).State = EntityState.Modified;

            /* if (ob.TransferId == 0)
             * { db.TransferDetail.Add(ob); }
             * else { db.Entry(ob).State = EntityState.Modified; }*/
        }
Example #10
0
        public IEnumerable <TransferDetail> QueryTransferDetailByPurchase(Pagination pagination, Guid purchaseId)
        {
            ClearParameters();
            var result = new List <TransferDetail>();

            AddParameter("@iPagesize", pagination.PageSize);
            AddParameter("@iPageIndex", pagination.PageIndex);
            AddParameter("@iGetCount", pagination.GetRowCount);
            AddParameter("@PurchaseId", purchaseId);
            var totalCount = AddParameter("@oTotalCount");

            totalCount.DbType    = System.Data.DbType.Int32;
            totalCount.Direction = System.Data.ParameterDirection.Output;
            using (var reader = ExecuteReader("dbo.P_QueryPurchaseFlightTransferDetail", System.Data.CommandType.StoredProcedure))
            {
                while (reader.Read())
                {
                    var    oFlightNO = reader.GetString(4);
                    string nFlightNO = reader.IsDBNull(5) ? string.Empty : reader.GetString(5);
                    var    item      = new TransferDetail()
                    {
                        TransferId = reader.GetGuid(0),
                        PNR        = new PNRPair(reader.IsDBNull(1) ? string.Empty : reader.GetString(1),
                                                 reader.IsDBNull(2) ? string.Empty : reader.GetString(2)),
                        OrderId             = reader.GetDecimal(3),
                        OriginalCarrier     = oFlightNO.Substring(0, 2),
                        OriginalFlightNo    = oFlightNO.Substring(2),
                        OriginalTakeoffTime = reader.GetDateTime(7),
                        OriginalArrivalTime = reader.GetDateTime(8),
                        Carrier             = !string.IsNullOrEmpty(nFlightNO) ? nFlightNO.Substring(0, 2) : string.Empty,
                        FlightNo            = !string.IsNullOrEmpty(nFlightNO) ? nFlightNO.Substring(2) : string.Empty,
                        TransferType        = (TransferType)reader.GetByte(6),
                    };
                    if (!reader.IsDBNull(11))
                    {
                        item.FlightDate = reader.GetDateTime(11);
                        if (!reader.IsDBNull(9))
                        {
                            item.TakeoffTime = reader.GetDateTime(9);
                            item.TakeoffTime = item.FlightDate.Value.AddHours(item.TakeoffTime.Value.Hour)
                                               .AddMinutes(item.TakeoffTime.Value.Minute);
                        }
                        if (!reader.IsDBNull(10))
                        {
                            item.ArrivalTime = reader.GetDateTime(10);
                            item.ArrivalTime = item.FlightDate.Value.AddHours(item.ArrivalTime.Value.Hour).AddMinutes(item.ArrivalTime.Value.Minute);
                        }
                    }
                    result.Add(item);
                }
            }
            if (pagination.GetRowCount)
            {
                pagination.RowCount = (int)totalCount.Value;
            }
            return(result);
        }
        public async Task ShouldGet()
        {
            /// Arrange
            var result = await CreateTransferAsync();

            /// Act
            TransferDetail transfer = await _client.Transfers.GetAsync(result.Transfer.Id);

            /// Assert
            Assert.NotNull(result);
            Assert.Equal(result.Transfer.Id, transfer.Id);
        }
Example #12
0
        public ActionResult AddProduct()
        {
            string transferId          = Request.Form["TransferId"].ToString();
            var    productids          = Request.Form["ProductIds"].ToString(); //  ProductId:PriceNet
            string qtys                = Request.Form["RequestQtys"].ToString();
            string currentQty          = Request.Form["currentQty"].ToString();
            List <TransferDetail> list = new List <TransferDetail>();


            if (transferId.Count() > 0)
            {
                int row = 0;
                for (row = 0; row < productids.Split(',').Count(); row++)
                {
                    TransferDetail ob = new TransferDetail();
                    ob.TransferId = transferId.ParseInt();
                    ob.ProductId  = productids.Split(',')[row].ParseInt();
                    ob.RequestQty = qtys.Split(',')[row].ParseInt();
                    ob.CurrentQty = currentQty.Split(',')[row];
                    ob.Seq        = row + 1;

                    list.Add(ob);


                    /*   TransferDetail ob = uow.Modules.Transfer.GetDetail(qid.ParseInt(), row+1);
                     * if (ob == null)
                     * {
                     *     ob = new TransferDetail();
                     *     ob.TransferId = qid.ParseInt();
                     *     ob.ProductId = productids.Split(',')[row].ParseInt();
                     *     ob.RequestQty = qtys.Split(',')[row].ParseInt();
                     *     ob.Seq = row + 1;
                     *     uow.Modules.Transfer.SetDetail(ob);
                     * }
                     * else {
                     *     ob.TransferId = qid.ParseInt();
                     *     ob.ProductId = productids.Split(',')[row].ParseInt();
                     *     ob.RequestQty = qtys.Split(',')[row].ParseInt();
                     *     ob.Seq = row + 1;
                     *     uow.Modules.Transfer.UpdateDetail(ob);
                     * }
                     */



                    //  uow.SaveChanges();
                }

                uow.Modules.Transfer.Add(transferId, list);
            }
            return(RedirectToAction("Detail", MVCController, new { id = transferId, tab = "Product", msg = "บันทึกข้อมูลสินค้าเรียบร้อยแล้ว", msgType = AlertMsgType.Success }));
        }
        public bool TransferDetailUpdate(int id, TransferDetail transferDetail)
        {
            OpenQbitInventoryContext db = new OpenQbitInventoryContext();
            TransferDetail           newTransferDetail = db.TransferDetail.Find(id);

            if (newTransferDetail == null)
            {
                return(false);
            }
            db.Entry(newTransferDetail).State = EntityState.Modified;
            db.SaveChanges();
            return(true);
        }
Example #14
0
        public bool Update(ApiTransferDetail apiTransferDetail)
        {
            TransferDetail transferDetail = new TransferDetail
            {
                ID            = apiTransferDetail.ID,
                BatchID       = apiTransferDetail.BatchID,
                LocationID    = apiTransferDetail.LocationID,
                DistributerID = apiTransferDetail.DistributerID,
                CustomerID    = apiTransferDetail.CustomerID
            };

            return(transferDetailManager.UpdateTransferDetail(transferDetail));
        }
Example #15
0
        // GET: TransferDetail/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TransferDetail transferDetail = db.TransferDetail.Find(id);

            if (transferDetail == null)
            {
                return(HttpNotFound());
            }
            return(View(transferDetail));
        }
Example #16
0
 public ActionResult Edit([Bind(Include = "ID,CustomerID,BatchID,LocationID,DistributerID")] TransferDetail transferDetail)
 {
     if (ModelState.IsValid)
     {
         db.Entry(transferDetail).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.BatchID       = new SelectList(db.Batch, "ID", "ID", transferDetail.BatchID);
     ViewBag.CustomerID    = new SelectList(db.Customers, "ID", "Name", transferDetail.CustomerID);
     ViewBag.DistributerID = new SelectList(db.Distributer, "ID", "Name", transferDetail.DistributerID);
     ViewBag.LocationID    = new SelectList(db.Location, "ID", "Name", transferDetail.LocationID);
     return(View(transferDetail));
 }
        public bool TransferDetailDelete(int id)
        {
            OpenQbitInventoryContext db = new OpenQbitInventoryContext();

            TransferDetail transferDetail = db.TransferDetail.Find(id);

            if (transferDetail == null)
            {
                return(false);
            }
            db.TransferDetail.Remove(transferDetail);
            db.SaveChanges();
            return(true);
        }
Example #18
0
        public ApiTransferDetail Get(int ID)
        {
            TransferDetail transferDetail = transferDetailManager.FindTransferDetail(ID);

            ApiTransferDetail apiTransferDetail = new ApiTransferDetail
            {
                ID            = transferDetail.ID,
                BatchID       = transferDetail.BatchID,
                LocationID    = transferDetail.LocationID,
                DistributerID = transferDetail.DistributerID,
                CustomerID    = transferDetail.CustomerID
            };

            return(apiTransferDetail);
        }
Example #19
0
        public bool Update(ApiTransferDetail apiTransferDetail)
        {
            // string id = User.Identity.Name;
            TransferDetail transferDetail = new TransferDetail
            {
                ID            = apiTransferDetail.ID,
                BatchID       = apiTransferDetail.BatchID,
                LocationID    = apiTransferDetail.LocationID,
                DistributerID = apiTransferDetail.DistributerID,
                CustomerID    = Helper.getCustID(),
                qty           = apiTransferDetail.qty
            };

            return(transferDetailManager.UpdateTransferDetail(transferDetail));
        }
        private TransferDetail TransferDetailFromReader(SqlDataReader reader)
        {
            TransferDetail output = new TransferDetail()
            {
                TransferId  = Convert.ToInt32(reader["transfer_id"]),
                AccountTo   = Convert.ToInt32(reader["account_to"]),
                AccountFrom = Convert.ToInt32(reader["account_from"]),
                Amount      = Convert.ToDecimal(reader["amount"]),
                From        = Convert.ToString(reader["FromUser"]),
                To          = Convert.ToString(reader["ToUser"]),
                Status      = Convert.ToString(reader["transfer_status_desc"]),
                Type        = Convert.ToString(reader["transfer_type_desc"])
            };

            return(output);
        }
Example #21
0
        public async Task <IActionResult> GetWMSDetail(uint DocEntry)
        {
            SAPContext context = HttpContext.RequestServices.GetService(typeof(SAPContext)) as SAPContext;

            SAPbobsCOM.Recordset oRecSet = (SAPbobsCOM.Recordset)context.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);

            oRecSet.DoQuery($@"
                Select
                    ""DocEntry"",
                    ""DocNum"",
                    to_char(to_date(SUBSTRING(""DocDate"", 0, 10), 'YYYY-MM-DD'), 'DD-MM-YYYY') as ""DocDate"",
                    to_char(to_date(SUBSTRING(""DocDueDate"", 0, 10), 'YYYY-MM-DD'), 'DD-MM-YYYY') as ""DocDueDate"",
                    to_char(to_date(SUBSTRING(""CancelDate"", 0, 10), 'YYYY-MM-DD'), 'DD-MM-YYYY') as ""CancelDate"",
                    ""Comments"",
                    ""ToWhsCode"",
                    ""Filler""
                From OWTR
                WHERE ""DocEntry"" = '{DocEntry}';");

            if (oRecSet.RecordCount == 0)
            {
                return(NoContent());
            }

            JToken temp = context.XMLTOJSON(oRecSet.GetAsXML())["OWTR"][0];

            oRecSet.DoQuery($@"
                Select
                    ""ItemCode"",
                    ""Dscription"",
                    ""Quantity"",
                    ""UomCode"",
                    ""InvQty"",
                    ""UomCode2""
                From WTR1
                WHERE ""DocEntry"" = '{DocEntry}';");

            temp["TransferRows"] = context.XMLTOJSON(oRecSet.GetAsXML())["WTR1"];

            TransferDetail output = temp.ToObject <TransferDetail>();

            //Force Garbage Collector. Recommendation by InterLatin Dude. SDK Problem with memory.
            GC.Collect();
            GC.WaitForPendingFinalizers();

            return(Ok(output));
        }
Example #22
0
        public async Task ShouldGet()
        {
            // Arrange
            var urls = new List <string>
            {
                "https://picturepark.com/wp-content/uploads/2013/06/home-marquee.jpg",
                "http://cdn1.spiegel.de/images/image-733178-900_breitwand_180x67-zgpe-733178.jpg",
                "http://cdn3.spiegel.de/images/image-1046236-700_poster_16x9-ymle-1046236.jpg"
            };
            var result = await CreateWebTransferAsync(urls).ConfigureAwait(false);

            // Act
            TransferDetail transfer = await _client.Transfer.GetAsync(result.Transfer.Id).ConfigureAwait(false);

            // Assert
            Assert.NotNull(result);
            Assert.Equal(result.Transfer.Id, transfer.Id);
        }
Example #23
0
        // GET: TransferDetail/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TransferDetail transferDetail = db.TransferDetail.Find(id);

            if (transferDetail == null)
            {
                return(HttpNotFound());
            }
            ViewBag.BatchID       = new SelectList(db.Batch, "ID", "ID", transferDetail.BatchID);
            ViewBag.CustomerID    = new SelectList(db.Customers, "ID", "Name", transferDetail.CustomerID);
            ViewBag.DistributerID = new SelectList(db.Distributer, "ID", "Name", transferDetail.DistributerID);
            ViewBag.LocationID    = new SelectList(db.Location, "ID", "Name", transferDetail.LocationID);
            return(View(transferDetail));
        }
        public TransferDetail GetById(int id)
        {
            var transfer = new TransferDetail();

            try
            {
                transfer = (from pt in context.ProductTransfer
                            join wo in context.Warehouses on pt.WarehouseOrigin equals wo.Code
                            join wd in context.Warehouses on pt.WarehouseDestiny equals wd.Code
                            where pt.Id == id
                            select new TransferDetail()
                {
                    Id = pt.Id,
                    WarehouseOrigin = wo.Code,
                    WarehouseDestiny = wd.Code,
                    Status = pt.Status,
                    DateCreated = pt.DateCreated.ToString(),
                    Observation = pt.Observation
                }).FirstOrDefault();

                if (transfer != null)
                {
                    var details = (from dt in context.ProductTransferDetail
                                   where dt.ProductTransfer_Id == id
                                   select new ProductTransferDetailExtend
                    {
                        Quantity = dt.Quantity,
                        ProductCode = dt.ProductCode,
                        ProductDescription = dt.ProductDescription
                    }).ToList();

                    if (details != null)
                    {
                        transfer.products = details;
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.Write(@"Error " + ex.Message);
            }

            return(transfer);
        }
Example #25
0
        static void Main(string[] args)
        {
            ApiHelper helper = new ApiHelper(API_BASE_URL, KEYSTONE_URL, KEYSTONE_CLIENT_ID, KEYSTONE_CLIENT_SECRET, KEYSTONE_USER, KEYSTONE_PASS);

            // First we go see if there is a file there already. with GET/visits/1/fieldFolders/Topo/files/Filename.zip
            var hashcode       = ApiHelper.GetFileHashCode(filepath);
            var transferDetail = new TransferDetail
            {
                datasetName = ApiHelper.FieldFolderType.Topo,
                visitId     = vid,
                manifest    = new[] { new TransferManifestFile {
                                          hash = hashcode, name = fileinfo.Name
                                      }, }
            };

            var response = helper.CreateTransfer(transferDetail);
            var transfer = response.Payload;
            var resp     = helper.UploadTransferFile(transfer.id, fileinfo.FullName, CHUNK_SIZE);
        }
        //[Authorized]
        public ActionResult DetailDelete()
        {
            int qid = Request.Form["TransferId"].ParseInt();

            try
            {
                int            Seq = Request.Form["Seq"].ParseInt();
                TransferDetail ob  = uow.Modules.Transfer.GetDetail(qid, Seq);
                if (ob == null)
                {
                    return(RedirectToAction("Detail", MVCController, new { id = qid, tab = "Product", msg = "ไม่พบข้อมูลที่ต้องการ", msgType = AlertMsgType.Warning }));
                }

                uow.Modules.Transfer.DeleteDetail(ob);
                uow.SaveChanges();
                return(RedirectToAction("Detail", MVCController, new { id = qid, tab = "Product", msg = "ลบข้อมูลเรียบร้อยแล้ว", msgType = AlertMsgType.Success }));
            }
            catch (Exception ex)
            { return(RedirectToAction("Detail", MVCController, new { id = qid, tab = "Product", msg = ex.GetMessage(), msgType = AlertMsgType.Danger })); }
        }
        public Tuple<Transfer, Entity> Transfer(int entryUserID, EntityCollection entityCollection, decimal[] baseTransfer)
        {
            User _user = (new UserAccessClient(EndpointName.UserAccess)).QueryuserID(entryUserID)[0];

            Entity _exchangeDiffEntity = EntityService.Instance.LoadEntity(int.Parse(PropertiesService.Instance.GetPropertyValue(SpecialProperty.ExchangeDiff)[0].PropertyValue))[0];

            WeeklySummaryCollection _weeklySummaryCollection = new WeeklySummaryCollection();

            foreach (Entity _entity in entityCollection)
            {
                _weeklySummaryCollection.AddRange(GetWeeklySummary(_entity.EntityID));
            }

            Record _record = RecordHelper.GenerateTempRecord();

            _record.Type = RecordType.Transfer;

            int _index = 0;

            //Transfer
            Transfer _transfer = new Transfer()
            {
                RecordID = _record.RecordID,
                ToEntity = entityCollection[_index],
                Currency = new Currency() { CurrencyID = _weeklySummaryCollection[_index].BaseCurrency },
                ExchangeRate = _weeklySummaryCollection[_index].ExchangeRate,
                BaseBefore = _weeklySummaryCollection[_index].BaseBalance,
                SGDBefore = _weeklySummaryCollection[_index].SGDBalance,
            };

            foreach (Entity _entity in entityCollection)
            {
                if (_index == 0)
                {
                    _index++;

                    continue;
                }

                TransferDetail _transferDetail = new TransferDetail()
                {
                    RecordID = _record.RecordID,
                    Entity = _entity,
                    BaseCurrency = _weeklySummaryCollection[_index].BaseCurrency,
                    ExchangeRate = _weeklySummaryCollection[_index].ExchangeRate,
                    BaseBefore = _weeklySummaryCollection[_index].BaseBalance,
                    SGDBefore = _weeklySummaryCollection[_index].SGDBalance,
                };

                _transferDetail.BaseTransfer = baseTransfer[_index];
                _transferDetail.SGDTransfer = (_transferDetail.BaseTransfer / _transfer.ExchangeRate).ExtRound();
                _transferDetail.ProfitAndLoss = (_transferDetail.BaseTransfer / _transferDetail.ExchangeRate).ExtRound() - _transferDetail.SGDTransfer;

                _transferDetail.BaseResult = 0;
                _transferDetail.SGDResult = 0;

                _transfer.TransferDetailCollection.Add(_transferDetail);

                _index++;
            }

            _transfer.BaseResult = _transfer.TransferDetailCollection.Sum(x=>x.BaseTransfer)+_transfer.BaseBefore;
            _transfer.SGDResult = (_transfer.BaseResult / _transfer.ExchangeRate).ExtRound();

            //Record
            _index = 0;

            Journal _journal = new Journal()
            {
                RecordID = _record.RecordID,
                EntityID = entityCollection[_index].EntityID,
                BaseCurrency = _transfer.Currency.CurrencyID,
                ExchangeRate = _transfer.ExchangeRate,
                BaseAmount = _transfer.TransferDetailCollection.Sum(TransferDetail => TransferDetail.BaseTransfer),
                SGDAmount = _transfer.TransferDetailCollection.Sum(TransferDetail => TransferDetail.SGDTransfer),
                EntryUser = _user,
            };

            _record.JournalCollection.Add(_journal);

            foreach (Entity _entity in entityCollection)
            {
                if (_index == 0)
                {
                    _index++;

                    continue;
                }

                _journal = new Journal()
                {
                    RecordID = _record.RecordID,
                    EntityID = _entity.EntityID,
                    BaseCurrency = _transfer.TransferDetailCollection[_index - 1].BaseCurrency,
                    ExchangeRate = _transfer.TransferDetailCollection[_index - 1].ExchangeRate,
                    BaseAmount = _transfer.TransferDetailCollection[_index - 1].BaseTransfer * -1,
                    SGDAmount = (_transfer.TransferDetailCollection[_index - 1].SGDTransfer + _transfer.TransferDetailCollection[_index - 1].ProfitAndLoss) * -1,
                    EntryUser = _user,
                };

                _record.JournalCollection.Add(_journal);

                _index++;
            }

            _journal = new Journal()
            {
                RecordID = _record.RecordID,
                EntityID = _exchangeDiffEntity.EntityID,
                SGDAmount = _transfer.TransferDetailCollection.Sum(TransferDetail => TransferDetail.ProfitAndLoss)
            };

            _record.JournalCollection.Add(_journal);

            _transfer.RecordNotInDB = _record;

            return new Tuple<Transfer, Entity>(_transfer, _exchangeDiffEntity);
        }
        public bool DeleteTransferDetail(TransferDetail trensferdetail)
        {
            _log.LogError("Transfer Detail delete fail");

            return(_repository.Delete <TransferDetail>(trensferdetail));
        }
        public bool UpdateTransferDetail(TransferDetail trensferdetail)
        {
            _log.LogError("Transfer Detail update fail");

            return(_repository.Update <TransferDetail>(trensferdetail));
        }
        public bool RecoredTransferDetail(TransferDetail trensferdetail)
        {
            _log.LogError("Transfer Detail add fail");

            return(_repository.Create <TransferDetail>(trensferdetail));
        }
Example #31
0
        /// <summary>
        /// 读取所有的调休excel信息
        /// </summary>
        public TransferResult ReadTransferFile()
        {
            var num = this._workBook.NumberOfSheets;
            List <UserTransferList> result = new List <UserTransferList>();

            while (num > 0)
            {
                var sheet = this._workBook.GetSheetAt(num - 1);
                if (sheet == null)
                {
                    return(new TransferResult()
                    {
                        hasError = true,
                        ErrorMsg = $"错误定位:工作表=>{sheet.SheetName},<br />" +
                                   $"错误信息:当前工作表无数据"
                    });
                }
                IRow title = sheet.GetRow(0);
                if (!title.GetCell(0, MissingCellPolicy.CREATE_NULL_AS_BLANK).ToString().Trim().Equals("Analyst Involved"))
                {
                    return(new TransferResult()
                    {
                        hasError = true,
                        ErrorMsg = $"错误定位:工作表=>{sheet.SheetName},<br />" +
                                   $"错误信息:当前工作表数据格式不正确,请确保'A1'单元格为数据起始点,其值为'Analyst Involved'"
                    });
                }
                //读取所有调休信息
                int cols = title.LastCellNum;
                UserTransferList list = new UserTransferList();
                var allUsers          = new UserService().GetAllUsers();
                try
                {
                    for (int row = 1; row < sheet.LastRowNum + 1; row++)
                    {
                        IRow sRow = sheet.GetRow(row);
                        if (sRow == null || sRow.Cells.Count == 0)
                        {
                            continue;
                        }
                        string name    = sRow.GetCell(0) == null ? null : sRow.GetCell(0).ToString();
                        bool   nameExt = name != null && name != ""; //名字单元格不为空
                                                                     //确保第一个名字单元格存在
                        if (nameExt)
                        {
                            var user = allUsers.Where(r => r.EnglishName.ToLower() == name.ToLower().Trim());
                            if (user.Count() > 0)
                            {
                                var userModel = user.FirstOrDefault();
                                try
                                {
                                    //读取所有基本信息详情
                                    var staffRecord = result.Where(r => r.StaffName.ToLower() == name.ToLower());
                                    //读取公式列(剩余调休时间)
                                    var    specialCol = sRow.GetCell(6, MissingCellPolicy.CREATE_NULL_AS_BLANK);
                                    double val        = 0.0;
                                    if (specialCol.CellType == CellType.Formula)
                                    {
                                        val = specialCol.NumericCellValue;
                                    }
                                    else
                                    {
                                        val = double.Parse(specialCol.ToString().Trim());
                                    }
                                    string date = sRow.GetCell(1, MissingCellPolicy.CREATE_NULL_AS_BLANK).ToString().Trim();
                                    if (DateTime.TryParse(date, out DateTime transDate))
                                    {
                                        date = transDate.ToString("yyyy-MM-dd");
                                    }
                                    if (result.Count > 0 && staffRecord.Count() > 0)
                                    {
                                        staffRecord.First().UserTransferDetail.Add(
                                            new TransferDetail()
                                        {
                                            ExtraWorkDate         = date,
                                            ExtraWorkPeriod       = sRow.GetCell(2, MissingCellPolicy.CREATE_NULL_AS_BLANK).ToString().Trim(),
                                            ExtraWorkTime         = double.Parse(sRow.GetCell(3, MissingCellPolicy.CREATE_NULL_AS_BLANK).ToString().Trim()),
                                            TransferPeriod        = sRow.GetCell(4, MissingCellPolicy.CREATE_NULL_AS_BLANK).ToString().Trim(),
                                            TransferRemainingTime = val,
                                            MaturityDate          = DateTime.Parse(sRow.GetCell(8, MissingCellPolicy.CREATE_NULL_AS_BLANK).ToString().Trim()).ToString("yyyy-MM-dd")
                                        });
                                    }
                                    else
                                    {
                                        var detail = new TransferDetail()
                                        {
                                            ExtraWorkDate         = date,
                                            ExtraWorkPeriod       = sRow.GetCell(2, MissingCellPolicy.CREATE_NULL_AS_BLANK).ToString().Trim(),
                                            ExtraWorkTime         = double.Parse(sRow.GetCell(3, MissingCellPolicy.CREATE_NULL_AS_BLANK).ToString().Trim()),
                                            TransferPeriod        = sRow.GetCell(4, MissingCellPolicy.CREATE_NULL_AS_BLANK).ToString().Trim(),
                                            TransferRemainingTime = val,
                                            MaturityDate          = DateTime.Parse(sRow.GetCell(8, MissingCellPolicy.CREATE_NULL_AS_BLANK).ToString().Trim()).ToString("yyyy-MM-dd")
                                        };
                                        var userlist = new UserTransferList()
                                        {
                                            StaffName  = name,
                                            StaffEmail = userModel.EmailAddress,
                                        };
                                        userlist.UserTransferDetail.Add(detail);
                                        result.Add(userlist);
                                    }
                                }
                                catch (Exception ex)
                                {
                                    return(new TransferResult()
                                    {
                                        hasError = true,
                                        ErrorMsg = $"错误定位:工作表=>{sheet.SheetName}, 姓名=>{name}, <br />" +
                                                   $"错误信息:当前文件字段类型有误,无法转换字段: {ex.Message}" +
                                                   $"错误追踪:{ex.StackTrace}"
                                    });
                                }
                            }
                            else
                            {
                                return(new TransferResult()
                                {
                                    hasError = true,
                                    ErrorMsg = $"错误定位:工作表=>{sheet.SheetName}, 姓名=>{name}, <br />" +
                                               "错误信息:当前文件姓名有误,无法匹配数据库员工字段"
                                });
                            }
                        }
                        //数据读取结束,返回result
                    }
                }
                catch (Exception ex)
                {
                    return(new TransferResult()
                    {
                        hasError = true,
                        ErrorMsg = $"错误定位:工作表=>{sheet.SheetName}, <br />" +
                                   $"错误追踪:{ex.StackTrace}"
                    });
                }
                num--;
            }
            return(new TransferResult()
            {
                hasError = false,
                ErrorMsg = "",
                result = result
            });
        }
        public Transfer Subtotal(int entryUserID, Entity entity)
        {
            User _user = (new UserAccessClient(EndpointName.UserAccess)).QueryuserID(entryUserID)[0];

            Dictionary<Entity, WeeklySummary> _pair = new Dictionary<Entity, WeeklySummary>();

            HasWeeklySummary(entity, _pair);

            Record _record = RecordHelper.GenerateTempRecord();

            _record.Type = RecordType.WinAndLoss;

            WeeklySummary _weeklySummary = _pair[entity];

            //Transfer
            Transfer _transfer = new Transfer()
            {
                RecordID = _record.RecordID,
                ToEntity = entity,
            };

            if (_weeklySummary == null)
            {
                using (WeeklySummaryAccessClient _weeklySummaryAccessClient = new WeeklySummaryAccessClient(EndpointName.WeeklySummaryAccess))
                {
                    _weeklySummaryAccessClient.Insert1(_weeklySummary = new WeeklySummary(PeriodService.Instance.GetCurrentPeriod()[0], entity));
                }
            }

            _transfer.ExchangeRate = _weeklySummary.ExchangeRate;
            _transfer.BaseBefore = _weeklySummary.BaseBalance;
            _transfer.SGDBefore = _weeklySummary.SGDBalance;
            _transfer.Currency.CurrencyID = _weeklySummary.BaseCurrency;
            foreach (Entity _entity in _pair.Keys)
            {
                if (_entity == entity)
                {
                    continue;
                }
                else if ((_weeklySummary = _pair[_entity]) == null)
                {
                    using (WeeklySummaryAccessClient _weeklySummaryAccessClient = new WeeklySummaryAccessClient(EndpointName.WeeklySummaryAccess))
                    {
                        _weeklySummaryAccessClient.Insert1(_weeklySummary = new WeeklySummary(PeriodService.Instance.GetCurrentPeriod()[0], _entity));
                    }
                }

                TransferDetail _transferDetail = new TransferDetail()
                {
                    RecordID = _record.RecordID,
                    Entity = _entity,
                    BaseCurrency = _weeklySummary.BaseCurrency,
                    ExchangeRate = _weeklySummary.ExchangeRate,
                    BaseBefore = _weeklySummary.BaseBalance,
                    SGDBefore = _weeklySummary.SGDBalance,
                };

                _transferDetail.BaseTransfer = _transferDetail.BaseBefore;
                _transferDetail.SGDTransfer = _transferDetail.SGDBefore;
                _transferDetail.ProfitAndLoss = 0;

                _transferDetail.BaseResult = 0;
                _transferDetail.SGDResult = 0;

                _transfer.TransferDetailCollection.Add(_transferDetail);
            }

            _transfer.SGDResult = _transfer.TransferDetailCollection.Sum(TransferDetail => TransferDetail.SGDBefore).ExtRound();
            _transfer.BaseResult = (_transfer.SGDResult * _transfer.ExchangeRate).ExtRound();

            //Record
            Journal _journal = new Journal()
            {
                RecordID = _record.RecordID,
                EntityID = entity.EntityID,
                BaseCurrency = entity.Currency.CurrencyID,
                ExchangeRate = _transfer.ExchangeRate,
                BaseAmount = _transfer.TransferDetailCollection.Sum(TransferDetail => TransferDetail.BaseTransfer),
                SGDAmount = _transfer.TransferDetailCollection.Sum(TransferDetail => TransferDetail.SGDTransfer),
                EntryUser = _user,
            };

            _record.JournalCollection.Add(_journal);

            foreach (Entity _entity in _pair.Keys)
            {
                if (_entity == entity)
                {
                    continue;
                }
                else if ((_weeklySummary = _pair[_entity]) == null)
                {
                    continue;
                }

                _journal = new Journal()
                {
                    RecordID = _record.RecordID,
                    EntityID = _entity.EntityID,
                    BaseCurrency = _weeklySummary.BaseCurrency,
                    ExchangeRate = _weeklySummary.ExchangeRate,
                    BaseAmount = _weeklySummary.BaseBalance * -1,
                    SGDAmount = _weeklySummary.SGDBalance * -1,
                    EntryUser = _user,
                };

                _record.JournalCollection.Add(_journal);
            }

            _transfer.RecordNotInDB = _record;

            return _transfer;
        }
 private void attach_TransferDetails(TransferDetail entity)
 {
     this.SendPropertyChanging("TransferDetails");
     entity.TransferHeader = this;
 }
 private void detach_TransferDetails(TransferDetail entity)
 {
     this.SendPropertyChanging("TransferDetails");
     entity.PartInfo = null;
 }