コード例 #1
0
ファイル: DALBaseCommon.cs プロジェクト: yfbTeam/CRM
 /// <summary>
 /// 获取联系人类
 /// </summary>
 /// <param name="entity"></param>
 /// <param name="id"></param>
 /// <returns></returns>
 public static linkman_info getcust_linkman(linkman_info entity, string id)
 {
     try
     {
         SqlParameter[] param =
         {
             new SqlParameter("@Id", id)
         };
         SqlDataReader reader = SQLHelp.ExecuteReader("getcust_linkman", CommandType.StoredProcedure, param);
         if (reader.HasRows)
         {
             PropertyInfo[] pros = entity.GetType().GetProperties();
             while (reader.Read())
             {
                 foreach (PropertyInfo item in pros)
                 {
                     item.SetValue(entity, reader.IsDBNull(reader.GetOrdinal(item.Name)) ? null : reader[item.Name]);
                 }
             }
         }
         else
         {
             entity = null;
         }
         return(entity);
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
コード例 #2
0
ファイル: BaseDal.cs プロジェクト: yfbTeam/CRM
 /// <summary>
 /// 根据Id获取单条数据
 /// </summary>
 /// <param name="entity"></param>
 /// <param name="id"></param>
 /// <returns></returns>
 public virtual T GetEntityById(T entity, int id)
 {
     try
     {
         string        sql    = string.Format("select * from {0} where Id=@id", entity.GetType().Name);
         SqlParameter  pms    = new SqlParameter("@id", id);
         SqlDataReader reader = SQLHelp.ExecuteReader(sql, CommandType.Text, pms);
         if (reader.HasRows)
         {
             PropertyInfo[] pros = entity.GetType().GetProperties();
             while (reader.Read())
             {
                 foreach (PropertyInfo item in pros)
                 {
                     item.SetValue(entity, reader.IsDBNull(reader.GetOrdinal(item.Name)) ? null : reader[item.Name]);
                 }
             }
         }
         else
         {
             entity = null;
         }
         return(entity);
     }
     catch (Exception ex)
     {
         LogHelper.Error(ex);
         return(null);
     }
 }
コード例 #3
0
ファイル: DALBaseCommon.cs プロジェクト: yfbTeam/CRM
 /// <summary>
 /// 获取提醒设置信息
 /// </summary>
 /// <param name="entity"></param>
 /// <param name="remind_userid"></param>
 /// <param name="remind_type"></param>
 /// <returns></returns>
 public static remind_setting get_remind_setting_info(remind_setting entity, string remind_userid, string remind_type)
 {
     try
     {
         SqlParameter[] param =
         {
             new SqlParameter("@remind_userid", remind_userid),
             new SqlParameter("@remind_type",   remind_type)
         };
         SqlDataReader reader = SQLHelp.ExecuteReader("get_remind_setting_info", CommandType.StoredProcedure, param);
         if (reader.HasRows)
         {
             PropertyInfo[] pros = entity.GetType().GetProperties();
             while (reader.Read())
             {
                 foreach (PropertyInfo item in pros)
                 {
                     item.SetValue(entity, reader.IsDBNull(reader.GetOrdinal(item.Name)) ? null : reader[item.Name]);
                 }
             }
         }
         else
         {
             entity = null;
         }
         return(entity);
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
コード例 #4
0
ファイル: BaseDal.cs プロジェクト: yfbTeam/Ecampus
        public virtual List <T> GetEntityListByField(T entity, string filed, string value)
        {
            List <T>      tlist  = new List <T>();
            string        sql    = string.Format("select * from {0} where {1}=@id", entity.GetType().Name, filed);
            SqlParameter  pms    = new SqlParameter("@id", value);
            SqlDataReader reader = SQLHelp.ExecuteReader(sql, CommandType.Text, pms);

            if (reader.HasRows)
            {
                PropertyInfo[] pros = entity.GetType().GetProperties();
                while (reader.Read())
                {
                    T newentity = new T();
                    foreach (PropertyInfo item in pros)
                    {
                        if (string.IsNullOrEmpty(reader[item.Name].SafeToString()))
                        {
                            // item.SetValue(newentity, "");
                        }
                        else
                        {
                            item.SetValue(newentity, reader[item.Name]);
                        }
                    }
                    tlist.Add(newentity);
                }
            }
            return(tlist);
        }
コード例 #5
0
        public DataTable FetchGivenAccess(Int32 DesignationID)
        {
            List <SqlParameter> sqlparam = new List <SqlParameter>();

            sqlparam.Add(new SqlParameter("@DesignationId", DesignationID));
            DataTable dt = SQLHelp.ExecuteReader("Usp_GetGivenAccess", sqlparam);

            return(dt);
        }
コード例 #6
0
        public DataTable CheckGivenAccess(int UserID, int PageID)
        {
            List <SqlParameter> sqlparam = new List <SqlParameter>();

            sqlparam.Add(new SqlParameter("@UserId", UserID));
            sqlparam.Add(new SqlParameter("@MenuId", PageID));
            DataTable dt = SQLHelp.ExecuteReader("Usp_GetUserAccess", sqlparam);

            return(dt);
        }
コード例 #7
0
ファイル: DYYX_BaseDal.cs プロジェクト: yfbTeam/portal
        public virtual List <T> GetEntityListByField(T entity, string filed, string value, string sqlWhere)
        {
            List <T> tlist = new List <T>();

            try
            {
                using (SqlConnection con = new SqlConnection(SQLHelp.conStr))
                {
                    string       sql = string.Format("select * from {0} where {1}=@id", entity.GetType().Name, filed);
                    SqlParameter pms = new SqlParameter("@id", value);

                    if (!string.IsNullOrEmpty(sqlWhere))
                    {
                        sql += string.Format(@" and {0}", sqlWhere);
                    }
                    SqlDataReader reader = SQLHelp.ExecuteReader(con, sql, CommandType.Text, pms);
                    if (reader.HasRows)
                    {
                        PropertyInfo[] pros = entity.GetType().GetProperties();
                        while (reader.Read())
                        {
                            T newentity = new T();
                            foreach (PropertyInfo item in pros)
                            {
                                if (string.IsNullOrEmpty(reader[item.Name].SafeToString()))
                                {
                                    // item.SetValue(newentity, "");
                                }
                                else
                                {
                                    item.SetValue(newentity, reader[item.Name]);
                                }
                            }
                            tlist.Add(newentity);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
            }
            return(tlist);
        }