Пример #1
0
        public InstrumentTypeVm SelectInstrumentTypeByInstrumentTypeId(string instrumentTypeId)
        {
            InstrumentTypeVm instrumentType = new InstrumentTypeVm();
            var conn = DbConnection.GetConnection();
            var cmd  = new SqlCommand("sp_select_instrument_type_by_InstrumentTypeID", conn)
            {
                CommandType = CommandType.StoredProcedure
            };

            cmd.Parameters.AddWithValue("@InstrumentTypeID", instrumentTypeId);

            try
            {
                conn.Open();
                var reader = cmd.ExecuteReader();
                if (reader.Read())
                {
                    instrumentType.InstrumentTypeId   = instrumentTypeId;
                    instrumentType.RentalTermId       = reader.GetString(0);
                    instrumentType.RentalFee          = reader.GetDecimal(1);
                    instrumentType.InstrumentFamilyId = reader.GetString(2);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }
            return(instrumentType);
        }
Пример #2
0
        private void cmbType_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            string           instrumentType   = CmbType.SelectedItem.ToString();
            InstrumentTypeVm instrumentTypeVm = null;

            try
            {
                instrumentTypeVm = _instrumentManager.GetInstrumentTypeByInstrumentTypeId(instrumentType);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n\n" + ex.InnerException.Message);
            }
            TxtFamily.Text     = instrumentTypeVm.InstrumentFamilyId;
            TxtRentalTerm.Text = instrumentTypeVm.RentalTermId;
            TxtRentalFee.Text  = instrumentTypeVm.RentalFee.ToString("c");
        }