Exemplo n.º 1
0
        public Core.Business.Material GetByCode(string code)
        {
            SqlServerUtility sql = new SqlServerUtility();

            sql.AddParameter("@Code", SqlDbType.NVarChar, code);
            SqlDataReader reader = sql.ExecuteSqlReader(SqlGetByCode);

            if (reader != null && !reader.IsClosed && reader.Read())
            {
                Core.Business.Material material = new Core.Business.Material();

                if (!reader.IsDBNull(0)) material.Id = reader.GetInt32(0);
                if (!reader.IsDBNull(1)) material.Num = reader.GetInt32(1);
                if (!reader.IsDBNull(2)) material.BookDate = reader.GetDateTime(2);
                if (!reader.IsDBNull(3)) material.PreArriveDate = reader.GetDateTime(3);
                if (!reader.IsDBNull(4)) material.ArriveTimeDate = reader.GetDateTime(4);
                if (!reader.IsDBNull(5)) material.Code = reader.GetString(5);
                if (!reader.IsDBNull(6)) material.InPosition = reader.GetString(6);
                if (!reader.IsDBNull(7)) material.UnitCode = reader.GetString(7);
                if (!reader.IsDBNull(8)) material.AcceptResult = reader.GetString(8);

                reader.Close();

                material.MarkOld();

                return material;
            }
            else
            {
                if (reader != null && !reader.IsClosed)
                    reader.Close();

                return null;
            }
        }
Exemplo n.º 2
0
        public IList<Core.Business.Material> GetAllMaterial()
        {
            IList<Core.Business.Material> materiallist = new List<Core.Business.Material>();
            SqlServerUtility sql = new SqlServerUtility();

            SqlDataReader reader = sql.ExecuteSqlReader(SqlGetAllMaterial);

            if(reader != null)
            {
                while(reader.Read())
                {
                    Core.Business.Material material = new Core.Business.Material();

                    if (!reader.IsDBNull(0)) material.Id = reader.GetInt32(0);
                    if (!reader.IsDBNull(1)) material.Num = reader.GetInt32(1);
                    if (!reader.IsDBNull(2)) material.BookDate = reader.GetDateTime(2);
                    if (!reader.IsDBNull(3)) material.PreArriveDate = reader.GetDateTime(3);
                    if (!reader.IsDBNull(4)) material.ArriveTimeDate = reader.GetDateTime(4);
                    if (!reader.IsDBNull(5)) material.Code = reader.GetString(5);
                    if (!reader.IsDBNull(6)) material.InPosition = reader.GetString(6);
                    if (!reader.IsDBNull(7)) material.UnitCode = reader.GetString(7);
                    if (!reader.IsDBNull(8)) material.AcceptResult = reader.GetString(8);

                    material.MarkOld();
                    materiallist.Add(material);
                }
                reader.Close();
            }
            return materiallist;
        }