Exemplo n.º 1
0
        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)
                                            {
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        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;
            }
        }
Exemplo n.º 3
0
 public void AddMyClass(random_client myclass)
 {
     rclientList.Add(myclass);
 }