Пример #1
0
        public static Dictionary <String, DataRow> BuildIndex_SQL(String SQLCommand, List <String> ColumnName, String seperator)
        {
            DataTable table = DataSupport.RunDataSet(SQLCommand).Tables[0];
            Dictionary <String, DataRow> index = new Dictionary <String, DataRow>(table.Rows.Count);

            foreach (DataRow Row in table.Rows)
            {
                String key = "";
                int    cnt = 0;

                foreach (String col in ColumnName)
                {
                    if (cnt == ColumnName.Count - 1)
                    {
                        key += Row[col].ToString().Trim();
                    }
                    else
                    {
                        key += Row[col].ToString().Trim() + seperator;
                    }
                    cnt++;
                }

                index[key] = Row;
            }
            return(index);
        }
Пример #2
0
        public static String GetNextMenuCodeInt(String menu)
        {
            String result = "";

            System.Data.DataSet ds = DataSupport.RunDataSet(String.Format("SELECT menu_current FROM MENU WHERE menu_id = '{0}' ", menu) + UpdateMenuCode(menu));
            String next_value      = ds.Tables[0].Rows[0][0].ToString();

            result = next_value;
            return(result);
        }
Пример #3
0
        private static Boolean IsInConflict(String value, String table, String id)
        {
            String    sql = "SELECT " + id + " FROM " + table + " WHERE " + id + " = @id ";
            DataTable dt  = DataSupport.RunDataSet(sql, "id", value).Tables[0];

            if (dt.Rows.Count > 0)
            {
                return(true);
            }
            return(false);
        }
Пример #4
0
        public static String GetNextMenuCode(String menu, String menu_prefix)
        {
            String result      = "";
            String building_id = "WEB";

            System.Data.DataSet ds = DataSupport.RunDataSet(String.Format("SELECT menu_current FROM MENU WHERE menu_id = '{0}' ", menu));
            String next_value      = ds.Tables[0].Rows[0][0].ToString();

            result = String.Format("{0}-{1}-{2}", building_id, menu_prefix, next_value);
            return(result);
        }
Пример #5
0
        public static Dictionary <String, DataRow> BuildIndex_SQL(String SQLCommand, String ColumnName)
        {
            DataTable table = DataSupport.RunDataSet(SQLCommand).Tables[0];
            Dictionary <String, DataRow> index = new Dictionary <String, DataRow>(table.Rows.Count);

            foreach (DataRow Row in table.Rows)
            {
                index[Row[ColumnName].ToString()] = Row;
            }
            return(index);
        }
Пример #6
0
        public static void GetChildren(String table_name, String parent_key, String primary_key, String value, ref List <String> result)
        {
            String sql = "SELECT " + primary_key + " FROM " + table_name + " WHERE " + parent_key + " = @value";
            var    dt  = DataSupport.RunDataSet(sql, "value", value).Tables[0];

            foreach (DataRow row in dt.Rows)
            {
                String child_value = row[primary_key].ToString();
                result.Add(child_value);
                GetChildren(table_name, parent_key, primary_key, child_value, ref result);
            }
        }
Пример #7
0
        public static string GetDataString(String sql, params Object[] parameters)
        {
            DataTable dt = DataSupport.RunDataSet(sql).Tables[0];

            if (dt.Rows.Count == 0)
            {
                return("");
            }
            else
            {
                return(dt.Rows[0][0].ToString());
            }
        }
Пример #8
0
        public static int GetDataInt(String sql, params Object[] parameters)
        {
            DataTable dt = DataSupport.RunDataSet(sql).Tables[0];

            if (dt.Rows.Count == 0)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(dt.Rows[0][0]));
            }
        }
Пример #9
0
        public static decimal GetDataDecimal(String sql, params Object[] parameters)
        {
            DataTable dt = DataSupport.RunDataSet(sql).Tables[0];

            if (dt.Rows.Count == 0)
            {
                return(Convert.ToDecimal("0.00"));
            }
            else
            {
                return(Convert.ToDecimal(dt.Rows[0][0]));
            }
        }
Пример #10
0
 public static DataTable GetDataTable(String sql, params Object[] parameters)
 {
     return(DataSupport.RunDataSet(sql).Tables[0]);
 }
Пример #11
0
 public static System.Data.DataSet GetDataset(String sql)
 {
     return(DataSupport.RunDataSet(sql));
 }