예제 #1
0
 public PgInstrumentDetail(InstrumentVm instrument, IInstrumentManager instrumentManager, bool editMode = false)
 {
     InitializeComponent();
     _instrumentManager = instrumentManager;
     _instrument        = instrument;
     _editMode          = false;
     _editMode          = editMode;
 }
예제 #2
0
        public List <InstrumentVm> SelectInstrumentsByStatus(string status)
        {
            List <InstrumentVm> instruments = new List <InstrumentVm>();
            var conn = DbConnection.GetConnection();
            var cmd  = new SqlCommand("sp_select_instruments_by_status", conn)
            {
                CommandType = CommandType.StoredProcedure
            };

            cmd.Parameters.AddWithValue("@Status", status);

            try
            {
                conn.Open();
                var reader = cmd.ExecuteReader();
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        InstrumentVm newInstrument = new InstrumentVm
                        {
                            InstrumentId       = reader.GetString(0),
                            InstrumentTypeId   = reader.GetString(1),
                            InstrumentFamily   = reader.GetString(2),
                            InstrumentStatusId = reader.GetString(3),
                            InstrumentBrandId  = reader.GetString(4),
                            Price               = reader.GetDecimal(5),
                            RentalTermId        = reader.GetString(6),
                            RentalFee           = reader.GetDecimal(7),
                            PrepListDescription = reader.GetString(8)
                        };
                        instruments.Add(newInstrument);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }

            return(instruments);
        }
예제 #3
0
        public List <InstrumentVm> SelectAllInCart()
        {
            List <InstrumentVm> instruments = new List <InstrumentVm>();
            var conn = DbConnection.GetConnection();
            var cmd  = new SqlCommand("sp_select_all_in_cart", conn)
            {
                CommandType = CommandType.StoredProcedure
            };

            try
            {
                conn.Open();
                var reader = cmd.ExecuteReader();
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        InstrumentVm newInstrument = new InstrumentVm
                        {
                            InstrumentId       = reader.GetString(0),
                            InstrumentTypeId   = reader.GetString(1),
                            InstrumentStatusId = reader.GetString(3),
                            InstrumentBrandId  = reader.GetString(4),
                            Price        = reader.GetDecimal(5),
                            RentalTermId = reader.GetString(6),
                            RentalFee    = reader.GetDecimal(7),
                        };
                        instruments.Add(newInstrument);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }

            return(instruments);
        }