Трудности при чтении из БД и скроллинге tabPage - C#
Формулировка задачи:
Всем здоровья, друзья Возникла проблема вот такого плана: Я из БД сайта считываю поступившие брони в отеле, Вроде бы всё успешно, НО(всегда возникает какое-то "но" ) при считывании даты заезда и выезда у меня скроллинг происходит не до конца
В этом кусочке кода я закомментировал проблемные строки. В данном случае скролл проходит до конца.( 1 скрин)
MySqlDataReader readedBrons; int dictionCounts = 1; int x = 31, y = 21,y2=46,y3=71,y4=96,y5=121,y6=146,y7=171,y8=196,y9=221,y10=246,y11=271,y12=296,y13=321,y14=346; Dictionary<int, Label> bronTitle = new Dictionary<int, Label>(); Dictionary<int, Label> bronInDate = new Dictionary<int, Label>(); Dictionary<int, Label> bronOutDate = new Dictionary<int, Label>(); Dictionary<int, Label> bronSurename = new Dictionary<int, Label>(); Dictionary<int, Label> bronName = new Dictionary<int, Label>(); Dictionary<int, Label> bronLastname = new Dictionary<int, Label>(); Dictionary<int, Label> bronPhone = new Dictionary<int, Label>(); Dictionary<int, Label> bronType = new Dictionary<int, Label>(); Dictionary<int, Label> bronDays = new Dictionary<int, Label>(); Dictionary<int, Label> bronPeoples = new Dictionary<int, Label>(); Dictionary<int, Label> bronPrice = new Dictionary<int, Label>(); Dictionary<int, Button> confirmButton = new Dictionary<int, Button>(); Dictionary<int, Button> borderLine = new Dictionary<int, Button>(); Dictionary<int, Button> freeSpace = new Dictionary<int, Button>(); connect.Open(); readedBrons = commandExecuteBrons.ExecuteReader(); while(readedBrons.Read()) { bronTitle[dictionCounts] = new Label(); bronTitle[dictionCounts].Location = new Point(x, y); bronTitle[dictionCounts].Font = new Font("Century Gothic", 10, FontStyle.Regular); bronTitle[dictionCounts].Text = "Номер: " + readedBrons["number"].ToString(); bronTitle[dictionCounts].AutoSize = true; tabPage1.Controls.Add(bronTitle[dictionCounts]); //bronInDate[dictionCounts] = new Label(); //bronInDate[dictionCounts].Location = new Point(x, y2); //bronInDate[dictionCounts].Font = new Font("Century Gothic", 10, FontStyle.Regular); //bronInDate[dictionCounts].Text = "Дата заезда: " + readedBrons["date1"].ToString(); //bronInDate[dictionCounts].AutoSize = true; //tabPage1.Controls.Add(bronInDate[dictionCounts]); //bronOutDate[dictionCounts] = new Label(); //bronOutDate[dictionCounts].Location = new Point(x, y3); //bronOutDate[dictionCounts].Font = new Font("Century Gothic", 10, FontStyle.Regular); //bronOutDate[dictionCounts].Text = "Дата выезда: " + readedBrons["date2"].ToString(); //bronOutDate[dictionCounts].AutoSize = true; //tabPage1.Controls.Add(bronOutDate[dictionCounts]); bronSurename[dictionCounts] = new Label(); bronSurename[dictionCounts].Location = new Point(x, y4); bronSurename[dictionCounts].Font = new Font("Century Gothic", 10, FontStyle.Regular); bronSurename[dictionCounts].Text = "Фамилия: " + readedBrons["surname"].ToString(); bronSurename[dictionCounts].AutoSize = true; tabPage1.Controls.Add(bronSurename[dictionCounts]); bronName[dictionCounts] = new Label(); bronName[dictionCounts].Location = new Point(x, y5); bronName[dictionCounts].Font = new Font("Century Gothic", 10, FontStyle.Regular); bronName[dictionCounts].Text = "Имя: " + readedBrons["name"].ToString(); bronName[dictionCounts].AutoSize = true; tabPage1.Controls.Add(bronName[dictionCounts]); bronLastname[dictionCounts] = new Label(); bronLastname[dictionCounts].Location = new Point(x, y6); bronLastname[dictionCounts].Font = new Font("Century Gothic", 10, FontStyle.Regular); bronLastname[dictionCounts].Text = "Отчество: " + readedBrons["lastname"].ToString(); bronLastname[dictionCounts].AutoSize = true; tabPage1.Controls.Add(bronLastname[dictionCounts]); bronPhone[dictionCounts] = new Label(); bronPhone[dictionCounts].Location = new Point(x, y7); bronPhone[dictionCounts].Font = new Font("Century Gothic", 10, FontStyle.Regular); bronPhone[dictionCounts].Text = "Телефон: " + readedBrons["phone"].ToString(); bronPhone[dictionCounts].AutoSize = true; tabPage1.Controls.Add(bronPhone[dictionCounts]); bronType[dictionCounts] = new Label(); bronType[dictionCounts].Location = new Point(x, y8); bronType[dictionCounts].Font = new Font("Century Gothic", 10, FontStyle.Regular); bronType[dictionCounts].Text = "Тип брони: " + readedBrons["brontype"].ToString(); bronType[dictionCounts].AutoSize = true; tabPage1.Controls.Add(bronType[dictionCounts]); bronDays[dictionCounts] = new Label(); bronDays[dictionCounts].Location = new Point(x, y9); bronDays[dictionCounts].Font = new Font("Century Gothic", 10, FontStyle.Regular); bronDays[dictionCounts].Text = "Количество дней: " + readedBrons["days"].ToString(); bronDays[dictionCounts].AutoSize = true; tabPage1.Controls.Add(bronDays[dictionCounts]); bronPeoples[dictionCounts] = new Label(); bronPeoples[dictionCounts].Location = new Point(x, y10); bronPeoples[dictionCounts].Font = new Font("Century Gothic", 10, FontStyle.Regular); bronPeoples[dictionCounts].Text = "Количество человек: " + readedBrons["peoples"].ToString(); bronPeoples[dictionCounts].AutoSize = true; tabPage1.Controls.Add(bronPeoples[dictionCounts]); bronPrice[dictionCounts] = new Label(); bronPrice[dictionCounts].Location = new Point(x, y11); bronPrice[dictionCounts].Font = new Font("Century Gothic", 10, FontStyle.Regular); bronPrice[dictionCounts].Text = "Цена: " + readedBrons["price"].ToString(); bronPrice[dictionCounts].AutoSize = true; tabPage1.Controls.Add(bronPrice[dictionCounts]); confirmButton[dictionCounts] = new Button(); confirmButton[dictionCounts].Parent = tabPage1; confirmButton[dictionCounts].Location = new Point(526, y12); confirmButton[dictionCounts].BackColor = Color.YellowGreen; confirmButton[dictionCounts].Width = 300; confirmButton[dictionCounts].Height = 30; confirmButton[dictionCounts].ForeColor = Color.Black; confirmButton[dictionCounts].Font = new Font("Century Gothic", 10, FontStyle.Regular); confirmButton[dictionCounts].Text = "Подтвердить бронь"; confirmButton[dictionCounts].FlatStyle = FlatStyle.Flat; confirmButton[dictionCounts].FlatAppearance.BorderSize = 0; confirmButton[dictionCounts].Cursor = Cursors.Hand; tabPage1.Controls.Add(confirmButton[dictionCounts]); borderLine[dictionCounts] = new Button(); borderLine[dictionCounts].Parent = tabPage1; borderLine[dictionCounts].Location = new Point(x, y13); borderLine[dictionCounts].BackColor = Color.YellowGreen; borderLine[dictionCounts].Width = 795; borderLine[dictionCounts].Height = 3; borderLine[dictionCounts].FlatStyle = FlatStyle.Flat; borderLine[dictionCounts].FlatAppearance.BorderSize = 0; tabPage1.Controls.Add(borderLine[dictionCounts]); freeSpace[dictionCounts] = new Button(); freeSpace[dictionCounts].Parent = tabPage1; freeSpace[dictionCounts].Location = new Point(x, y14); freeSpace[dictionCounts].BackColor = Color.Transparent; freeSpace[dictionCounts].Width = 795; freeSpace[dictionCounts].Height = 3; freeSpace[dictionCounts].FlatStyle = FlatStyle.Flat; freeSpace[dictionCounts].FlatAppearance.BorderSize = 0; freeSpace[dictionCounts].Enabled = false; tabPage1.Controls.Add(freeSpace[dictionCounts]); y = y14 + 25; y2 = y + 25; y3 = y2 + 25; y4 = y3 + 25; y5 = y4 + 25; y6 = y5 + 25; y7 = y6 + 25; y8 = y7 + 25; y9 = y8 + 25; y10 = y9 + 25; y11 = y10 + 25; y12 = y11 + 25; y13 = y12 + 27; y14 = y13 + 25; dictionCounts++; } connect.Close();
Решение задачи: «Трудности при чтении из БД и скроллинге tabPage»
textual
Листинг программы
MySqlDataReader readedBrons; int dictionCounts = 1; int x = 31, y = 21,y2=46,y3=71,y4=96,y5=121,y6=146,y7=171,y8=196,y9=221,y10=246,y11=271,y12=296,y13=321,y14=346; Dictionary<int, Label> bronTitle = new Dictionary<int, Label>(); Dictionary<int, Label> bronInDate = new Dictionary<int, Label>(); Dictionary<int, Label> bronOutDate = new Dictionary<int, Label>(); Dictionary<int, Label> bronSurename = new Dictionary<int, Label>(); Dictionary<int, Label> bronName = new Dictionary<int, Label>(); Dictionary<int, Label> bronLastname = new Dictionary<int, Label>(); Dictionary<int, Label> bronPhone = new Dictionary<int, Label>(); Dictionary<int, Label> bronType = new Dictionary<int, Label>(); Dictionary<int, Label> bronDays = new Dictionary<int, Label>(); Dictionary<int, Label> bronPeoples = new Dictionary<int, Label>(); Dictionary<int, Label> bronPrice = new Dictionary<int, Label>(); Dictionary<int, Button> confirmButton = new Dictionary<int, Button>(); Dictionary<int, Button> borderLine = new Dictionary<int, Button>(); Dictionary<int, Button> freeSpace = new Dictionary<int, Button>(); connect.Open(); readedBrons = commandExecuteBrons.ExecuteReader(); while(readedBrons.Read()) { bronTitle[dictionCounts] = new Label(); bronTitle[dictionCounts].Location = new Point(x, y); bronTitle[dictionCounts].Font = new Font("Century Gothic", 10, FontStyle.Regular); bronTitle[dictionCounts].Text = "Номер: " + readedBrons["number"].ToString(); bronTitle[dictionCounts].AutoSize = true; tabPage1.Controls.Add(bronTitle[dictionCounts]); bronInDate[dictionCounts] = new Label(); bronInDate[dictionCounts].Location = new Point(x, y2); bronInDate[dictionCounts].Font = new Font("Century Gothic", 10, FontStyle.Regular); bronInDate[dictionCounts].Text = "Дата заезда: " + readedBrons["date1"].ToString(); bronInDate[dictionCounts].AutoSize = true; tabPage1.Controls.Add(bronInDate[dictionCounts]); bronOutDate[dictionCounts] = new Label(); bronOutDate[dictionCounts].Location = new Point(x, y3); bronOutDate[dictionCounts].Font = new Font("Century Gothic", 10, FontStyle.Regular); bronOutDate[dictionCounts].Text = "Дата выезда: " + readedBrons["date2"].ToString(); bronOutDate[dictionCounts].AutoSize = true; tabPage1.Controls.Add(bronOutDate[dictionCounts]); bronSurename[dictionCounts] = new Label(); bronSurename[dictionCounts].Location = new Point(x, y4); bronSurename[dictionCounts].Font = new Font("Century Gothic", 10, FontStyle.Regular); bronSurename[dictionCounts].Text = "Фамилия: " + readedBrons["surname"].ToString(); bronSurename[dictionCounts].AutoSize = true; tabPage1.Controls.Add(bronSurename[dictionCounts]); bronName[dictionCounts] = new Label(); bronName[dictionCounts].Location = new Point(x, y5); bronName[dictionCounts].Font = new Font("Century Gothic", 10, FontStyle.Regular); bronName[dictionCounts].Text = "Имя: " + readedBrons["name"].ToString(); bronName[dictionCounts].AutoSize = true; tabPage1.Controls.Add(bronName[dictionCounts]); bronLastname[dictionCounts] = new Label(); bronLastname[dictionCounts].Location = new Point(x, y6); bronLastname[dictionCounts].Font = new Font("Century Gothic", 10, FontStyle.Regular); bronLastname[dictionCounts].Text = "Отчество: " + readedBrons["lastname"].ToString(); bronLastname[dictionCounts].AutoSize = true; tabPage1.Controls.Add(bronLastname[dictionCounts]); bronPhone[dictionCounts] = new Label(); bronPhone[dictionCounts].Location = new Point(x, y7); bronPhone[dictionCounts].Font = new Font("Century Gothic", 10, FontStyle.Regular); bronPhone[dictionCounts].Text = "Телефон: " + readedBrons["phone"].ToString(); bronPhone[dictionCounts].AutoSize = true; tabPage1.Controls.Add(bronPhone[dictionCounts]); bronType[dictionCounts] = new Label(); bronType[dictionCounts].Location = new Point(x, y8); bronType[dictionCounts].Font = new Font("Century Gothic", 10, FontStyle.Regular); bronType[dictionCounts].Text = "Тип брони: " + readedBrons["brontype"].ToString(); bronType[dictionCounts].AutoSize = true; tabPage1.Controls.Add(bronType[dictionCounts]); bronDays[dictionCounts] = new Label(); bronDays[dictionCounts].Location = new Point(x, y9); bronDays[dictionCounts].Font = new Font("Century Gothic", 10, FontStyle.Regular); bronDays[dictionCounts].Text = "Количество дней: " + readedBrons["days"].ToString(); bronDays[dictionCounts].AutoSize = true; tabPage1.Controls.Add(bronDays[dictionCounts]); bronPeoples[dictionCounts] = new Label(); bronPeoples[dictionCounts].Location = new Point(x, y10); bronPeoples[dictionCounts].Font = new Font("Century Gothic", 10, FontStyle.Regular); bronPeoples[dictionCounts].Text = "Количество человек: " + readedBrons["peoples"].ToString(); bronPeoples[dictionCounts].AutoSize = true; tabPage1.Controls.Add(bronPeoples[dictionCounts]); bronPrice[dictionCounts] = new Label(); bronPrice[dictionCounts].Location = new Point(x, y11); bronPrice[dictionCounts].Font = new Font("Century Gothic", 10, FontStyle.Regular); bronPrice[dictionCounts].Text = "Цена: " + readedBrons["price"].ToString(); bronPrice[dictionCounts].AutoSize = true; tabPage1.Controls.Add(bronPrice[dictionCounts]); confirmButton[dictionCounts] = new Button(); confirmButton[dictionCounts].Parent = tabPage1; confirmButton[dictionCounts].Location = new Point(526, y12); confirmButton[dictionCounts].BackColor = Color.YellowGreen; confirmButton[dictionCounts].Width = 300; confirmButton[dictionCounts].Height = 30; confirmButton[dictionCounts].ForeColor = Color.Black; confirmButton[dictionCounts].Font = new Font("Century Gothic", 10, FontStyle.Regular); confirmButton[dictionCounts].Text = "Подтвердить бронь"; confirmButton[dictionCounts].FlatStyle = FlatStyle.Flat; confirmButton[dictionCounts].FlatAppearance.BorderSize = 0; confirmButton[dictionCounts].Cursor = Cursors.Hand; tabPage1.Controls.Add(confirmButton[dictionCounts]); borderLine[dictionCounts] = new Button(); borderLine[dictionCounts].Parent = tabPage1; borderLine[dictionCounts].Location = new Point(x, y13); borderLine[dictionCounts].BackColor = Color.YellowGreen; borderLine[dictionCounts].Width = 795; borderLine[dictionCounts].Height = 3; borderLine[dictionCounts].FlatStyle = FlatStyle.Flat; borderLine[dictionCounts].FlatAppearance.BorderSize = 0; tabPage1.Controls.Add(borderLine[dictionCounts]); freeSpace[dictionCounts] = new Button(); freeSpace[dictionCounts].Parent = tabPage1; freeSpace[dictionCounts].Location = new Point(x, y14); freeSpace[dictionCounts].BackColor = Color.Transparent; freeSpace[dictionCounts].Width = 795; freeSpace[dictionCounts].Height = 3; freeSpace[dictionCounts].FlatStyle = FlatStyle.Flat; freeSpace[dictionCounts].FlatAppearance.BorderSize = 0; freeSpace[dictionCounts].Enabled = false; tabPage1.Controls.Add(freeSpace[dictionCounts]); y = y14 + 25; y2 = y + 25; y3 = y2 + 25; y4 = y3 + 25; y5 = y4 + 25; y6 = y5 + 25; y7 = y6 + 25; y8 = y7 + 25; y9 = y8 + 25; y10 = y9 + 25; y11 = y10 + 25; y12 = y11 + 25; y13 = y12 + 27; y14 = y13 + 25; dictionCounts++; } connect.Close();
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д