Date.cs 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.Data.SqlClient;
  11. namespace NN_TelekomPP.Forms
  12. {
  13. public partial class Date : Form
  14. {
  15. DataBase dataBase = new DataBase();
  16. public Date()
  17. {
  18. InitializeComponent();
  19. }
  20. private void CreateColums()
  21. {
  22. dataGridView1.Columns.Add("id", "id");
  23. dataGridView1.Columns.Add("Name", "Название организации (абонента)");
  24. dataGridView1.Columns.Add("Number", "МГ1");
  25. dataGridView1.Columns.Add("Number", "МГ2");
  26. dataGridView1.Columns.Add("Number", "ДВО");
  27. dataGridView1.Columns.Add("Number", "Стоимость ДВО");
  28. dataGridView1.Columns.Add("Number", "Интернет");
  29. dataGridView1.Columns.Add("Number", "Стоимость интернета");
  30. dataGridView1.Columns.Add("Number", "Абонентский пакет");
  31. dataGridView1.Columns.Add("Number", "Стоимость абонентского пакета");
  32. dataGridView1.Columns.Add("IsNew", String.Empty);
  33. }
  34. private void ReadSingleRow(DataGridView dgw, IDataRecord record)
  35. {
  36. dgw.Rows.Add(record.GetInt32(0), record.GetString(1), record.GetDouble(2), record.GetDouble(3), record.GetString(4), record.GetDouble(5), record.GetString(6), record.GetDouble(7), record.GetString(8), record.GetDouble(9), RowState.ModifiedNew);
  37. }
  38. private void RefrashDataGrid(DataGridView dgw)
  39. {
  40. dgw.Rows.Clear();
  41. dataGridView1.Columns[0].Visible = false;
  42. dataGridView1.Columns[10].Visible = false;
  43. string querryString = $"select Calculation.Calculation_code,Organizations.Name, Calculation.MG_OSIPS, Calculation.MG_m200, ServicesADD.Name, ServicesADD.Cost, Internet.Name, Internet.Cost,SubscriptionFee.Name, SubscriptionFee.Cost from ADD_customers join Organizations on Organizations.Organizations_code=ADD_customers.Organizations_code join ServicesADD on ServicesADD.ServicesADD_code=ADD_customers.ServicesADD_code join Calculation on Calculation.Organizations_code=Organizations.Organizations_code join Services_customers on Services_customers.Organizations_code=Organizations.Organizations_code join Internet on Internet.Internet_code=Services_customers.Internet_code join SubscriptionFee on SubscriptionFee.AP_code=Services_customers.AP_code ";
  44. SqlCommand command = new SqlCommand(querryString, dataBase.GetConnection());
  45. dataBase.openConnection();
  46. SqlDataReader reader = command.ExecuteReader();
  47. while (reader.Read())
  48. {
  49. ReadSingleRow(dgw, reader);
  50. }
  51. reader.Close();
  52. }
  53. private void Date_Load(object sender, EventArgs e)
  54. {
  55. CreateColums();
  56. RefrashDataGrid(dataGridView1);
  57. }
  58. private void global_FormClosed(object sender, FormClosedEventArgs e)
  59. {
  60. Application.Exit();
  61. }
  62. private void button_back_Click(object sender, EventArgs e)
  63. {
  64. this.Hide();
  65. CalculetionForm M = new CalculetionForm();
  66. M.ShowDialog();
  67. }
  68. }
  69. }