예제 #1
0
        public static bool SaveToInv(int TrxNo)
        {
            bool isDone = false;

            // configure automapper
            var config = new MapperConfiguration(cfg => cfg.CreateMap <whgi2, whiv1>()
                                                 .ForMember(dest => dest.BatchLineItemNo, opt => opt.MapFrom(src => src.LineItemNo))
                                                 .ForMember(dest => dest.TrxNo, opt => opt.Ignore())
                                                 );
            var mapper = config.CreateMapper();

            // get gin, gindetails
            whgi1 gin = GetGin(TrxNo);
            IEnumerable <whgi2> ginDetails = GetGinDetails(TrxNo);

            using (var connection = new ConnectionProvider(ApiService.Site).CreateDbConnection())
            {
                try
                {
                    connection.Open();

                    foreach (var ginDetail in ginDetails)
                    {
                        // set minus values
                        ginDetail.Length    = -1 * ginDetail.Length;
                        ginDetail.Width     = -1 * ginDetail.Width;
                        ginDetail.Height    = -1 * ginDetail.Height;
                        ginDetail.Weight    = -1 * ginDetail.Weight;
                        ginDetail.Volume    = -1 * ginDetail.Volume;
                        ginDetail.SpaceArea = -1 * ginDetail.SpaceArea;
                        ginDetail.Qty       = -1 * ginDetail.Qty;

                        // map gin to inv
                        whiv1 myInv = mapper.Map <whiv1>(ginDetail);
                        myInv.BatchNo        = gin.GoodsIssueNoteNo;
                        myInv.WarehouseCode  = gin.WarehouseCode;
                        myInv.WorkStation    = ApiService.HostName;
                        myInv.CreateBy       = ApiService.UserId;
                        myInv.CreateDateTime = ApiService.ClientDate;
                        myInv.UpdateBy       = ApiService.UserId;
                        myInv.UpdateDateTime = ApiService.ClientDate;

                        // save to inventory
                        isDone = InventoryHelper.SaveInv(myInv);
                    }
                }
                catch (Exception) { throw; }
                finally { connection.Close(); }
            }

            return(isDone);
        }
예제 #2
0
        public static whiv1 GetInv(int TrxNo)
        {
            var   connection = ApiService.dbConnection;
            whiv1 myInvItem  = null;

            try
            {
                connection.Open();
                myInvItem = connection.QuerySingleOrDefault <whiv1>(qryInventory.selectInv, new { TrxNo });
            }
            catch (Exception) { throw; }
            finally { connection.Close(); }

            return(myInvItem);
        }
예제 #3
0
        public static bool SaveInv(whiv1 Inv)
        {
            int afRecCnt = 0;

            using (var connection = new ConnectionProvider(ApiService.Site).CreateDbConnection())
            {
                try
                {
                    connection.Open();

                    string storeProcName;
                    if (Inv.TrxNo <= 0)
                    {
                        Inv.StatusCode     = "USE";
                        Inv.WorkStation    = ApiService.HostName;
                        Inv.CreateBy       = ApiService.UserId;
                        Inv.CreateDateTime = ApiService.ClientDate;
                        Inv.UpdateBy       = ApiService.UserId;
                        Inv.UpdateDateTime = ApiService.ClientDate;

                        storeProcName = qryInventory.insertInv;
                    }
                    else
                    {
                        Inv.WorkStation    = ApiService.HostName;
                        Inv.UpdateBy       = ApiService.UserId;
                        Inv.UpdateDateTime = ApiService.ClientDate;

                        storeProcName = qryInventory.updateInv;
                    }

                    var param = connection.GetStoreProcParams(storeProcName, Inv);
                    afRecCnt = connection.ExecuteScalar <int>(storeProcName, param, null, null, CommandType.StoredProcedure);
                }
                catch (Exception) { throw; }
                finally { connection.Close(); }
            }

            return(afRecCnt > 0 ? true : false);
        }