public void updateShipped(string epicorUserID, string epiorUserPassword, UriBuilder builder, Guid sessionId, int packNum, string DPNo)
        {
            try
            {
                EndpointBindingType bindingType = EndpointBindingType.BasicHttp;

                builder.Path = $"{Conn.environment}/Erp/BO/CustShip.svc";

                svcCustShip.CustShipSvcContractClient _svcCustShip = GetClient <svcCustShip.CustShipSvcContractClient, svcCustShip.CustShipSvcContract>(

                    builder.Uri.ToString(),

                    epicorUserID,

                    epiorUserPassword,

                    bindingType);

                _svcCustShip.Endpoint.EndpointBehaviors.Add(new HookServiceBehavior(sessionId, epicorUserID));

                bool cError = false;

                svcCustShip.UpdExtCustShipTableset dsExtCustShip = new svcCustShip.UpdExtCustShipTableset();

                svcCustShip.CustShipTableset dsCustShip = new svcCustShip.CustShipTableset();

                dsExtCustShip = new svcCustShip.UpdExtCustShipTableset();

                dsCustShip = _svcCustShip.GetByID(packNum);

                dsExtCustShip.ShipHead = dsCustShip.ShipHead;

                dsExtCustShip.ShipHead[0].UserDefinedColumns["FS_DPNum_c"] = DPNo;

                dsExtCustShip.ShipHead[0].ReadyToInvoice = true;

                dsExtCustShip.ShipHead[0].RowMod = "U";

                _svcCustShip.UpdateExt(ref dsExtCustShip, true, true, out cError);
            }

            catch (Exception ex)

            {
                throw new Exception($"Epicor Error : {ex.Message.ToString()}");
            }
        }
        public void performCustShipment(string epicorUserID, string epiorUserPassword, UriBuilder builder,
                                        Guid sessionId, List <CustShipment> custShipment,
                                        string DPNo, int custNum, int existingPackNum)
        {
            var cs = custShipment.First();

            try
            {
                EndpointBindingType bindingType = EndpointBindingType.BasicHttp;

                builder.Path = $"{Conn.environment}/Erp/BO/CustShip.svc";
                svcCustShip.CustShipSvcContractClient _svcCustShip = GetClient <svcCustShip.CustShipSvcContractClient, svcCustShip.CustShipSvcContract>(
                    builder.Uri.ToString(),
                    epicorUserID,
                    epiorUserPassword,
                    bindingType);

                _svcCustShip.Endpoint.EndpointBehaviors.Add(new HookServiceBehavior(sessionId, epicorUserID));

                svcCustShip.CustShipTableset dsCustShip = new svcCustShip.CustShipTableset();

                bool    belongToAnotherPC   = false;
                bool    vSubAvail           = false;
                string  pcOutsideMessage    = "";
                string  opShippingMessage   = "";
                string  partNum             = "";
                string  vMsgType            = "";
                string  origPartNum         = "";
                string  wareHouse           = "";
                string  binNum              = "";
                string  LotNum              = "";
                string  opCompleteMessage   = "";
                string  opLotMessage        = "";
                string  opInventoryMessage  = "";
                string  opLockQtyMessage    = "";
                string  opAllocationMessage = "";
                string  opPartList          = "";
                string  opLot = "";
                string  shipCredMsg = "";
                bool    cError = false;
                bool    compError = false;
                string  msg2 = "";
                string  opPostUpdMsg = "";
                bool    updComplete = false;
                bool    checkCompError = false;
                bool    chgStatErr = false;
                bool    chkShipDtl = false;
                decimal Qty = 0;
                int     packNum = 0, orderNum = 0, orderLine = 0, orderRelNum = 0;
                orderNum = (int)custShipment[0].OrderNum;
                // ## Cust Shipment Header ## //
                if (existingPackNum == 0)
                {
                    _svcCustShip.GetNewShipHead(ref dsCustShip);
                    _svcCustShip.GetHeadOrderInfo(orderNum, ref dsCustShip);
                    _svcCustShip.BuildShipToCustomerList(orderNum);
                    _svcCustShip.GetLegalNumGenOpts(0, ref dsCustShip);
                    _svcCustShip.CheckPCBinOutLocation(ref dsCustShip, out belongToAnotherPC, out pcOutsideMessage);
                    dsCustShip.ShipHead[0].UserDefinedColumns["FS_DPNum_c"] = DPNo;
                    //_svcCustShip.Update(ref dsCustShip);
                    _svcCustShip.UpdateMaster(ref dsCustShip, false, true, false, false, false, false, false, packNum,
                                              custNum, out opCompleteMessage, out opShippingMessage, out opLotMessage, out opInventoryMessage,
                                              out opLockQtyMessage, out opAllocationMessage, out opPartList, out opLot,
                                              out shipCredMsg, out cError, out compError, out msg2, out opPostUpdMsg, out updComplete,
                                              out checkCompError, out chgStatErr, out chkShipDtl);
                    packNum = dsCustShip.ShipHead[0].PackNum;
                }
                else
                {
                    packNum = existingPackNum;
                }

                int ttlrec  = custShipment.Count();
                int currRow = 0;
                // ## Cust Shipment Details ## //
                foreach (CustShipment custShipmentRec in custShipment)
                {
                    orderNum    = (int)custShipmentRec.OrderNum;
                    orderLine   = (int)custShipmentRec.OrderLine;
                    orderRelNum = (int)custShipmentRec.OrderRel;
                    Qty         = (decimal)custShipmentRec.ShipQty;

                    if (custShipmentRec.PalletLine)
                    {
                        LotNum = "";
                    }
                    else
                    {
                        LotNum = custShipmentRec.LotNum;
                    }
                    dsCustShip = new svcCustShip.CustShipTableset();
                    _svcCustShip.GetNewShipDtl(ref dsCustShip, packNum);
                    currRow++;
                    int dtlLastRowIndex = dsCustShip.ShipDtl.Count - 1;
                    if (dsCustShip.ShipHead.Count > 0)
                    {
                        // dsCustShip.ShipHead[0].RowMod = "U";
                    }
                    _svcCustShip.GetOrderInfo(orderNum, ref dsCustShip);
                    _svcCustShip.CheckPrePartInfo(ref partNum, orderNum, orderLine, out vSubAvail, out vMsgType, out origPartNum);
                    _svcCustShip.GetOrderLineInfo(ref dsCustShip, 0, orderLine, "");
                    _svcCustShip.GetOrderRelInfo(ref dsCustShip, 0, orderRelNum, true);
                    _svcCustShip.GetQtyInfo(ref dsCustShip, 0, Qty, 0);
                    // need to identify the warehouse and bin to use
                    //wareHouse = "WO-A"; binNum = "A10111";

                    _svcCustShip.GetWhseInfo(ref dsCustShip, 0, custShipmentRec.WH, "WarehouseCode");
                    _svcCustShip.ValidateBinCode(custShipmentRec.WH, custShipmentRec.Bin);
                    dsCustShip.ShipDtl[dtlLastRowIndex].WarehouseCode = custShipmentRec.WH;
                    dsCustShip.ShipDtl[dtlLastRowIndex].BinNum        = custShipmentRec.Bin;
                    _svcCustShip.GetLegalNumGenOpts(packNum, ref dsCustShip);
                    _svcCustShip.CheckPCBinOutLocation(ref dsCustShip, out belongToAnotherPC, out pcOutsideMessage);
                    dsCustShip.ShipDtl[dtlLastRowIndex].LotNum = LotNum;
                    //dsCustShip.ShipDtl[dtlLastRowIndex].ReadyToInvoice = true;
                    if (ttlrec == currRow)
                    {
                        //dsCustShip.ShipHead[0].ReadyToInvoice = true;
                        //dsCustShip.ShipHead[0].RowMod = "U";
                        //dsCustShip.ShipHead[0].UserDefinedColumns["FS_DPNum_c"] = DPNo;
                        dsCustShip.ShipDtl[dtlLastRowIndex].ShipComment = "D";
                    }
                    _svcCustShip.Update(ref dsCustShip);
                }

                //updateShipped(epicorUserID, epiorUserPassword, builder, sessionId, custNum, packNum, DPNo);
                updateShipped(epicorUserID, epiorUserPassword, builder, sessionId, packNum, DPNo);
            }
            catch (Exception ex)
            {
                throw new Exception($"Epicor Error : {ex.Message.ToString()}");
            }
        }