Пример #1
0
 public void fillgrid(SqlCommand command)
 {
     dataGridView1.ReadOnly           = true;
     dataGridView1.RowTemplate.Height = 20;
     dataGridView1.DataSource         = phong.getshowkh(command);
     dataGridView1.AllowUserToAddRows = false;
 }
Пример #2
0
        private void BaoCaoThang_Load(object sender, EventArgs e)
        {
            Phong      phong   = new Phong();
            SqlCommand command = new SqlCommand("Select * from BaoCaoLuong ");

            dataGridView1.ReadOnly = true;

            dataGridView1.DataSource = phong.getshowkh(command);

            dataGridView1.AllowUserToAddRows = false;
        }
Пример #3
0
        private void QuanLyPhong_Load(object sender, EventArgs e)
        {
            Phong      phong   = new Phong();
            SqlCommand command = new SqlCommand("Select TenPhong,TrangThai,MKPhong from TTPhong ");

            dataGridView1.ReadOnly = true;

            dataGridView1.DataSource = phong.getshowkh(command);

            dataGridView1.AllowUserToAddRows = false;
        }
Пример #4
0
        private void BaoCao_Load(object sender, EventArgs e)
        {
            Phong      phong   = new Phong();
            SqlCommand command = new SqlCommand("Select Id,HoTen,GioBD,GioKT,ChucVu,CaLamViec from BaoCaoNgay");

            dataGridView1.ReadOnly = true;

            dataGridView1.DataSource = phong.getshowkh(command);

            dataGridView1.AllowUserToAddRows = false;
        }
Пример #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            Phong      phong   = new Phong();
            LuongNV    nv      = new LuongNV();
            SqlCommand command = new SqlCommand("Select HoTen,ChucVu,sum(Luong) as Luong from BaoCaoLuong where convert(char(7), GioKT,21)='2019-" + textBox1.Text + "' group by HoTen,ChucVu");

            nv.dataGridViewLuong.ReadOnly = true;

            nv.dataGridViewLuong.DataSource = phong.getshowkh(command);

            nv.dataGridViewLuong.AllowUserToAddRows = false;
            this.Close();
            nv.Show();
        }
Пример #6
0
        private void TrPhong_Load(object sender, EventArgs e)
        {
            Phong      phong   = new Phong();
            SqlCommand command = new SqlCommand("Select * from TTKH ");

            dataGridViewKH.ReadOnly = true;

            dataGridViewKH.DataSource = phong.getshowkh(command);

            dataGridViewKH.AllowUserToAddRows = false;
            comboBox1.DataSource    = phong.getAllTraPhong();;
            comboBox1.DisplayMember = "MaKH";
            comboBox1.ValueMember   = "MaKH";
            comboBox1.SelectedItem  = null;
        }
Пример #7
0
        private void NhanVienLeTan_Load(object sender, EventArgs e)
        {
            Phong      phong   = new Phong();
            string     cv      = "LeTan    ";
            SqlCommand command = new SqlCommand("SELECT * FROM TTNV as a,Login as b where b.ChucVu like '" + cv + "%' and a.IdNhanVien = b.Id ");

            dataGridViewManagerStudent.ReadOnly = true;

            dataGridViewManagerStudent.DataSource = phong.getshowkh(command);

            dataGridViewManagerStudent.AllowUserToAddRows = false;
            ComboBoxCaDK.DataSource    = NhanVien.getAllCalam();
            ComboBoxCaDK.DisplayMember = "CaLamViec";
            ComboBoxCaDK.ValueMember   = "CaLamViec";
            ComboBoxCaDK.SelectedItem  = null;
        }
Пример #8
0
        private void ThongTinPhong_Load(object sender, EventArgs e)
        {
            Phong      phong   = new Phong();
            SqlCommand command = new SqlCommand("Select * from ChiTietPhong ");

            dataGridView1.ReadOnly = true;

            dataGridView1.DataSource = phong.getshowkh(command);

            dataGridView1.AllowUserToAddRows = false;

            comboBoxRoomName.DataSource    = phong.getDatPhong();
            comboBoxRoomName.DisplayMember = "TenPhong";
            comboBoxRoomName.ValueMember   = "MaPhong";
            comboBoxRoomName.SelectedItem  = null;
        }
Пример #9
0
        private void Button1_Click(object sender, EventArgs e)
        {
            if ((TextBoxMaKH.Text.Trim() == ""))
            {
                MessageBox.Show("NhapID", " Add ", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                string   id     = TextBoxMaKH.Text;
                string   name   = TextBoxNameKH.Text;
                DateTime datebd = DatetimeBD.Value;
                string   phone  = TextBoxPhone.Text;
                string   adrs   = TextBoxDC.Text;
                string   LBGT   = "Male";
                int      mk;
                string   TPhong = ComboBoxPhong.SelectedValue.ToString();
                if (radioButtonFemale.Checked)
                {
                    LBGT = "Female";
                }
                MemoryStream pic      = new MemoryStream();
                SqlCommand   command5 = new SqlCommand("Select MKPhong From TTPhong where MaPhong  like'" + TPhong + "%'");
                DataTable    table5   = phong.getshowkh(command5);
                mk = (int)table5.Rows[0]["MKPhong"];
                if (verif())
                {
                    pictureBox1.Image.Save(pic, pictureBox1.Image.RawFormat);
                    if (phong.insertPhong(id, name, LBGT, adrs, phone, TPhong, datebd, pic))
                    {
                        phong.updateTPhong(TPhong);
                        phong.insertKHForQL(id, name, LBGT, adrs, phone, TPhong, datebd, pic);
                        MessageBox.Show("Thành Công", "Thêm Khách Hàng", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        MessageBox.Show("Mật Khẩu Phòng là: " + mk, "Thêm Khách Hàng", MessageBoxButtons.OK);

                        Close();
                    }
                    else
                    {
                        MessageBox.Show("Thất Bại", "Thêm Khách Hàng", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show("Thiếu gì đó", "Thêm Khách Hàng", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }
Пример #10
0
        private void buttonTraPhong_Click(object sender, EventArgs e)
        {
            int      Coca   = (int)numericUpDownCOCA.Value;
            int      Tiger  = (int)numericUpDownTiger.Value;
            int      Ruou   = (int)numericUpDownRuou.Value;
            int      Mi     = (int)numericUpDownMi.Value;
            int      Snack  = (int)numericUpDownSncack.Value;
            DateTime NgayKT = DateTime.Now;
            int      day    = NgayKT.Day;
            int      month  = NgayKT.Month;
            int      year   = NgayKT.Year;

            string   MAKhach = comboBox1.SelectedValue.ToString();
            DateTime NgayBD;
            string   MaPhong;
            int      tonggio;
            int      tongngay;
            int      vp1;
            int      vp2;
            int      vp3;
            int      vp4;
            int      vp5;
            string   tenPhong;
            string   TenKhang;
            string   DC;
            string   DT;
            string   GT;
            string   TP;
            Random   rb = new Random();
            int      mk = rb.Next(1, 99);
            //
            SqlCommand command5 = new SqlCommand("Select TenKH From TTKH where MaKH like '" + MAKhach + "%'");
            DataTable  table5   = phong.getshowkh(command5);

            TenKhang = (string)table5.Rows[0]["TenKH"];
            SqlCommand command6 = new SqlCommand("Select GioiTinh From TTKH where MaKH like '" + MAKhach + "%'");
            DataTable  table6   = phong.getshowkh(command6);

            GT = (string)table6.Rows[0]["GioiTinh"];
            SqlCommand command7 = new SqlCommand("Select DiaChi From TTKH where MaKH like '" + MAKhach + "%'");
            DataTable  table7   = phong.getshowkh(command7);

            DC = (string)table7.Rows[0]["DiaChi"];
            SqlCommand command8 = new SqlCommand("Select DienThoai From TTKH where MaKH like '" + MAKhach + "%'");
            DataTable  table8   = phong.getshowkh(command8);

            DT = (string)table8.Rows[0]["DienThoai"];
            SqlCommand command9 = new SqlCommand("Select ThuePhong From TTKH where MaKH like '" + MAKhach + "%'");
            DataTable  table9   = phong.getshowkh(command9);

            TP = (string)table9.Rows[0]["ThuePhong"];
            //
            SqlCommand command1 = new SqlCommand("Select NgayBatDau From TTKH where MaKH like '" + MAKhach + "%'");
            DataTable  table1   = phong.getshowkh(command1);

            NgayBD = (DateTime)table1.Rows[0]["NgayBatDau"];
            SqlCommand command2 = new SqlCommand("Select ThuePhong From TTKH ");
            DataTable  table2   = phong.getshowkh(command2);

            MaPhong = table2.Rows[0]["ThuePhong"].ToString();
            SqlCommand command4 = new SqlCommand("Select * From ChiTietPhong where MaPhong like '" + MaPhong + "%'");
            DataTable  table4   = phong.getshowkh(command4);

            vp1      = (int)table4.Rows[0]["VatPham1"];
            vp2      = (int)table4.Rows[0]["VatPham2"];
            vp3      = (int)table4.Rows[0]["VatPham3"];
            vp4      = (int)table4.Rows[0]["VatPham4"];
            vp5      = (int)table4.Rows[0]["VatPham5"];
            tenPhong = table4.Rows[0]["TenPhong"].ToString();
            SqlDataAdapter adapter1 = new SqlDataAdapter();
            DataTable      table3   = new DataTable();
            SqlCommand     command3 = new SqlCommand("Select * From TTKH WHERE @MA = MaKH", mydb.GetConnection);

            command3.Parameters.Add("@MA", SqlDbType.VarChar).Value = MAKhach;
            adapter1.SelectCommand = command3;
            adapter1.Fill(table3);
            TimeSpan tn = NgayKT - NgayBD;
            HoaDon   hd = new HoaDon();

            if (Coca <= vp1 && Tiger <= vp2 && Snack <= vp3 && Ruou <= vp4 && Mi <= vp5)
            {
                vp1            = vp1 - Coca;
                vp2            = vp2 - Tiger;
                vp3            = vp3 - Snack;
                vp4            = vp4 - Ruou;
                vp5            = vp5 - Mi;
                labelgio.Text  = Convert.ToString(tn.Hours) + "  Gio";
                labelNgay.Text = Convert.ToString(tn.Days) + "  Ngay";
                labelTien.Text = Convert.ToString((tn.Days * 1000000) + (tn.Hours * (1000000 / 24)) + (Coca * 15000 + Snack * 10000 + Ruou * 200000 + Tiger * 20000 + Mi * 10000)) + "  VNĐ";
                int ThuNhap = Convert.ToInt32((tn.Days * 1000000) + (tn.Hours * (1000000 / 24)) + (Coca * 15000 + Snack * 10000 + Ruou * 200000 + Tiger * 20000 + Mi * 10000));
                if (table3.Rows.Count <= 0)
                {
                    MessageBox.Show("MA KHACH HANG CHUA DUOC DAT PHONG", " nhap lai", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else if (phong.updateTraPhong(MaPhong, mk))
                {
                    SqlDataAdapter adapter = new SqlDataAdapter();
                    DataTable      table   = new DataTable();
                    SqlCommand     command = new SqlCommand("Select * From TTKH WHERE @MA = MaKH", mydb.GetConnection);
                    command.Parameters.Add("@MA", SqlDbType.VarChar).Value = MAKhach;
                    adapter.SelectCommand = command;
                    adapter.Fill(table);
                    fillgrid(command);
                    if (phong.updateNGayKT(MAKhach, NgayKT))
                    {
                        Global.SetGlobalUserId2(MAKhach);
                        phong.insertThuNhap(NgayKT, ThuNhap);
                        phong.updateNGayKTForQL(MAKhach, NgayKT);
                        phong.updateChitietPhong(MaPhong, tenPhong, vp1, vp2, vp3, vp4, vp5);


                        hd.TextBoxMaKHHD.Text   = MAKhach;
                        hd.TextBoxNameKHHD.Text = TenKhang;
                        hd.TextBoxPhoneHD.Text  = DT;
                        if (GT == "Female")
                        {
                            hd.radioButtonFemaleHD.Checked = true;
                        }
                        else
                        {
                            hd.radioButtonMaleHD.Checked = true;
                        }
                        hd.TextBoxTPHD.Text   = TP;
                        hd.TextBoxDCHD.Text   = DC;
                        hd.DatetimeNPHD.Value = NgayBD;
                        hd.DatetimeTPHD.Value = NgayKT;
                        hd.labelcoca.Text     = "CoCaCoLa(15k/1): " + Convert.ToString(Coca);
                        hd.labelTB.Text       = "Tiger Beer(20k/1): " + Convert.ToString(Coca);
                        hd.labels.Text        = "Snack (10k/1): " + Convert.ToString(Snack);
                        hd.labelVK.Text       = "Vodka (200k/1): " + Convert.ToString(Ruou);
                        hd.labelN.Text        = "Noodles(10k/1): " + Convert.ToString(Mi);
                        hd.labeltien.Text     = Convert.ToString((tn.Days * 1000000) + (tn.Hours * (1000000 / 24)) + (Coca * 15000 + Snack * 10000 + Ruou * 200000 + Tiger * 20000 + Mi * 10000)) + "  VNĐ";
                        hd.labelgio.Text      = Convert.ToString(tn.Hours) + "  Gio";
                        hd.labelngay.Text     = Convert.ToString(tn.Days) + "  Ngay";
                        this.Close();
                        hd.Show();
                    }
                    else
                    {
                        MessageBox.Show("Lỗi Update", "Trả Phong", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show("Emty fields", " Thue Phong ", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            else
            {
                MessageBox.Show("So Luonng Vat Pham Nhap Vao La Sai Lech So Voi Vat Pham Trong Phong", " Nhap Lai ", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }