コード例 #1
0
            public void Test_NhapTGThueKPhaiDangSo()
            {
                bool actual   = KTbangKH.kt_nhapTGThue("hai");
                bool expected = false;

                Assert.AreEqual(expected, actual);
            }
コード例 #2
0
        public void Test_KhongNhapTenKH()
        {
            bool actual   = KTbangKH.kt_ThemKhachBoTrongTenKH("");
            bool expected = false;

            Assert.AreEqual(expected, actual);
        }
コード例 #3
0
        public void Test_trungmaKH()
        {
            bool actual   = KTbangKH.kt_trungmaKH("KH001");
            bool expected = false;

            Assert.AreEqual(expected, actual);
        }
コード例 #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            string luutru = maluutru();
            int    tuoi, phongdon, phongdoi, thue;

            KTbangKH.kt_ThemKhachBoTrongMaKH(tmakhach.Text);
            //if (tmakhach.Text == "")
            //    MessageBox.Show("Hãy nhập vào mã khách hàng", "Chú ý");

            //if (tcheckin.Text == "")
            //    MessageBox.Show("Hãy nhập vào mã check in", "Chú ý");

            //if (ttenkhach.Text == "")
            //    MessageBox.Show("Hãy nhập vào tên khách hàng", "Chú ý");


            //bool kttuoi = KTbangKH.kt_nhaptuoi(ttuoi.Text);
            //if (kttuoi == false)
            //{
            //    MessageBox.Show("Nhập tuổi dạng số!", "Chú ý");

            //}


            //KTbangKH.kt_nhaptuoi(ttuoi.Text);
            //if (KTbangKH.kt_nhaptuoi(ttuoi.Text) == true)
            //{
            //    MessageBox.Show("Nhập tuổi đúng dạng số!", "Chú ý");

            //}
            if (ttuoi.Text == "")
            {
                tuoi = 0;
            }
            else
            {
                tuoi = Convert.ToInt16(ttuoi.Text);
            }


            bool ktphongDoi = KTbangKH.kt_nhapSoPhongDoi(tphongdoi.Text);

            if (ktphongDoi == true)
            {
                MessageBox.Show("Nhập số phòng đôi dạng số!", "Chú ý");
            }
            ;

            if (tphongdoi.Text == "")
            {
                phongdoi = 0;
            }
            else
            {
                phongdoi = Convert.ToInt16(tphongdoi.Text);
            }


            bool ktphongDon = KTbangKH.kt_nhapSoPhongDon(tphongdon.Text);

            if (ktphongDon == true)
            {
                MessageBox.Show("Nhập số phòng đơn dạng số!", "Chú ý");
            }
            ;
            if (tphongdon.Text == "")
            {
                phongdon = 0;
            }
            else
            {
                phongdon = Convert.ToInt16(tphongdon.Text);
            }


            bool ktTGthue = KTbangKH.kt_nhapTGThue(ttgianthue.Text);

            if (ktTGthue == true)
            {
                MessageBox.Show("Nhập số ngày thuê dạng số!", "Chú ý");
            }
            ;
            if (ttgianthue.Text == "")
            {
                thue = 0;
            }
            else
            {
                thue = Convert.ToInt16(ttgianthue.Text);
            }

            //bool ktmakhach = KTbangKH.kt_trungmaKH(tmakhach.Text);
            //bool ktmacheckin = KTbangCheckin.kt_trungmacheckin(tcheckin.Text);
            //bool kttuoi = KTbangKH.kt_nhaptuoi(ttuoi.Text);
            //bool ktkhongtenKH = KTbangKH.kt_ThemKhachBoTrongTenKH(ttenkhach.Text);
            //bool ktkhongmacheckin = KTbangCheckin.kt_ThemKhachBoTrongMacheckin(tcheckin.Text);
            //if ((ktmakhach == false) || (ktmacheckin == false) || (kttuoi == false) || (ktkhongmacheckin == false))
            //    ketnoi.HuyKetNoi();

            try
            {
                string strcom1 = "insert into khachhang values(" + "'" + tmakhach.Text + "'," + "'" + ttenkhach.Text + "'," + tuoi + "," + "'" + tam + "'," + "'" + tquoctich.Text + "'," + "'" + tcmnd.Text + "'," + "'" + tdienthoai.Text + "'," + "'" + tdiachi.Text + "'," + "'" + tngaydat.Text + "'," + thue + "," + phongdon + "," + phongdoi + ",'" + comboBox1.SelectedItem.ToString() + "')";
                string strcom2 = "insert into checkin(macheckin,makhach) values('" + tcheckin.Text + "','" + tmakhach.Text + "')";
                string strcom3 = "insert into luutru(maluutru,macheckin,makhach) values('" + luutru + "','" + tcheckin.Text + "','" + tmakhach.Text + "')";

                ketnoi.ThietlapketNoi();
                //laydulieu dl = new laydulieu();
                //if ( dl.thucthitruyvan("insert into checkin values(" + tcheckin.Text + "," + tmakhach.Text + "," + tphong.Text + ")") == 1 && dl.thucthitruyvan("Update from phong set tinhtrang='Reserve' where sophong=" + tphong.Text) == 1)
                SqlCommand com1 = new SqlCommand(strcom1, ketnoi.con);
                SqlCommand com2 = new SqlCommand(strcom2, ketnoi.con);
                SqlCommand com3 = new SqlCommand(strcom3, ketnoi.con);

                com1.ExecuteNonQuery();
                com2.ExecuteNonQuery();
                com3.ExecuteNonQuery();
                //label16.Text = luutru;
                MessageBox.Show("Đã thêm khách hàng thành công", "Thông báo");
                ketnoi.HuyKetNoi();

                /*laydulieu dl = new laydulieu();
                 * dt = dl.getdata("select sophong from phong where tinhtrang='Reserve'");
                 *
                 *
                 * tam1=dt.Tables[0].Rows[0]["sophong"].ToString();
                 * if (tam.IndexOf(tphongdon.Text) >= 0)
                 *  MessageBox.Show("Phòng này đã có khách đặt", "Chú ý");*/
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }