Esempio n. 1
0
        public IList<CY.GFive.Core.Business.ClassInfo> Search(string strGradeCode, string strProCode, string keyword)
        {
            IList<Core.Business.ClassInfo> listClassInfo = new List<Core.Business.ClassInfo>();
            SqlServerUtility sqlhelper = new SqlServerUtility();
            SqlDataReader reader;
            if (!string.IsNullOrEmpty(keyword) && (keyword.Trim() != ""))
            {
                sqlhelper.AddParameter("@KeyWord", SqlDbType.VarChar, keyword.Trim(), 50);
            }

            if (!strGradeCode.Trim().Equals(""))
            {
                sqlhelper.AddParameter("@GradeCode", SqlDbType.NVarChar, strGradeCode.Trim(), 30);
                if (!strProCode.Trim().Equals(""))
                {
                    sqlhelper.AddParameter("@ProCode", SqlDbType.NVarChar, strProCode.Trim(), 20);
                    if (!string.IsNullOrEmpty(keyword) && (keyword.Trim() != ""))
                    {
                        reader = sqlhelper.ExecuteSqlReader(SqlSelectByGPClassCodeSearch.ToString());
                    }
                    else
                    {
                        reader = sqlhelper.ExecuteSqlReader(SqlSelectByGradeCodeAndProCodeSearch.ToString());
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(keyword) && (keyword.Trim() != ""))
                    {
                        reader = sqlhelper.ExecuteSqlReader(SqlSelectByGClassCodeSearch.ToString());
                    }
                    else
                    {
                        reader = sqlhelper.ExecuteSqlReader(SqlSelectByGradeCodeSearch.ToString());
                    }
                }

            }
            else if (!strProCode.Trim().Equals(""))
            {
                sqlhelper.AddParameter("@ProCode", SqlDbType.NVarChar, strProCode.Trim(), 20);
                if (!string.IsNullOrEmpty(keyword) && (keyword.Trim() != ""))
                {
                    reader = sqlhelper.ExecuteSqlReader(SqlSelectByPClassCodeSearch.ToString());
                }
                else
                {
                    reader = sqlhelper.ExecuteSqlReader(SqlSelectByProCodeSearch.ToString());
                }
            }
            else if (!string.IsNullOrEmpty(keyword) && (keyword.Trim() != ""))
            {
                reader = sqlhelper.ExecuteSqlReader(SqlSelectByClassCodeSearch);
            }
            else
            {
                reader = sqlhelper.ExecuteSqlReader(SqlGetAllClassInfo);
            }

            if (reader != null && !reader.IsClosed)
            {
                while (reader.Read())
                {
                    ClassInfo ci = new ClassInfo();

                    if (!reader.IsDBNull(0)) ci.Id = reader.GetInt32(0);
                    if (!reader.IsDBNull(1)) ci.ClassCode = reader.GetString(1);
                    if (!reader.IsDBNull(2)) ci.GradeCode = reader.GetString(2);
                    if (!reader.IsDBNull(3)) ci.ProCode = reader.GetString(3);
                    if (!reader.IsDBNull(4)) ci.OrStdNum = reader.GetInt32(4);
                    if (!reader.IsDBNull(5)) ci.ClassName = reader.GetString(5);

                    ci.MarkOld();

                    listClassInfo.Add(ci);
                }
                reader.Close();
                return listClassInfo;
            }

            return null;
        }