Exemple #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);
        }
Exemple #2
0
        public IHttpActionResult SaveGin(whgi1 gin)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            int trxNo = GinHelper.SaveGin(gin);

            if (trxNo <= 0)
            {
                return(InternalServerError());
            }
            return(Ok(trxNo));
        }
Exemple #3
0
        public static whgi1 GetGin(int TrxNo)
        {
            whgi1 myGin = null;

            using (var connection = new ConnectionProvider(ApiService.Site).CreateDbConnection())
            {
                try
                {
                    connection.Open();
                    myGin = connection.QuerySingleOrDefault <whgi1>(qryGoodsIssueNote.selectGin, new { TrxNo });
                }
                catch (Exception) { throw; }
                finally { connection.Close(); }
            }

            return(myGin);
        }
Exemple #4
0
        public static int SaveGin(whgi1 gin)
        {
            int trxNo = 0;

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

                    string storeProcName;
                    if (gin.TrxNo <= 0)
                    {
                        // set audit values
                        gin.WorkStation    = ApiService.HostName;
                        gin.CreateBy       = ApiService.UserId;
                        gin.CreateDateTime = ApiService.ClientDate;
                        gin.UpdateBy       = ApiService.UserId;
                        gin.UpdateDateTime = ApiService.ClientDate;

                        // set insert store procedure
                        storeProcName = qryGoodsIssueNote.insertGin;
                    }
                    else
                    {
                        // set audit values
                        gin.WorkStation    = ApiService.HostName;
                        gin.UpdateBy       = ApiService.UserId;
                        gin.UpdateDateTime = ApiService.ClientDate;

                        // set update store procedure
                        storeProcName = qryGoodsIssueNote.updateGin;
                    }

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

            return(trxNo);
        }
Exemple #5
0
        public static bool DeleteFromInv(int TrxNo)
        {
            bool isDone = false;

            // get gin, gindetails
            whgi1 gin = GetGin(TrxNo);

            using (var connection = new ConnectionProvider(ApiService.Site).CreateDbConnection())
            {
                try
                {
                    connection.Open();
                    isDone = InventoryHelper.DeleteInvBatch(gin.GoodsIssueNoteNo);
                }
                catch (Exception) { throw; }
                finally { connection.Close(); }
            }

            return(isDone);
        }