Пример #1
0
        /// <summary>
        /// Выбрать строку из справочника по коду груза
        /// </summary>
        /// <param name="CargoCode">Код груза</param>
        /// <returns></returns>
        public CargoGuide GetCargoByCode(string Cargo_ID)
        {
            using (SqlConnection sqlConn = new SqlConnection(connectionString))
            {

                using (SqlCommand sqlCmd = sqlConn.CreateCommand())
                {
                    sqlCmd.CommandText = "SELECT * FROM Cargo where Cargo.Cargo_ID = @Cargo_ID";
                    sqlCmd.Parameters.AddWithValue("@Cargo_ID", Int32.Parse(Cargo_ID));
                    CargoGuide cargo = new CargoGuide();
                    sqlConn.Open();

                    using (SqlDataReader sqlDR = sqlCmd.ExecuteReader())
                    {
                        while (sqlDR.Read())
                            cargo = GetCargoGuideInfo(sqlDR);

                        if (sqlDR != null)
                            sqlDR.Close();
                        sqlConn.Close();
                    }
                    return cargo;
                }
            }
        }
Пример #2
0
        public CargoGuide GetCargoGuideInfo(SqlDataReader sqlDR)
        {
            CargoGuide row = new CargoGuide();

            row.Cargo_ID = DBNullToString(sqlDR["Cargo_ID"]);
            row.Name = DBNullToString(sqlDR["Name"]);
            row.Description = DBNullToString(sqlDR["Description"]);
            row.ShortCode = DBNullToString(sqlDR["ShortCode"]);
            row.Code = DBNullToString(sqlDR["Code"]);
            row.CodeGNG = DBNullToString(sqlDR["CodeGNG"]);
            row.Mnemocode = DBNullToString(sqlDR["Mnemocode"]);
            row.IsUsed = DBNullToString(sqlDR["IsUsed"]);
            row.IsEmpty = DBNullToString(sqlDR["IsEmpty"]);

            return row;
        }