public void Tang(int temp, int a, out string laytenphong, BunifuFlatButton btdattraphong) { string ghepmaphong; laytenphong = null; HotelObject.PhongHo p = new HotelObject.PhongHo(); HotelObject.PhongHo p1 = new HotelObject.PhongHo(); HotelObject.PhongHo p2 = new HotelObject.PhongHo(); HotelObject.PhongHo p3 = new HotelObject.PhongHo(); p.TenPhong = null; p1.TenPhong = null; p2.TenPhong = null; p3.TenPhong = null; if (a.ToString().Length == 1) { ghepmaphong = "P" + temp.ToString() + "0" + a.ToString(); } else { ghepmaphong = "P" + temp.ToString() + a.ToString(); } p.TenPhong = conn.LayBien("EXEC PROC_SELECT_PHONGDANGO1 " + temp + ",'" + ghepmaphong + "'", 0); p1.TenPhong = conn.LayBien("EXEC PROC_SELECT_PHONGDANGTHUE1 " + temp + ", '" + ghepmaphong + "'", 0); p2.TenPhong = conn.LayBien("EXEC PROC_SELECT_PHONGTRAMUON1 " + temp + ",'" + ghepmaphong + "'", 0); p3.TenPhong = conn.LayBien("EXEC PROC_SELECT_PHONGDATCOCTRUOC1 " + temp + ",'" + ghepmaphong + "'", 0); if (p.TenPhong != null) { btdattraphong.Text = "Trả Phòng"; btdattraphong.Cursor = Cursors.Hand; //label16.Text = "phong dang o"; laytenphong = p.TenPhong; } if (p1.TenPhong != null) { btdattraphong.Text = "Đặt Phòng"; btdattraphong.Cursor = Cursors.Default; FormDatPhong dp = new FormDatPhong(p1.TenPhong, temp.ToString()); dp.Show(); } if (p2.TenPhong != null) { //label16.Text = "phong dang tra muon"; btdattraphong.Text = "Trả Phòng"; btdattraphong.Cursor = Cursors.Hand; laytenphong = p2.TenPhong; } if (p3.TenPhong != null) { // label16.Text = "phong dang dat coc"; btdattraphong.Text = "Trả Phòng"; btdattraphong.Cursor = Cursors.Hand; laytenphong = p3.TenPhong; } }
public void DatPhong(TextBoxX tbhoten, BunifuDropdown ddGioiTinh, TextBoxX tbsocmt, TextBoxX tbphone, BunifuDatepicker DPNgayDat, BunifuDatepicker DPNgayTra, Label label2, Label label8, out int transfer) { transfer = 0; ChuanHoa ch = new ChuanHoa(); HotelObject.KhachHangHo kh = new HotelObject.KhachHangHo(); HotelObject.ThuePhongHo tp = new HotelObject.ThuePhongHo(); HotelObject.PhongHo p = new HotelObject.PhongHo(); string day, month, year; string day1, month1, year1; string day2, month2, year2; ch.ChuanHoaDate(DPNgayTra.Value.ToString(), out day1, out month1, out year1); ch.ChuanHoaDate(DPNgayDat.Value.ToString(), out day, out month, out year); ch.ChuanHoaDate(DateTime.Now.ToString(), out day2, out month2, out year2); Connection cn = new Connection(); if (ch.CheckTB(tbhoten.Text, tbsocmt.Text, tbphone.Text) == false) { Notification nf = new Notification("LỖI", "Thông tin phải được nhập đầy đủ.", "Mời bạn nhập lại."); nf.Show(); } else if (ch.Check_Text_Name(tbhoten) == false) { Notification nf = new Notification("LỖI", "Tên không chứa chữ số.", "Mời bạn nhập lại."); nf.Show(); } else if (ch.CheckDate(Int32.Parse(day2), Int32.Parse(month2), Int32.Parse(year2), Int32.Parse(day), Int32.Parse(month), Int32.Parse(year)) == false) { Notification nf = new Notification("LỖI", "Ngày đặt phòng không hợp lệ.", "Mời bạn nhập lại."); nf.Show(); } else if (ch.CheckDate(Int32.Parse(day), Int32.Parse(month), Int32.Parse(year), Int32.Parse(day1), Int32.Parse(month1), Int32.Parse(year1)) == false) { Notification nf = new Notification("LỖI", "Ngày đặt phòng và ngày trả phòng không hợp lệ.", "Mời bạn nhập lại."); nf.Show(); } else if (ch.Check_SoCMT(tbsocmt) == false) { Notification nf = new Notification("LỖI", "Số CMT không hợp lệ.", "Mời bạn nhập lại."); nf.Show(); } else if (ch.Check_Phone(tbphone) == false) { Notification nf = new Notification("LỖI", "Số điện thoại không hợp lệ.", "Mời bạn nhập lại."); nf.Show(); } else { kh.TenKhachHang = ch.CH_Name(tbhoten); kh.SoCMT = ch.CH_Space(tbsocmt); string temp = null, temp2 = null; kh.MaKhachHang = cn.LayBien("select makhachhang from khachhang order by makhachhang asc", 0); tp.MaThue = cn.LayBien("select mathue from thuephong order by mathue asc", 0); for (int i = 2; i < tp.MaThue.Length; i++) { temp2 = temp2 + tp.MaThue[i]; } tp.MaThue = "TP" + (Int32.Parse(temp2) + 1).ToString(); p.MaPhong = cn.LayBien("select maphong from phong where tenphong='" + label2.Text + "'", 0); for (int i = 2; i < kh.MaKhachHang.Length; i++) { temp = temp + kh.MaKhachHang[i]; } kh.MaKhachHang = "KH" + (Int32.Parse(temp) + 1).ToString(); cn.InsertDeleteUpdate("INSERT INTO KHACHHANG VALUES('" + kh.MaKhachHang + "',N'" + kh.TenKhachHang + "',N'" + ddGioiTinh.selectedValue + "','" + kh.SoCMT + "','" + tbphone.Text + "')"); cn.InsertDeleteUpdate("INSERT INTO THUEPHONG VALUES('" + tp.MaThue + "','" + kh.MaKhachHang + "','" + p.MaPhong + "','" + year + month + day + "','" + year1 + month1 + day1 + "',1)"); Notification nf = new Notification("ĐẶT PHÒNG", "Đặt phòng thành công.", ""); nf.Show(); transfer = 1; } }