示例#1
0
        public clsPMCTransfer Confirm(clsPMCTransfer objPMCTransfer)
        {
            clsPMCTransfer objPMCTransferReturn = new clsPMCTransfer();

            DAL dAL = new DAL();

            objPMCTransferReturn = dAL.Confirm(objPMCTransfer);
            return(objPMCTransferReturn);
        }
示例#2
0
        public clsPMCTransfer ValidateLot(clsPMCTransfer objPMCTransfer)
        {
            clsPMCTransfer objPMCTransferReturn = new clsPMCTransfer();

            DAL dAL = new DAL();

            objPMCTransferReturn = dAL.ValidateLot(objPMCTransfer);
            return(objPMCTransferReturn);
        }
示例#3
0
        public clsPMCTransfer ValidateLot(clsPMCTransfer objPMCTransfer)
        {
            bool   ValidLot    = false;
            string ValidateMsg = "Success";

            clsPMCTransfer objValidatePart = new clsPMCTransfer();

            // copy class from incoming class to return class
            objValidatePart = objPMCTransfer;
            //initialize BalQty to zero
            objValidatePart.BalQty = 0;
            //check valid part
            StringBuilder sbQry = new StringBuilder();

            sbQry.Append($"Select OnHandQty  From erp.PartBin ");
            sbQry.Append($"where Company='{objPMCTransfer.Company}' and PartNum='{objPMCTransfer.ActualPart}' ");
            sbQry.Append($"and WarehouseCode='{objPMCTransfer.FromWH}' ");
            sbQry.Append($"and BinNum='{objPMCTransfer.FromBin}' ");
            sbQry.Append($"and LotNum='{objPMCTransfer.LotNum}'  ");
            using (SqlConnection connection = new SqlConnection(EpicorConStr))
            {
                connection.Open();
                SqlCommand command = new SqlCommand(sbQry.ToString(), connection);
                using (SqlDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        objValidatePart.BalQty = Convert.ToDecimal(reader["OnHandQty"].ToString());
                        ValidLot = true;
                    }
                }

                if (!ValidLot)
                {
                    ValidateMsg = "Invalid Lot";
                }

                objValidatePart.TranStatus = ValidateMsg;
            }

            return(objValidatePart);
        }
示例#4
0
        public clsPMCTransfer ValidatePart(clsPMCTransfer objPMCTransfer)
        {
            bool ValidPMCWH  = ValidatePMCWH(objPMCTransfer.FromWH, objPMCTransfer.Company);
            bool ValidPartWH = ValidatePart(objPMCTransfer.FromWH, objPMCTransfer.Company, objPMCTransfer.Part);

            //ValidatePart
            bool           ValidActPart    = false;
            int            Count           = 0;
            bool           ValidPart       = false;
            string         ValidateMsg     = string.Empty;
            string         ActualPart      = string.Empty;
            clsPMCTransfer objValidatePart = new clsPMCTransfer();

            try
            {
                //check valid part
                StringBuilder sbQry = new StringBuilder();
                sbQry.Append($"Select count(*) as NumPart From Part where Company='{objPMCTransfer.Company}' and PartNum='{objPMCTransfer.Part}' ");
                if (ValidPMCWH)
                {
                    if (!ValidPartWH)
                    {
                        throw new Exception($"PartNum {objPMCTransfer.Part} not belong to Warehouse {objPMCTransfer.FromWH}!");
                    }
                    using (SqlConnection connection = new SqlConnection(EpicorConStr))
                    {
                        connection.Open();
                        SqlCommand command = new SqlCommand(sbQry.ToString(), connection);
                        using (SqlDataReader reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                Count = Convert.ToInt32(reader["NumPart"].ToString());
                            }
                            if (Count > 0)
                            {
                                ValidActPart = true;
                                ActualPart   = objPMCTransfer.Part;
                                ValidPart    = true;
                            }
                        }


                        // invalid part search Supplier Part XRef
                        if (!ValidActPart)
                        {
                            sbQry = new StringBuilder();
                            sbQry.Append($"select PartNum from erp.PartXRefVend where ");
                            sbQry.Append($"company ='{objPMCTransfer.Company}' and VendPartNum='{objPMCTransfer.Part}' ");
                            command = new SqlCommand(sbQry.ToString(), connection);
                            using (SqlDataReader reader = command.ExecuteReader())
                            {
                                while (reader.Read())
                                {
                                    ActualPart = reader["PartNum"].ToString();
                                    ValidPart  = true;
                                    objValidatePart.SupplierPart = true;
                                }
                            }
                        }

                        if (!ValidPart)
                        {
                            ValidateMsg = "Invalid Part";
                        }

                        // Check Part Exist in WH
                        if (ValidPart)
                        {
                            sbQry = new StringBuilder();
                            sbQry.Append($"select Count(*) as NumPart from erp.PartWhse where ");
                            sbQry.Append($"company ='{objPMCTransfer.Company}' ");
                            sbQry.Append($"and WarehouseCode='{objPMCTransfer.FromWH}' ");
                            sbQry.Append($"and PartNum='{objPMCTransfer.Part}' ");
                            command = new SqlCommand(sbQry.ToString(), connection);
                            Count   = 0;
                            using (SqlDataReader reader = command.ExecuteReader())
                            {
                                while (reader.Read())
                                {
                                    Count = Convert.ToInt32(reader["NumPart"].ToString());
                                }
                                if (Count == 0)
                                {
                                    ValidateMsg = "Part Not Found In WH";
                                    ValidPart   = false;
                                }
                            }
                            // Get Part Info
                            sbQry = new StringBuilder();
                            sbQry.Append($"select PartDescription,IUM from erp.Part where company='{objPMCTransfer.Company}' ");
                            sbQry.Append($"and PartNum='{ActualPart}' ");
                            Count   = 0;
                            command = new SqlCommand(sbQry.ToString(), connection);
                            using (SqlDataReader reader = command.ExecuteReader())
                            {
                                while (reader.Read())
                                {
                                    objValidatePart.Desc       = reader["PartDescription"].ToString();
                                    objValidatePart.UOM        = reader["IUM"].ToString();
                                    objValidatePart.ActualPart = ActualPart;
                                    ValidateMsg = "Success";
                                }
                            }
                        }
                        objValidatePart.Part   = objPMCTransfer.Part;
                        objValidatePart.FromWH = objPMCTransfer.FromWH;
                        //feedback from Steven 17/11 & 21/11
                        objValidatePart.FromBin = objPMCTransfer.FromWH;

                        //objValidatePart.ToWH = objPMCTransfer.FromWH;
                        //Transfer from machine location to machine inuse bin for use by
                        // auto backflush machine consumption program
                        //objValidatePart.ToBin = "InUse";
                        objValidatePart.TranStatus = ValidateMsg;
                        objValidatePart.Company    = objPMCTransfer.Company;
                    }
                }
                else
                {
                    //ValidateMsg = "WH selected not PMC Area!";
                    throw new Exception("WH selected not PMC Area!");
                }
                objValidatePart.TranStatus = ValidateMsg;
            }
            catch (Exception ex)
            {
                objValidatePart.TranStatus = ex.Message.ToString();
            }

            return(objValidatePart);
        }
示例#5
0
        public clsPMCTransfer Confirm(clsPMCTransfer objPMCTransfer)
        {
            string         StatusMsg       = string.Empty;
            clsPMCTransfer objValidatePart = new clsPMCTransfer();

            // copy class from incoming class to return class
            objValidatePart = objPMCTransfer;
            string errMsg = ValidateToWHAndToBin(objPMCTransfer.ToWH, objPMCTransfer.ToBin, objPMCTransfer.Part, objPMCTransfer.Company);

            if (errMsg != "0")
            {
                objValidatePart.TranStatus = errMsg;
                return(objValidatePart);
            }
            // Inventory Transfer
            //check WH is ProdLine

            bool ValidProdLineWH = ValidateProdAreaWH(objPMCTransfer.ToWH, objPMCTransfer.Company);

            if (ValidProdLineWH)
            {
                try
                {
                    InvTransfer invTransfer = new InvTransfer();
                    invTransfer.company      = objPMCTransfer.Company;
                    invTransfer.frmWarehouse = objPMCTransfer.FromWH;
                    invTransfer.frmBinNum    = objPMCTransfer.FromBin;
                    invTransfer.frmLotNum    = objPMCTransfer.LotNum;
                    invTransfer.partNum      = objPMCTransfer.ActualPart;
                    invTransfer.toBinNum     = objPMCTransfer.ToBin;
                    invTransfer.toWarehouse  = objPMCTransfer.ToWH;
                    invTransfer.toLotNum     = objPMCTransfer.LotNum;
                    invTransfer.uom          = objPMCTransfer.UOM;
                    invTransfer.qty          = objPMCTransfer.Qty;
                    invTransfer.id           = "PMCTransfer"; // Req by Tsen in the email subject FW: Part Transaction History Tracker
                    InventoryTransferServices inventoryTransferServices = new InventoryTransferServices();
                    inventoryTransferServices.doInvTransfer(invTransfer);
                }
                catch (Exception e)
                {
                    StatusMsg = string.Concat(StatusMsg, " ", e.ToString());
                }


                // Insert Into UD19
                try
                {
                    //UD19Model uD19Model = new UD19Model();
                    //uD19Model.RunningNo = FindUD19Key(objPMCTransfer.Company);
                    //uD19Model.Company = objPMCTransfer.Company;
                    //uD19Model.EnteredBy = "Handheld";
                    //uD19Model.Lot = objPMCTransfer.LotNum;
                    //uD19Model.PartNum = objPMCTransfer.ActualPart;
                    //uD19Model.Qty = objPMCTransfer.Qty;
                    //uD19Model.ToBin = objPMCTransfer.ToBin;
                    //uD19Model.ToWH = objPMCTransfer.ToWH;
                    //uD19Model.TranDate = DateTime.Today;
                    //uD19Model.TranTime = DateTime.Today;
                    //uD19Model.UOM = objPMCTransfer.UOM;
                    //UD19Services uD19Services = new UD19Services();
                    //uD19Services.Begin(uD19Model);
                    // Update Part Bin - Fields to update not defined don't execute
                    //StatusMsg= UpdatePartBin(objPMCTransfer.Company, objPMCTransfer.ActualPart,
                    //    objPMCTransfer.FromWH, objPMCTransfer.FromBin,objPMCTransfer.LotNum,
                    //    objPMCTransfer.Qty);
                }

                catch (Exception e)
                {
                    StatusMsg = string.Concat(StatusMsg, " ", e.ToString());
                }
            }
            else
            {
                StatusMsg = "To Warehouse Not A Produciton Line WH";
            }

            if (StatusMsg == string.Empty)
            {
                StatusMsg = "Success";
            }
            objValidatePart.TranStatus = StatusMsg;
            return(objValidatePart);
        }