private void btDatPhong_Click(object sender, EventArgs e) { try { if (FormMain.KhachHang.status != true) { DialogResult dlr = MessageBox.Show("Hãy đăng nhập để đặt phòng nhé!", "Thông báo", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information); if (dlr == DialogResult.Yes) { ucDangNhap ucDN = new ucDangNhap(); ucDN.Show(); _datPhong = this; _datPhong.metroPanelContainer.Controls.Add(ucDN); _datPhong.metroPanelContainer.Controls["ucDangNhap"].BringToFront(); } } else { SqlConnection con = conn.getConnect(); if (con.State == ConnectionState.Closed) { con.Open(); } SqlCommand sqlCmd = new SqlCommand("USP_DatPhong", con); sqlCmd.CommandType = CommandType.StoredProcedure; sqlCmd.Parameters.AddWithValue("@malphong", dgDatPhong.Rows[dgDatPhong.CurrentRow.Index].Cells["maLoaiPhong"].Value.ToString()); sqlCmd.Parameters.AddWithValue("@makh", FormMain.KhachHang.maKH); sqlCmd.Parameters.AddWithValue("ngayBD", dtpBD.Value); sqlCmd.Parameters.AddWithValue("ngayT", dtpT.Value); if (sqlCmd.ExecuteNonQuery() > 0) { MessageBox.Show("Đặt phòng thành công"); } con.Close(); } } catch (SqlException ex) { MessageBox.Show(ex.Message); } }
private void linkLabel1_Click(object sender, EventArgs e) { ucDangNhap ucDN = new ucDangNhap(); ucDN.Show(); FormMain.formMain.metroPanelContainer.Controls.Add(ucDN); FormMain.formMain.metroPanelContainer.Controls["ucDangNhap"].BringToFront(); foreach (ucDangKy ucDK in FormMain.formMain.metroPanelContainer.Controls.OfType <ucDangKy>()) { FormMain.formMain.metroPanelContainer.Controls.Remove(ucDK); } if (ucDatPhong._datPhong != null) { foreach (ucDangKy ucDK in ucDatPhong.datPhong.metroPanelContainer.Controls.OfType <ucDangKy>()) { ucDatPhong.datPhong.metroPanelContainer.Controls.Remove(ucDK); } } }