public MaterialPermitItem(DbDataReader reader, MaterialPermit document)
 {
     Id           = (int)reader["id"];
     Document     = document;
     Material     = (string)reader["material"];
     MaterialUnit = (string)reader["materialUnit"];
     Quantity     = (decimal)reader["quantity"];
     Tonnage      = (decimal)reader["tonnage"];
 }
        public override bool Equals(object obj)
        {
            MaterialPermit otherDocument = obj as MaterialPermit;

            if (otherDocument != null)
            {
                return(Id.Equals(otherDocument.Id));
            }

            return(false);
        }
Esempio n. 3
0
        public MaterialPermit GetMaterialPermit(Database database)
        {
            string          query      = EntryControl.Resources.Doc.MaterialPermit.GetMaterialPermitId;
            QueryParameters parameters = new QueryParameters("autoPermit", Id);
            object          result     = database.ExecuteScalar(query, parameters);

            if (result == null || DBNull.Value.Equals(result))
            {
                return(null);
            }

            return(MaterialPermit.Load(database, (int)result));
        }
        public static List <MaterialPermitItem> LoadList(Database database, MaterialPermit document)
        {
            List <MaterialPermitItem> itemList = new List <MaterialPermitItem>();

            string          query      = EntryControl.Resources.Doc.MaterialPermit.LoadItemList;
            QueryParameters parameters = new QueryParameters("id", document.Id);

            using (DbDataReader reader = database.ExecuteReader(query, parameters))
            {
                while (reader.Read())
                {
                    itemList.Add(new MaterialPermitItem(reader, document));
                }
                reader.Close();
            }

            return(itemList);
        }
        /// <summary>
        ///     возвращает объект по идентификатору
        /// </summary>
        /// <param name="database">объект БД</param>
        /// <param name="id">идентификатор документа</param>
        /// <returns>объект документа</returns>
        public static MaterialPermit Load(Database database, int id)
        {
            string          query      = EntryControl.Resources.Doc.MaterialPermit.Load;
            QueryParameters parameters = new QueryParameters("id", id);

            MaterialPermit materialPermit = null;

            using (DbDataReader reader = database.ExecuteReader(query, parameters))
            {
                if (reader.Read())
                {
                    materialPermit = new MaterialPermit(reader);
                }

                reader.Close();
            }

            if (materialPermit == null)
            {
                throw new ArgumentException(EntryControl.Resources.Message.Error.WrongIdentifier);
            }

            return(materialPermit);
        }