public IDataReader ExecuteReader(CommandType commandType, string commandText)
 {
     this.idbCommand       = SalesPOSDBManagerFactory.GetCommand(this.ProviderType);
     idbCommand.Connection = this.Connection;
     PrepareCommand(idbCommand, this.Connection, this.Transaction, commandType, commandText, this.Parameters);
     this.DataReader = idbCommand.ExecuteReader();
     idbCommand.Parameters.Clear();
     return(this.DataReader);
 }
        public IDbDataParameter getparam(string paramName, object objValue)
        {
            IDbDataParameter param = SalesPOSDBManagerFactory.GetParameter(this.providerType);

            param.Value         = objValue;
            param.ParameterName = paramName;

            return(param);
        }
 public void Open()
 {
     idbConnection = SalesPOSDBManagerFactory.GetConnection(this.providerType);
     idbConnection.ConnectionString = this.ConnectionString;
     if (idbConnection.State != ConnectionState.Open)
     {
         idbConnection.Open();
     }
 }
 public void BeginTransaction()
 {
     try
     {
         if (this.idbTransaction == null)
         {
             idbTransaction = SalesPOSDBManagerFactory.GetTransaction(this.ProviderType, this.idbConnection); // rasoo
         }
         // this.idbCommand.Transaction = idbTransaction;
     }
     catch (Exception ex)
     {
         throw (ex);
     }
 }
        public string GetMaxId(string tbName, string field)
        {
            string thisyeaar = string.Empty;

            try
            {
                this.Open();
                String   maxIDField = "";
                int      num        = 0;
                string   substr     = "";
                DateTime dt         = DateTime.Now;
                string   y          = dt.Year.ToString();
                string   m          = dt.Month.ToString();
                string   d          = dt.Day.ToString();
                m         = m.PadLeft(2, '0');
                d         = d.PadLeft(2, '0');
                thisyeaar = y + "" + m + "" + d;
                string strSQL = "select max(" + field + ") from " + tbName + " where " + field + " Like'" + thisyeaar + "%'";
                this.idbCommand        = SalesPOSDBManagerFactory.GetCommand(this.ProviderType);
                idbCommand.Connection  = this.idbConnection;
                idbCommand.CommandType = CommandType.Text;
                idbCommand.CommandText = strSQL;


                if (Convert.IsDBNull(idbCommand.ExecuteScalar()))
                {
                    thisyeaar = thisyeaar + "0001";
                }
                else
                {
                    maxIDField = Convert.ToString(idbCommand.ExecuteScalar());
                    int intCardLength = Convert.ToInt32(maxIDField.Length);
                    substr    = maxIDField.Substring(intCardLength - 4).ToString();
                    num       = Convert.ToInt16(substr) + 1;
                    thisyeaar = thisyeaar + num.ToString().PadLeft(4, '0');
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            finally
            {
                this.Dispose();
            }
            return(thisyeaar);
        }
 public int ExecuteNonQuery(CommandType commandType, string commandText)
 {
     BeginTransaction();
     try
     {
         this.idbCommand = SalesPOSDBManagerFactory.GetCommand(this.ProviderType);
         PrepareCommand(idbCommand, this.Connection, this.Transaction, commandType, commandText, this.Parameters);
         int returnValue = idbCommand.ExecuteNonQuery();
         idbCommand.Parameters.Clear();
         CommitTransaction();
         return(returnValue);
     }
     catch (Exception ex)
     {
         RollBackTransaction();
         throw (ex);
         //return -2;
     }
 }
        public DataTable GetDataTable(IDbCommand cmd)
        {
            DataSet ds = new DataSet();

            try
            {
                cmd.Connection = this.idbConnection;
                IDbDataAdapter dataadapter = SalesPOSDBManagerFactory.GetDataAdapter(this.ProviderType);
                dataadapter.SelectCommand = cmd;
                dataadapter.Fill(ds);
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            finally
            {
                ds.Dispose();
            }
            return((DataTable)ds.Tables[0]);
        }
        public IDbCommand getCommand(CommandType commandType, string commandText, IDbDataParameter[] commandParameters)
        {
            IDbCommand command = SalesPOSDBManagerFactory.GetCommand(this.providerType);

            try
            {
                command.Connection = this.idbConnection;

                command.CommandText = commandText;
                command.CommandType = commandType;
                if (commandParameters != null)
                {
                    AttachParameters(command, commandParameters);
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            finally
            {
            }
            return(command);
        }
 public void CreateParameters(int paramsCount)
 {
     idbParameters = new IDbDataParameter[paramsCount];
     idbParameters = SalesPOSDBManagerFactory.GetParameters(this.ProviderType, paramsCount);
 }