示例#1
0
        public static bool ReturnDBInputStatus(object obj, string SPName)
        {
            DBSettingEntity          dbSetting = new DBSettingEntity(DataProvider.SqlServer, DBSetting.GetDBConnection(DBSource.MainDBConstr), CommandType.StoredProcedure, DBSetting.GetSPValue(SPName), false);
            List <SPParameterEntity> sp        = SPParameterObject.GetParameter(SPName);

            PropertyInfo[] ps        = obj.GetType().GetProperties();
            bool           statusVal = false;

            foreach (PropertyInfo p in ps)
            {
                string parametername = string.Empty;
                if (sp.Exists(delegate(SPParameterEntity s) { parametername = s.name; return(s.name.ToLower() == "@" + p.Name.ToLower()); }))
                {
                    dbSetting.AddParameters(parametername, p.GetValue(obj, null) == null ? DBNull.Value : p.GetValue(obj, null), ParameterDirection.Input);
                }
            }
            Func <IDataReader, bool> func = delegate(IDataReader dr)
            {
                while (dr.Read())
                {
                    if (dr["StatusValue"].ToString() == "1")
                    {
                        statusVal = true;
                    }
                    else
                    {
                        statusVal = false;
                    }
                }
                return(true);
            };

            DBManager2.Instance.ExecuteReader(dbSetting, func);
            return(statusVal);
        }
示例#2
0
        public static void InputToDB(object obj, string SPName)
        {
            DBSettingEntity          dbSetting = new DBSettingEntity(DataProvider.SqlServer, DBSetting.GetDBConnection(DBSource.MainDBConstr), CommandType.StoredProcedure, DBSetting.GetSPValue(SPName), false);
            List <SPParameterEntity> sp        = SPParameterObject.GetParameter(SPName);

            PropertyInfo[] ps = obj.GetType().GetProperties();
            foreach (PropertyInfo p in ps)
            {
                string parametername = string.Empty;
                if (sp.Exists(delegate(SPParameterEntity s) { parametername = s.name; return(s.name.ToLower() == "@" + p.Name.ToLower()); }))
                {
                    dbSetting.AddParameters(parametername, p.GetValue(obj, null) == null ? DBNull.Value : p.GetValue(obj, null), ParameterDirection.Input);
                }
            }
            DBManager2.Instance.ExecuteNonQuery(dbSetting);
        }
        public static List <SPParameterEntity> GetParameter(string SPName)
        {
            List <SPParameterEntity> list      = new List <SPParameterEntity>();
            DBSettingEntity          dbSetting = new DBSettingEntity(DataProvider.SqlServer, DBSetting.GetDBConnection(DBSource.MainDBConstr), CommandType.StoredProcedure, DBSetting.GetSPValue("GetSPParameters"), false);

            dbSetting.AddParameters("@SPName", DBSetting.GetSPValue(SPName), ParameterDirection.Input);
            Func <IDataReader, bool> func = delegate(IDataReader dr)
            {
                List <string> drlist = new List <string>();

                while (dr.Read())
                {
                    list.Add((SPParameterEntity)DBHelper.DataReaderMapping(dr, new SPParameterEntity()));
                }
                return(true);
            };

            DBManager2.Instance.ExecuteReader(dbSetting, func);
            return(list);
        }