private void ClearDGV() { dataGridView1.Rows.Clear(); if (File.Exists("orders.xml")) { try { orderlist.LoadList("orders.xml"); } catch (System.Exception ex) { File.Delete("orders.xml"); } ordering order = new ordering(); for (int i = 0; i < orderlist.coun(); i++) { order = orderlist.ReturnMyClass(i); if (order.boxname == tmpboxname) { dataGridView1.Rows.Add(order.startdate, order.enddate); } } } }
private DateTime return_end_time(int number) { boxlist.LoadList("boxes.xml"); boxes box = new boxes(); box = boxlist.ReturnMyClass(number); DateTime curr = DateTime.Now; DateTime rd = DateTime.Now; try { orderlist.LoadList("orders.xml"); } catch (System.Exception ex) { } ordering order = new ordering(); for (int i = 0; i < orderlist.coun(); i++) { order = orderlist.ReturnMyClass(i); if (order.boxname == box.box_number) { if (curr >= order.startdate && curr < order.enddate) { rd = order.enddate; } } } return rd; }
private bool proverka_future_busy(int number) { boxlist.LoadList("boxes.xml"); boxes box = new boxes(); box = boxlist.ReturnMyClass(number); if (File.Exists("orders.xml")) { try { orderlist.LoadList("orders.xml"); } catch (System.Exception ex) { } int flag = 0; ordering order = new ordering(); for (int i = 0; i < orderlist.coun(); i++) { order = orderlist.ReturnMyClass(i); if (order.boxname == box.box_number) flag = 1; } if (flag == 0) return false; else return true; } else return false; }
private void stripremoveclick(string str1, string str2, string str3) { if (File.Exists("boxes.xml")) { DialogResult dialogResult = MessageBox.Show("Вы точно хотите удалить эти данные из базы?", "Удаление данных", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dialogResult == DialogResult.Yes) { try { boxlist.LoadList("boxes.xml"); } catch (System.Exception ex) { Close(); } try { orderlist.LoadList("orders.xml"); } catch (System.Exception ex) { Close(); } string tmpboxname; DateTime currr; currr = DateTime.Now; if (radioButton1.Checked == true) { boxes box = new boxes(); box = boxlist.FindCLass(str1); tmpboxname = box.box_number; ordering norder = new ordering(); int fl = 999; for (int i = 0; i < orderlist.coun(); i++) { norder = orderlist.ReturnMyClass(i); if (norder.boxname == tmpboxname) { if (currr >= norder.startdate && currr <= norder.enddate) fl = i; } } norder = orderlist.ReturnMyClass(fl); orderlist.RemoveMyClass(tmpboxname, norder.enddate); orderlist.SaveList("orders.xml"); iRefreshForm(0); } else if (radioButton2.Checked == true) { boxes box = new boxes(); box = boxlist.FindCLass(str2); tmpboxname = box.box_number; ordering norder = new ordering(); int fl = 999; for (int i = 0; i < orderlist.coun(); i++) { norder = orderlist.ReturnMyClass(i); if (norder.boxname == tmpboxname) { if (currr >= norder.startdate && currr <= norder.enddate) fl = i; } } norder = orderlist.ReturnMyClass(fl); orderlist.RemoveMyClass(tmpboxname, norder.enddate); orderlist.SaveList("orders.xml"); iRefreshForm(12); } else if (radioButton3.Checked == true) { boxes box = new boxes(); box = boxlist.FindCLass(str3); tmpboxname = box.box_number; ordering norder = new ordering(); int fl = 999; for (int i = 0; i < orderlist.coun(); i++) { norder = orderlist.ReturnMyClass(i); if (norder.boxname == tmpboxname) { if (currr >= norder.startdate && currr <= norder.enddate) fl = i; } } norder = orderlist.ReturnMyClass(fl); orderlist.RemoveMyClass(tmpboxname, norder.enddate); orderlist.SaveList("orders.xml"); iRefreshForm(24); } } else if (dialogResult == DialogResult.No) { } } }
private void stripchangeclick(string str1, string str2, string str3) { if (File.Exists("boxes.xml")) { try { boxlist.LoadList("boxes.xml"); } catch (System.Exception ex) { Close(); } try { orderlist.LoadList("orders.xml"); } catch (System.Exception ex) { Close(); } string tmpboxname; DateTime currr; currr = DateTime.Now; if (radioButton1.Checked == true) { boxes box = new boxes(); box = boxlist.FindCLass(str1); tmpboxname = box.box_number; ordering norder = new ordering(); int fl = 999; for (int i = 0; i < orderlist.coun(); i++) { norder = orderlist.ReturnMyClass(i); if (norder.boxname == tmpboxname) { if (currr >= norder.startdate && currr <= norder.enddate) fl = i; } } norder = orderlist.ReturnMyClass(fl); edit_order edord = new edit_order(tmpboxname, norder.enddate); edord.ShowDialog(); iRefreshForm(0); } else if (radioButton2.Checked == true) { boxes box = new boxes(); box = boxlist.FindCLass(str2); tmpboxname = box.box_number; ordering norder = new ordering(); int fl = 999; for (int i = 0; i < orderlist.coun(); i++) { norder = orderlist.ReturnMyClass(i); if (norder.boxname == tmpboxname) { if (currr >= norder.startdate && currr <= norder.enddate) fl = i; } } norder = orderlist.ReturnMyClass(fl); edit_order edord = new edit_order(tmpboxname, norder.enddate); edord.ShowDialog(); iRefreshForm(12); } else if (radioButton3.Checked == true) { boxes box = new boxes(); box = boxlist.FindCLass(str3); tmpboxname = box.box_number; ordering norder = new ordering(); int fl = 999; for (int i = 0; i < orderlist.coun(); i++) { norder = orderlist.ReturnMyClass(i); if (norder.boxname == tmpboxname) { if (currr >= norder.startdate && currr <= norder.enddate) fl = i; } } norder = orderlist.ReturnMyClass(fl); edit_order edord = new edit_order(tmpboxname, norder.enddate); edord.ShowDialog(); iRefreshForm(24); } } }
private void scarlett_johansson() { if (File.Exists("orders.xml")) { try { boxlist.LoadList("boxes.xml"); } catch (System.Exception ex) { Close(); } boxes box = new boxes(); ordering order = new ordering(); DateTime currDateTime = DateTime.Now; for (int i = 0; i < boxlist.coun(); i++) { box = boxlist.ReturnMyClass(i); int flag = 0; try { orderlist.LoadList("orders.xml"); } catch (System.Exception ex) { Close(); } for (int j = 0; j < orderlist.coun(); j++) { order = orderlist.ReturnMyClass(j); if (box.box_number == order.boxname) { if (currDateTime >= order.startdate && currDateTime <= order.enddate) { box.box_status = "занят"; box.box_current_owner_login = order.box_owner_login; boxlist.RemoveMyClass(box.box_number); boxlist.AddMyClass(box); boxlist.SaveList("boxes.xml"); sortir(box.n); flag = 1; } if (currDateTime > order.enddate) { orderlist.RemoveMyClass(order.boxname, order.enddate); orderlist.SaveList("orders.xml"); } } } //конец фора по j if (flag == 0) { if (box.box_status != "свободен") { box.box_status = "свободен"; box.box_current_owner_login = "******"; boxlist.RemoveMyClass(box.box_number); boxlist.AddMyClass(box); boxlist.SaveList("boxes.xml"); sortir(box.n); } } } //конец фора по i } }
private void Init() { this.Text = "Редактирование записи об аренде - " + tmpboxname; label1.Text = "Место " + tmpboxname; try { orderlist.LoadList("orders.xml"); } catch (System.Exception ex) { } ordering order = new ordering(); order = orderlist.FindCLass(tmpboxname, tmpd2); if (order.box_owner_category == "Клиенты") comboBox1.SelectedIndex = 0; else comboBox1.SelectedIndex = 1; if (comboBox1.SelectedIndex == 0) { comboBox2.Items.Clear(); label3.Enabled = true; comboBox2.Enabled = true; textBox1.ReadOnly = true; textBox2.ReadOnly = true; textBox3.ReadOnly = true; richTextBox1.ReadOnly = true; textBox4.ReadOnly = true; textBox5.ReadOnly = true; if (File.Exists("clients.xml")) { try { clientlist.LoadList("clients.xml"); } catch (System.Exception ex) { Close(); } client obj = new client(); for (int i = 0; i < clientlist.coun(); i++) { obj = clientlist.ReturnMyClass(i); comboBox2.Items.Add(obj.login); } // obj = clientlist.FindCLass2(order.box_owner_login); comboBox2.Text = obj.login; textBox1.Text = obj.C_lastname; textBox2.Text = obj.C_name; textBox3.Text = obj.C_name_2; richTextBox1.Text = obj.kontakt; textBox4.Text = obj.auto_model; textBox5.Text = obj.auto_number; dateTimePicker1.Value = order.startdate; dateTimePicker3.Value = order.startdate; dateTimePicker2.Value = order.enddate; dateTimePicker4.Value = order.enddate; } } if (comboBox1.SelectedIndex == 1) { comboBox2.Items.Clear(); label3.Enabled = false; comboBox2.Enabled = false; textBox1.ReadOnly = false; textBox2.ReadOnly = false; textBox3.ReadOnly = false; richTextBox1.ReadOnly = false; textBox4.ReadOnly = false; textBox5.ReadOnly = false; textBox1.ResetText(); textBox2.ResetText(); textBox3.ResetText(); textBox4.ResetText(); textBox5.ResetText(); richTextBox1.ResetText(); // try { rclientlist.LoadList("rclients.xml"); } catch (System.Exception ex) { Close(); } random_client rcl = new random_client(); rcl = rclientlist.FindCLass(order.box_owner_login, order.box_owner_lastname); textBox1.Text = rcl.r_lastname; textBox2.Text = rcl.r_name; textBox3.Text = rcl.r_name_2; richTextBox1.Text = rcl.kontakt; textBox4.Text = rcl.auto_model; textBox5.Text = rcl.auto_number; dateTimePicker1.Value = order.startdate; dateTimePicker3.Value = order.startdate; dateTimePicker2.Value = order.enddate; dateTimePicker4.Value = order.enddate; } }
private void button1_Click(object sender, EventArgs e) { if (comboBox1.SelectedIndex == 0) { if (comboBox2.Text == "") { MessageBox.Show("Не выбран логин!", "Ошибка регистрации", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (textBox6.Text == "") { MessageBox.Show("Выберите дату окончания аренды!", "Ошибка регистрации", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { DateTime dt1, dt2; dt1 = dateTimePicker1.Value; dt2 = dateTimePicker2.Value; if (check_date(tmpboxname, dt1, dt2) == false) { MessageBox.Show("В выбранный период место уже занято!", "Ошибка регистрации", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { DialogResult dialogResult = MessageBox.Show("Сохранить изменения?", "Сохранение", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dialogResult == DialogResult.Yes) { try { clientlist.LoadList("clients.xml"); } catch (System.Exception ex) { File.Delete("clients.xml"); } try { boxlist.LoadList("boxes.xml"); } catch (System.Exception ex) { File.Delete("boxes.xml"); } try { cashlist.LoadList("cash.xml"); } catch (System.Exception ex) { File.Delete("cash.xml"); } try { orderlist.LoadList("orders.xml"); } catch (System.Exception ex) { File.Delete("orders.xml"); } client nclient = new client(); nclient = clientlist.FindCLass2(comboBox2.Text); ordering order = new ordering(); order.boxname = tmpboxname; order.box_owner_category = nclient.category; order.box_owner_lastname = nclient.C_lastname; order.box_owner_name = nclient.C_name; order.box_owner_kontakt = nclient.kontakt; order.box_owner_login = nclient.login; order.startdate = dateTimePicker1.Value; order.enddate = dateTimePicker2.Value; cash money = new cash(); money.date = DateTime.Now.ToShortDateString(); money.category = nclient.category; money.c_lastname = nclient.C_lastname; money.c_name = nclient.C_name; money.box = tmpboxname; money.c_value = Convert.ToDouble(textBox7.Text); //save cashlist.AddMyClass(money); cashlist.SaveList("cash.xml"); orderlist.RemoveMyClass(tmpboxname, tmpd2); orderlist.AddMyClass(order); orderlist.SaveList("orders.xml"); Close(); } else if (dialogResult == DialogResult.No) { } } } } } else if (comboBox1.SelectedIndex == 1) { if (textBox1.Text == "") { MessageBox.Show("Не заполнено поле Фамилия!", "Ошибка регистрации", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (textBox2.Text == "") { MessageBox.Show("Не заполнено поле Имя!", "Ошибка регистрации", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (richTextBox1.Text == "") { MessageBox.Show("Не заполнено поле Контактная информация!", "Ошибка регистрации", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (textBox4.Text == "") { MessageBox.Show("Не заполнено поле Модель транспортного средства!", "Ошибка регистрации", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (textBox5.Text == "") { MessageBox.Show("Не заполнено поле Номер транспортного средства!", "Ошибка регистрации", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (textBox6.Text == "") { MessageBox.Show("Выберите дату окончания аренды!", "Ошибка регистрации", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { DateTime dt1, dt2; dt1 = dateTimePicker1.Value; dt2 = dateTimePicker2.Value; if (check_date(tmpboxname, dt1, dt2) == false) { MessageBox.Show("В выбранный период место уже занято!", "Ошибка регистрации", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { DialogResult dialogResult = MessageBox.Show("Сохранить запись?", "Сохранение", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dialogResult == DialogResult.Yes) { //не забыть исправить 4 на 1)) //написать проверку на существование файл, защиту от дурака, сохранить все в файл, запилить кэш, запилить занятость, запилить освобождение по времени, все, я спаааааать try { rclientlist.LoadList("rclients.xml"); } catch (System.Exception ex) { File.Delete("rclients.xml"); } try { boxlist.LoadList("boxes.xml"); } catch (System.Exception ex) { File.Delete("boxes.xml"); } try { cashlist.LoadList("cash.xml"); } catch (System.Exception ex) { File.Delete("cash.xml"); } try { orderlist.LoadList("orders.xml"); } catch (System.Exception ex) { File.Delete("orders.xml"); } random_client rcl = new random_client(); rcl.category = "Незарегистрированный"; rcl.r_lastname = textBox1.Text; rcl.r_name = textBox2.Text; if (textBox3.Text == "") rcl.r_name_2 = "-"; else rcl.r_name_2 = textBox3.Text; rcl.kontakt = richTextBox1.Text; rcl.auto_model = textBox4.Text; rcl.auto_number = textBox5.Text; rcl.box = tmpboxname; rcl.d1 = dateTimePicker1.Value; rcl.d2 = dateTimePicker2.Value; ordering order = new ordering(); order.boxname = tmpboxname; order.box_owner_category = rcl.category; order.box_owner_lastname = rcl.r_lastname; order.box_owner_name = rcl.r_name; order.box_owner_kontakt = rcl.kontakt; order.box_owner_login = rcl.auto_number; order.startdate = dateTimePicker1.Value; order.enddate = dateTimePicker2.Value; cash money = new cash(); money.date = DateTime.Now.ToShortDateString(); money.category = rcl.category; money.c_lastname = rcl.r_lastname; money.c_name = rcl.r_name; money.box = tmpboxname; money.c_value = Convert.ToDouble(textBox7.Text); //save cashlist.AddMyClass(money); cashlist.SaveList("cash.xml"); orderlist.RemoveMyClass(tmpboxname, tmpd2); orderlist.AddMyClass(order); orderlist.SaveList("orders.xml"); rclientlist.AddMyClass(rcl); rclientlist.SaveList("rclients.xml"); Close(); } else if (dialogResult == DialogResult.No) { } } } } } } } } } }
private bool check_date(string str, DateTime dat1, DateTime dat2) { if (File.Exists("orders.xml")) { try { orderlist.LoadList("orders.xml"); } catch (System.Exception ex) { Close(); } int flag = 0; ordering order = new ordering(); ordering order2 = new ordering(); order2 = orderlist.FindCLass(tmpboxname, tmpd2); for (int i = 0; i < orderlist.coun(); i++) { order = orderlist.ReturnMyClass(i); if (order.Equals(order2) == false) { if (order.boxname == str) { if (dat1 >= order.startdate && dat1 <= order.enddate) flag = 1; if (dat2 >= order.startdate && dat2 <= order.enddate) flag = 1; if (dat1 < order.startdate && dat2 >= order.startdate && dat2 <= order.enddate) flag = 1; if (dat1 < order.startdate && order.enddate <= dat2) flag = 1; } } } if (flag == 0) return true; else return false; } else return true; }
private void Init() { this.Text = "Информация о стояночном месте - " + tmpboxname; this.label2.Text = "Место " + tmpboxname; if (File.Exists("orders.xml")) { try { orderlist.LoadList("orders.xml"); } catch (System.Exception ex) { File.Delete("orders.xml"); } try { boxlist.LoadList("boxes.xml"); } catch (System.Exception ex) { File.Delete("boxes.xml"); } boxes box = new boxes(); box = boxlist.FindCLass(tmpboxname); if (box.box_status == "свободен") { empty(); } else { DateTime d1; d1 = DateTime.Now; ordering order = new ordering(); for (int i = 0; i < orderlist.coun(); i++) { order = orderlist.ReturnMyClass(i); if (order.boxname == tmpboxname) { if (d1 >= order.startdate && d1 <= order.enddate) { textBox1.Text = "занят"; dateTimePicker2.Value = order.enddate; dateTimePicker3.Value = order.enddate; } } } } } else empty(); }
public void AddMyClass(ordering myclass) { orderingList.Add(myclass); }
private void button1_Click(object sender, EventArgs e) { if (textBox6.Text == "") { MessageBox.Show("Выберите дату окончания аренды!", "Ошибка регистрации", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { DateTime dt1, dt2; dt1 = dateTimePicker1.Value; dt2 = dateTimePicker2.Value; if (check_date(tmpboxname, dt1, dt2) == false) { MessageBox.Show("В выбранный период место уже занято!", "Ошибка регистрации", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (textBox1.Text == "") { MessageBox.Show("Введите номер кредитной карты!", "Ошибка регистрации", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (textBox2.Text == "") { MessageBox.Show("Введите PIN-код карты!", "Ошибка регистрации", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { DialogResult dialogResult = MessageBox.Show("Сохранить запись?", "Сохранение", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dialogResult == DialogResult.Yes) { try { clientlist.LoadList("clients.xml"); } catch (System.Exception ex) { File.Delete("clients.xml"); } try { boxlist.LoadList("boxes.xml"); } catch (System.Exception ex) { File.Delete("boxes.xml"); } try { orderlist.LoadList("orders.xml"); } catch (System.Exception ex) { File.Delete("orders.xml"); } client nclient = new client(); nclient = clientlist.FindCLass2(tmpusername); ordering order = new ordering(); order.boxname = tmpboxname; order.box_owner_category = nclient.category; order.box_owner_lastname = nclient.C_lastname; order.box_owner_name = nclient.C_name; order.box_owner_kontakt = nclient.kontakt; order.box_owner_login = nclient.login; order.startdate = dateTimePicker1.Value; order.enddate = dateTimePicker2.Value; orderlist.AddMyClass(order); orderlist.SaveList("orders.xml"); Close(); } else if (dialogResult == DialogResult.No) { } } } } } }