public voucherDTO IssueTicketToCage(IssueTicketEntity IssueTicketEntity, voucherDTO ovoucherDTO)
        {
            PrintTicketErrorCodes ErrorCode = PrintTicketErrorCodes.Failure;
            CageVoucher voucher = new CageVoucher();

            try
            {
                if ((ErrorCode = issueTicket.CreateTicketForCage(IssueTicketEntity, ref voucher)) == PrintTicketErrorCodes.Success)
                {
                    ovoucherDTO.barcode = IssueTicketEntity.BarCode;
                    ovoucherDTO.amountType = amountTypeEnum.CASHABLE;
                    ovoucherDTO.errorCodeId = voucher.ErrorCode;
                    ovoucherDTO.tktStatus = voucher.tktStatus;
                    ovoucherDTO.tktStatusId = voucher.tktStatusID;
                    ovoucherDTO.expiryDays = voucher.expiryDays;
                    ovoucherDTO.expireDate = voucher.expireDate;
                    ovoucherDTO.effectiveDate = voucher.DatePrinted;
                    //ovoucherDTO.expireDateSpecified = true;
                    //ovoucherDTO.effectiveDateSpecified = true; 

                    //SMSResponseInfo.ExpiryDate = (BDateTime)voucherDToObj.expireDate;
                    //SMSResponseInfo.ValidDays = voucherDToObj.expiryDays;
                    //SMSResponseInfo.TicketStatus = voucherDToObj.tktStatus;
                    //SMSResponseInfo.ErrorCode = voucherDToObj.errorCodeId;
                    //listResponseInfo.Add(SMSResponseInfo);
                    //TenderInfo tempTenderInfo = new TenderInfo();
                    //item.Copy(tempTenderInfo);
                    //(oCommonUtilities.CreateInstance()).PrintCommonReceipt(voucher);
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
            }

            return ovoucherDTO;
        }
        public bool GetTicketInfoForCage(IssueTicketEntity issueTicketEntity, ref CageVoucher voucher)
        {
            bool IsTicketInfoRetrieved = false;
            DataSet GetTicketInfo = new DataSet();

            try
            {
                SqlParameter[] sqlparams = new SqlParameter[5];
                sqlparams[0] = new SqlParameter(DBConstants.CONST_SP_PARAM_STARTDATE, DateTime.Now.AddDays(-5));//.GetUniversalDateTimeFormat()
                sqlparams[1] = new SqlParameter(DBConstants.CONST_SP_PARAM_ENDDATE, DateTime.Now.AddDays(5));//.GetUniversalDateTimeFormat()
                sqlparams[2] = new SqlParameter(DBConstants.CONST_SP_PARAM_TYPE, "A");
                sqlparams[3] = new SqlParameter(DBConstants.CONST_SP_PARAM_BARCODE, issueTicketEntity.BarCode);
                sqlparams[4] = new SqlParameter(DBConstants.CONST_SP_PARAM_ISLIABILITY, 0);

                if (OpenConnection() == true)
                {
                    GetTicketInfo = SqlHelper.ExecuteDataset(CommonDataAccess.TicketingConnectionString, "rsp_BGS_VoucherInformation_CAGE", sqlparams);
                    if (GetTicketInfo.Tables[0].Rows.Count > 0)
                    {
                        voucher.PrintDevice = GetTicketInfo.Tables[0].Rows[0][DBConstants.CONST_SP_RESULT_PRINTDEVICE].ToString();
                        voucher.PayDevice = GetTicketInfo.Tables[0].Rows[0][DBConstants.CONST_SP_RESULT_PAYDEVICE].ToString();
                        voucher.SBarCode = GetTicketInfo.Tables[0].Rows[0][DBConstants.CONST_SP_RESULT_BARCODE].ToString();
                        voucher.Amount = int.Parse((GetTicketInfo.Tables[0].Rows[0][DBConstants.CONST_SP_RESULT_AMOUNT]).ToString());
                        voucher.tktStatus = GetTicketInfo.Tables[0].Rows[0]["strVoucherStatus"].ToString();
                        voucher.tktStatusID = short.Parse(GetTicketInfo.Tables[0].Rows[0]["VoucherStatusID"].ToString());
                        voucher.Datepaid = (GetTicketInfo.Tables[0].Rows[0][DBConstants.CONST_SP_RESULT_DATEPAID]).ToString().ReadDate();
                        voucher.DatePrinted = (GetTicketInfo.Tables[0].Rows[0][DBConstants.CONST_SP_RESULT_DATEPRINTED]).ToString().ReadDate();
                        voucher.DeviceType = GetTicketInfo.Tables[0].Rows[0][DBConstants.CONST_SP_RESULT_DEVICETYPE].ToString();
                        voucher.expireDate = GetTicketInfo.Tables[0].Rows[0]["dtExpire"].ToString().ReadDate();
                        voucher.expiryDays = int.Parse(GetTicketInfo.Tables[0].Rows[0]["expiryDays"].ToString());
                        IsTicketInfoRetrieved = true;
                        voucher.ErrorCode = 0;
                    }
                }

            }
            catch (Exception ex)
            {
                voucher.ErrorCode = -1001;
                ExceptionManager.Publish(ex);
            }
            return IsTicketInfoRetrieved;
        }
        public PrintTicketErrorCodes CreateTicketForCage(IssueTicketEntity CDOEntity, ref CageVoucher voucher)
        {
            PrintTicketErrorCodes ErrorCode = PrintTicketErrorCodes.Failure;
            try
            {
                if ((ErrorCode = GenerateTicketForCage(CDOEntity)) == PrintTicketErrorCodes.Success)
                {
                    if ((ErrorCode = issueTicketDB.SaveTicketIssueDetailsCage(CDOEntity)) == PrintTicketErrorCodes.Success)
                        TicketIssueCreateForCage(CDOEntity, ref voucher);

                    return PrintTicketErrorCodes.Success;
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
            }
            return ErrorCode;
        }
        public bool GetMachineDetailsFromAssetForCage(ref CageVoucher voucher)
        {
            bool IsMachineDetailsRetrieved = false;
            DataSet dsGetMachineDetailsFromAsset = new DataSet();
            try
            {
                SqlParameter[] sqlparams = new SqlParameter[1];
                sqlparams[0] = new SqlParameter(DBConstants.CONST_SP_PARAM_MACHINENAME, voucher.PrintDevice);

                dsGetMachineDetailsFromAsset = SqlHelper.ExecuteDataset(CommonDataAccess.ExchangeConnectionString, DBConstants.CONST_SP_GETMACHINEDETAILSFROMASSET, sqlparams);

                if (dsGetMachineDetailsFromAsset.Tables[0].Rows.Count > 0)
                {
                    voucher.BarPositionName = dsGetMachineDetailsFromAsset.Tables[0].Rows[0][DBConstants.CONST_SP_RESULT_BARPOSITIONNAME].ToString();
                    voucher.InstallationNo = int.Parse((dsGetMachineDetailsFromAsset.Tables[0].Rows[0][DBConstants.CONST_SP_RESULT_INSTALLATIONNUMBER]).ToString());
                    voucher.StockNo = dsGetMachineDetailsFromAsset.Tables[0].Rows[0][DBConstants.CONST_SP_RESULT_STOCKNUMBER].ToString();
                    voucher.PrintDeviceName = dsGetMachineDetailsFromAsset.Tables[0].Rows[0][DBConstants.CONST_SP_RESULT_MACHINENAME].ToString();
                    voucher.PrintDeviceSerial = voucher.PrintDevice;
                    IsMachineDetailsRetrieved = true;
                }
                else
                {
                    voucher.PrintDeviceName = string.Empty;
                    IsMachineDetailsRetrieved = false;
                }
            }
            catch (Exception ex)
            {
                IsMachineDetailsRetrieved = false;
                ExceptionManager.Publish(ex);
            }
            return IsMachineDetailsRetrieved;

        }
        public bool GetTITOTicketInformationForCage(IssueTicketEntity issueTicketEntity, ref CageVoucher VoucherEntity)
        {
            bool HasGotTITOTicketInformation = false;

            try
            {
                if (issueTicketEntity.BarCode.Length == 18)
                {

                    if (issueTicketDB.GetTicketInfoForCage(issueTicketEntity, ref VoucherEntity) == true)
                        if (issueTicketDB.GetMachineDetailsFromAssetForCage(ref VoucherEntity) == true)
                            HasGotTITOTicketInformation = true;

                    //HasGotTITOTicketInformation = true;
                }
                else
                    HasGotTITOTicketInformation = false;
            }
            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
            }
            return HasGotTITOTicketInformation;
        }
 public void TicketIssueCreateForCage(IssueTicketEntity issueTicketEntity, ref CageVoucher voucherEntity)
 {
     try
     {
         if (GetTITOTicketInformationForCage(issueTicketEntity, ref voucherEntity) == true)
         {
             TicketNumber = issueTicketEntity.FullTicketNumber;
             Amount = int.Parse(issueTicketEntity.dblValue.ToString());
             voucherEntity.FullTicketNumber = issueTicketEntity.BarCode;
             voucherEntity.Value = issueTicketEntity.dblValue;
         }
     }
     catch (Exception ex)
     {
         ExceptionManager.Publish(ex);
     }
 }