Ejemplo n.º 1
0
 public static void mngError(Exception ex,
                      string function,
                      string module,
                      string infoAdd,
                      string title,
                      eErrorLevel level,
                      eErrorType varType,
                      object connection)
 {
     // TODO: implement function
     fErrors f = new fErrors();
     f.setErrorIcon();
     f.setDetails(ex.Message);
     f.ShowDialog();
 }
Ejemplo n.º 2
0
        public static void mngError(Exception ex,
                                    string function,
                                    string module,
                                    string infoAdd,
                                    string title,
                                    eErrorLevel level,
                                    eErrorType varType,
                                    object connection)
        {
            // TODO: implement function
            fErrors f = new fErrors();

            f.setErrorIcon();
            f.setDetails(ex.Message);
            f.ShowDialog();
        }
Ejemplo n.º 3
0
        public bool execute(string sqlstmt,
                            string function,
                            string module,
                            string title,
                            eErrorLevel level)
        {
            int tryCount = 0;
            ors = null;

            while (tryCount < m_maxTryExecute)
            {
                if (pExecute(sqlstmt,
                             function,
                             module,
                             title,
                             level,
                             tryCount == m_maxTryExecute))
                {
                    return true;
                }
            }
            return false;
        }
Ejemplo n.º 4
0
 private bool pExecute(string sqlstmt,
                       string function,
                       string module,
                       string title,
                       eErrorLevel level,
                       bool showError)
 {
     try
     {
         DbCommand ocmd = createCommand(sqlstmt);
         ocmd.ExecuteNonQuery();
         return true;
     }
     catch (Exception ex)
     {
         if (showError)
         {
             cError.mngError(ex, "pExecute for " + module + "." + function, c_module, "sentencia: " + sqlstmt);
         }
         return false;
     }
 }
Ejemplo n.º 5
0
 public bool existsInRecordEx(DataRow dr,
                              DataColumn[] columns,
                              string val,
                              out bool founded,
                              bool like,
                              string function,
                              string module,
                              string title,
                              eErrorLevel level)
 {
     return pExistsInRecord(dr, columns, val, out founded, like,
                            function, module, title, level);
 }
Ejemplo n.º 6
0
        private bool pExistsInRecord(DataRow dr,
                                    DataColumn[] columns,
                                    string val,
                                    out bool founded,
                                    bool like,
                                    string function,
                                    string module,
                                    string title,
                                    eErrorLevel level)
        {
            string filter = "";
            founded = false;
            val = val.ToLower();

            try
            {
                foreach (DataColumn col in columns)
                {
                    System.TypeCode typeCode = System.Type.GetTypeCode(col.GetType()); ;
                    switch (typeCode)
                    {
                        case System.TypeCode.Char:
                        case System.TypeCode.String:
                            if (like)
                            {
                                founded = dr[col.ColumnName].ToString().ToLower().Contains(val);
                            }
                            else
                            {
                                founded = dr[col.ColumnName].ToString().ToLower() == val;
                            }
                            break;
                        case System.TypeCode.Decimal:
                        case System.TypeCode.Double:
                        case System.TypeCode.Int16:
                        case System.TypeCode.Int32:
                        case System.TypeCode.Int64:
                        case System.TypeCode.Single:
                        case System.TypeCode.UInt16:
                        case System.TypeCode.UInt32:
                        case System.TypeCode.UInt64:
                            int ival;
                            if (int.TryParse(val, out ival))
                            {
                                founded = (int)dr[col.ColumnName] == ival;
                            }
                            break;
                        case System.TypeCode.DateTime:
                            break;
                        case System.TypeCode.Boolean:
                            founded = false;
                            break;
                        default:
                            founded = false;
                            break;
                    }
                }
                return true;
            }
            catch (Exception ex)
            {
                cError.mngError(ex, "existsInRecord", module, "filter: " + filter);
                return false;
            }
        }
Ejemplo n.º 7
0
 private bool pOpenRs(string sqlstmt,
                      out DbDataReader ors,
                      string function,
                      string module,
                      string title,
                      eErrorLevel level,
                      bool showError)
 {
     ors = null;
     try
     {
         DbCommand ocmd = createCommand(sqlstmt);
         ors = ocmd.ExecuteReader();
         return true;
     }
     catch (Exception ex)
     {
         if (showError)
         {
             cError.mngError(ex, "openRs for " + module + "." + function, c_module, "sentencia: " + sqlstmt);
         }
         return false;
     }
 }
Ejemplo n.º 8
0
        public bool existsInRecordset(DataTable dt,
                                      string field,
                                      string val,
                                      out bool founded,
                                      string function,
                                      string module,
                                      string title,
                                      eErrorLevel level)
        {
            string filter = field + " = " + val;
            founded = false;

            try
            {
                if (dt.Rows.Count == 0)
                {
                    return false;
                }
                else
                {
                    DataRow[] vdr = dt.Select(filter);
                    founded = vdr.Length > 0;
                    return true;
                }
            }
            catch (Exception ex)
            {
                cError.mngError(ex, "existsInRecordset", module, "filter: " + filter);
                return false;
            }
        }
Ejemplo n.º 9
0
        public bool saveSp(string sqlstmt,
                           out DbDataReader ors,
                           int timeout,
                           string function,
                           string module,
                           string title,
                           eErrorLevel level)
        {

            int oldCommandTimeout = m_commandTimeout;
            if (timeout != -1)
            {
                m_commandTimeout = timeout;
            }
            bool rtn = openRs(sqlstmt, out ors, function, module, title, level);
            m_commandTimeout = oldCommandTimeout;
            return rtn;
        }
Ejemplo n.º 10
0
        public bool openRs(string sqlstmt,
                           out DbDataReader ors,
                           string function,
                           string module,
                           string title,
                           eErrorLevel level)
        {
            int tryCount = 0;
            ors = null;

            while (tryCount < m_maxTryOpenRs)
            {
                if (pOpenRs(sqlstmt,
                            out ors,
                            function,
                            module,
                            title,
                            level,
                            tryCount == m_maxTryOpenRs))
                {
                    return true;
                }
            }
            return false;
        }
Ejemplo n.º 11
0
        private bool pGetNewId(string table,
                               string fieldId,
                               out int id,
                               bool showError,
                               string function,
                               string module,
                               string title,
                               eErrorLevel level)
        {
            id = 0;
            try
            {

                string sqlstmt;
                DbDataReader ors;
                DbCommand ocmd;

                sqlstmt = "sp_dbgetnewid "
                                + sqlString(table) + ","
                                + sqlString(fieldId) + ",0";

                ocmd = createCommand(sqlstmt);
                ors = ocmd.ExecuteReader();
                if (ors.Read())
                {
                    id = (int)ors.GetInt32(0);
                    return true;
                }
                else
                {
                    return false;
                }
            }
            catch (Exception ex)
            {
                cError.mngError(ex, "pGetNewId for " + module + "." + function, c_module, "");
                return false;
            }
        }
Ejemplo n.º 12
0
        public bool getNewId(string table,
                             string fieldId,
                             out int id,
                             string function,
                             string module,
                             string title,
                             eErrorLevel level)
        {
            cMouseWait mouseWait = new cMouseWait();
            id = cConstants.C_NO_ID;
            try
            {
                if (pGetNewId(table, fieldId, out id, false,
                               function, module, title, level))
                {
                    return true;
                }
                else
                {
                    if (pReconnectTry())
                    {
                        return pGetNewId(table, fieldId, out id, true,
                                         function, module, title, level);
                    }
                    else return false;
                }
            }
            catch (Exception ex)
            {
                cError.mngError(ex, "getNewId for " + module + "." + function, c_module, "");
                return false;
            }
            finally
            {
                mouseWait.Dispose();
            }

        }
Ejemplo n.º 13
0
        private bool pGetData(string table,
                              string fieldId,
                              string id,
                              string field,
                              out DbDataReader ors,
                              string function,
                              string module,
                              string title,
                              eErrorLevel level)
        {
            string sqlstmt;
            ors = null;
            sqlstmt = "select " + field + " from " + table + " where " + fieldId + " = " + id;

            return openRs(sqlstmt, out ors, function, module, title, level);
        }
Ejemplo n.º 14
0
        public bool getData(string table,
                            string fieldId,
                            string id,
                            string field,
                            out DateTime data,
                            string function,
                            string module,
                            string title,
                            eErrorLevel level)
        {
            DbDataReader ors;

            data = cConstants.C_NO_DATE;

            if (pGetData(table, fieldId, id, field, out ors,
                         function, module, title, level))
            {
                if (ors.Read())
                {
                    data = ors.GetDateTime(0);
                }
                return true;
            }
            else return false;
        }
Ejemplo n.º 15
0
        public bool getData(string table,
                            string fieldId,
                            string id,
                            string field,
                            out int data,
                            string function,
                            string module,
                            string title,
                            eErrorLevel level)
        {
            DbDataReader ors;

            data = 0;

            if (pGetData(table, fieldId, id, field, out ors,
                         function, module, title, level))
            {
                if (ors.Read())
                {
                    data = (int)ors.GetInt32(0);
                }
                return true;
            }
            else return false;
        }