Ejemplo n.º 1
0
        private void CheckOut_Click(object sender, EventArgs e)
        {
            if (HostelAd.Text == "")
            {
                MessageBox.Show("Вы не сможете выселять постояльцев гостиницы, так как вы к ней не привязаны");
                return;
            }
            Updating(sender, e);
            CheckInHostel checkInHostel = new CheckInHostel();

            checkInHostel.advancedDataGridView1.Columns[7].Visible = false;
            checkInHostel.Text        = "Выселение";
            checkInHostel.label1.Text = "Отмеченные к выселению постояльцы";
            if (checkInHostel.ShowDialog() == DialogResult.OK)
            {
                for (int i = 0; i < GridGuests.Rows.Count; i++)
                {
                    if ((bool)GridGuests[0, i].Value == true && (bool)GridGuests[10, i].Value == false)
                    {
                        MessageBox.Show("Вы не можете выселить постояльцев, если они еще не были заселены");
                        return;
                    }
                }
                for (int i = 0; i < GridGuests.Rows.Count; i++)
                {
                    if ((bool)GridGuests[0, i].Value == true)
                    {
                        NotStated(i);
                    }
                }

                string fileName = null;
                using (FolderBrowserDialog saveFileDialog = new FolderBrowserDialog())
                {
                    if (saveFileDialog.ShowDialog() == DialogResult.OK)
                    {
                        string path = saveFileDialog.SelectedPath;
                        for (int i = 0; i < checkInHostel.advancedDataGridView1.Rows.Count; i++)
                        {
                            fileName = checkInHostel.advancedDataGridView1[0, i].Value.ToString() + " "
                                       + checkInHostel.advancedDataGridView1[1, i].Value.ToString() + " "
                                       + checkInHostel.advancedDataGridView1[2, i].Value.ToString();
                            FileStream fileStream = File.Create(path + "\\" + "ВЫСЕЛЕНИЕ." + fileName + ".txt");
                            //fileStream.Close();
                            string Zasel = "Выселение\nПостоялец " + fileName + "\nГостиница " + HostelAd.Text + "\nНомер гостиницы " + checkInHostel.advancedDataGridView1[7, i].FormattedValue.ToString() + "\nАдминистратор " + Admin.Text + "\nДата выселения " + DateTime.Today.ToShortDateString();
                            byte[] info  = new UTF8Encoding(true).GetBytes(Zasel);
                            fileStream.Write(info, 0, info.Length);
                            fileStream.Close();
                            //StreamWriter streamWriter = new StreamWriter(path + "\\" + fileName+".txt");
                            //streamWriter.Write("Заселение");
                            //streamWriter.WriteLine("Постоялец "+fileName);
                            //streamWriter.WriteLine("Гостиница "+HostelAd.Text);
                            //streamWriter.WriteLine("Номер "+checkInHostel.advancedDataGridView1[7,i].Value.ToString());
                            //streamWriter.WriteLine("Администратор"+Admin.Text);
                            //streamWriter.WriteLine("Дата заселения "+DateTime.Today.ToString());
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void Incrementnumber(int index, int number, CheckInHostel checkInHostel)
        {
            OleDbConnection sql_conn = new OleDbConnection(ConnectionString);

            string Up_to_Date = "Update Guests Set Заселен = true, [Число заселений]=[Число заселений]+1," + " [Номер заселения]=" + GridHostel[1, number].Value + " Where [Паспортные данные]='" + checkInHostel.advancedDataGridView1[6, index].Value + "' And Гостиница=" + HostelAd.Text;

            OleDbCommand sql_comm = new OleDbCommand(Up_to_Date, sql_conn);

            sql_conn.Open();
            sql_comm.ExecuteNonQuery();
            // checkInHostel.dataBaseDataSet4.Guests.AcceptChanges();

            sql_conn.Close();
            ShowGuests();
        }
Ejemplo n.º 3
0
        private void CheckIn_Click(object sender, EventArgs e)
        {
            if (HostelAd.Text == "")
            {
                MessageBox.Show("Вы не сможете заселять постояльцев гостиницы, так как вы к ней не привязаны");
                return;
            }
            Updating(sender, e);
            CheckInHostel checkInHostel = new CheckInHostel();

            checkInHostel.Host = Convert.ToInt32(HostelAd.Text);
            // checkInHostel.CheckInHostel_Load(sender,e);
            // string Guests = "Select Фамилия, Имя, Отчество, [Дата рождения], Пол, [Номер телефона], [Паспортные данные] From Guests Where IsChecked=true";
            //checkInHostel.ShowGuests(Guests);
            // checkInHostel.GridCheckIn=checkInHostel.ShowChecked(GridGuests);

            if (checkInHostel.ShowDialog() == DialogResult.OK)
            {
                //string put = "Сохранить здесь";
                string fileName = null;
                //bool b = false;
                for (int i = 0; i < GridHostel.Rows.Count; i++)
                {
                    for (int j = 0; j < checkInHostel.advancedDataGridView1.Rows.Count; j++)
                    {
                        if (GridHostel[1, i].Value == checkInHostel.advancedDataGridView1[7, j].Value && (bool)GridHostel[6, i].Value == true)
                        {
                            MessageBox.Show("Невозможно заселить постояльцев, так как номер уже занят");
                            //        b = true;
                            return;
                        }
                    }

                    for (int j = 0; j < checkInHostel.advancedDataGridView1.Rows.Count; j++)
                    {
                        if (GridHostel[1, i].Value.ToString() == (string)checkInHostel.advancedDataGridView1[7, j].EditedFormattedValue && (bool)GridHostel[6, i].Value != true)
                        {
                            ZaselTr(i);
                            Incrementnumber(j, i, checkInHostel);
                        }
                    }
                    //  if (b) break;
                }

                //if (b) return;
                //{ Filter = "Word (*.doc;*.docx;*.txt;*.rtf)|*.doc;*.docx;*.txt;*.rtf|All files (*.*)|*.*" }
                using (FolderBrowserDialog saveFileDialog = new FolderBrowserDialog())
                {
                    if (saveFileDialog.ShowDialog() == DialogResult.OK)
                    {
                        string path = saveFileDialog.SelectedPath;
                        for (int i = 0; i < checkInHostel.advancedDataGridView1.Rows.Count; i++)
                        {
                            fileName = checkInHostel.advancedDataGridView1[0, i].Value.ToString() + " "
                                       + checkInHostel.advancedDataGridView1[1, i].Value.ToString() + " "
                                       + checkInHostel.advancedDataGridView1[2, i].Value.ToString();
                            FileStream fileStream = File.Create(path + "\\" + "ЗАСЕЛЕНИЕ." + fileName + ".txt");
                            //fileStream.Close();
                            string Zasel = "Заселение\nПостоялец " + fileName + "\nГостиница " + HostelAd.Text + "\nНомер гостиницы " + checkInHostel.advancedDataGridView1[7, i].FormattedValue.ToString() + "\nАдминистратор " + Admin.Text + "\nДата заселения " + DateTime.Today.ToShortDateString();
                            byte[] info  = new UTF8Encoding(true).GetBytes(Zasel);
                            fileStream.Write(info, 0, info.Length);
                            fileStream.Close();
                            //StreamWriter streamWriter = new StreamWriter(path + "\\" + fileName+".txt");
                            //streamWriter.Write("Заселение");
                            //streamWriter.WriteLine("Постоялец "+fileName);
                            //streamWriter.WriteLine("Гостиница "+HostelAd.Text);
                            //streamWriter.WriteLine("Номер "+checkInHostel.advancedDataGridView1[7,i].Value.ToString());
                            //streamWriter.WriteLine("Администратор"+Admin.Text);
                            //streamWriter.WriteLine("Дата заселения "+DateTime.Today.ToString());
                        }
                    }
                }
            }
        }