Пример #1
0
 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);
 }
Пример #2
0
        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);
        }
Пример #3
0
 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;
     }
 }
Пример #4
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);
        }