12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Data.SqlClient;
- namespace testkonkurs1
- {
- public partial class Form3 : Form
- {
- public Form3()
- {
- InitializeComponent();
- }
- private void Form3_FormClosing(object sender, FormClosingEventArgs e)
- {
- Application.Exit();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- string connString = "Data Source=DESKTOP-Q8BTJMH;Initial Catalog=Testkonkurs;Integrated Security=True";
- SqlConnection conn = new SqlConnection(connString);
- SqlCommand command = new SqlCommand("SELECT * FROM bronirovanie", conn);
- conn.Open();
- SqlDataReader Reader = null;
- try{
- DateTime date_1start = dateTimePicker1.Value;
- DateTime date_1end = date_1start.AddDays(Convert.ToInt32(textBox1.Text));
- Reader = command.ExecuteReader();
- listBox1.Items.Clear();
- if(comboBox1.SelectedItem.ToString() == "1-комнатный")
- {
-
- }
- while (Reader.Read()) {
- DateTime date_2_start = Convert.ToDateTime(Reader["date_zaezda"]);
- DateTime date_2_end = date_2_start.AddDays(Convert.ToInt16(Reader["kol_days"]));
- // bool intersect = !(date_2_end < date_1start || date_2_start > date_1end);
- bool intersect = date_2_end >= date_1start && date_2_start <= date_1end;
- if (!intersect) {
-
- }
- }
-
-
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message.ToString(), "", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
- {
-
- }
- }
- }
|