public ListOfPercents ReadPercentages() { List <Percent> percentsList = new List <Percent>(); SqlConnection connectToDateBase = new SqlConnection(pathOfDataBase); using (connectToDateBase) { SqlCommand command = new SqlCommand( "SELECT PERCENT_ID, DISCOUNT_MARKUP, DESCRIPTION, PERCENT1 FROM [PERCENTAGES];", connectToDateBase); connectToDateBase.Open(); SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { Percent percent = new Percent(reader.GetInt32(0), reader.GetString(1), reader.GetString(2), reader.GetInt32(3)); percentsList.Add(percent); } } reader.Close(); } ListOfPercents percents = new ListOfPercents(percentsList); return(percents); }
public fPercents(AuthorisedUser user) { InitializeComponent(); if (user.GetType() == typeof(AdminUser)) { this.user = user; ReadingFromDateBase reading = new ReadingFromDateBase(); percentList = reading.ReadPercentages(); sourceData.DataSource = percentList.Percents; dataGridViewPercents.DataSource = sourceData; dataGridViewPercents.Columns[0].Visible = false; dataGridViewPercents.Columns[1].HeaderText = "Скидка/Наценка"; dataGridViewPercents.Columns[2].HeaderText = "Описание"; dataGridViewPercents.Columns[3].HeaderText = "Процент"; } else { this.user = user; ReadingFromDateBase reading = new ReadingFromDateBase(); percentList = reading.ReadPercentages(); sourceData.DataSource = percentList.Percents; dataGridViewPercents.DataSource = sourceData; dataGridViewPercents.Columns[0].Visible = false; dataGridViewPercents.Columns[1].HeaderText = "Скидка/Наценка"; dataGridViewPercents.Columns[2].HeaderText = "Описание"; dataGridViewPercents.Columns[3].HeaderText = "Процент"; AddButton.Visible = false; UpdateButton.Visible = false; DeleteButton.Visible = false; this.Close(); } }
public fTickets(AuthorisedUser user) { InitializeComponent(); this.user = user; ReadingFromDateBase reading = new ReadingFromDateBase(); ticketsList = reading.ReadTickets(); percentsList = reading.ReadPercentages(); totalPercentList = reading.ReadTotalPercents(); statusTicketList = reading.ReadStatusTickets(); sessionList = reading.ReadSessions(); LoadDataGridView(); }
public fTickets(AuthorisedUser user, Session session, int row, int placeNumber, double price) { InitializeComponent(); this.user = user; ReadingFromDateBase reading = new ReadingFromDateBase(); ticketsList = reading.ReadTickets(); percentsList = reading.ReadPercentages(); totalPercentList = reading.ReadTotalPercents(); statusTicketList = reading.ReadStatusTickets(); sessionList = reading.ReadSessions(); LoadDataGridView(); SessionInput.Text = session.FilmSession.FilmName; RowInput.Text = row.ToString(); PlaceNumberInput.Text = placeNumber.ToString(); PriceInput.Text = price.ToString(); TicketInput.Text = (ticketsList.Tickets.Count() + 1).ToString(); }