public static bool InsertRoomLease(RoomLeaseDTO lease) { try { if (connection.State != ConnectionState.Open) { connection.Open(); } var command = new SqlCommand("ThemPhieuThuePhong", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(new SqlParameter("@MaPhong", lease.RoomID)); command.Parameters.Add(new SqlParameter("@NgayThue", lease.LeaseDate)); command.Parameters.Add(new SqlParameter("@LoaiPhong", lease.RoomTypeID)); command.Parameters.Add(new SqlParameter("@DonGia", lease.RoomPrice)); command.ExecuteNonQuery(); return(true); } catch (SqlException) { return(false); } finally { connection.Close(); } }
private void BtnCreate_Click(object sender, EventArgs e) { var lease = new RoomLeaseDTO(); lease.RoomID = this.tbRoomID.Text; lease.RoomTypeID = this.tbRoomType.Text; lease.RoomPrice = Int64.Parse(this.tbRoomPrice.Text.Split()[0].Replace(",", "")); lease.LeaseDate = DateTime.ParseExact(tbRoomDate.Text, "d/M/yyyy", CultureInfo.InvariantCulture).ToString("d"); if (RoomLeaseBUS.InsertRoomLease(lease)) { RoomLeaseDetailDTO detail = new RoomLeaseDetailDTO(); detail.LeaseID = RoomLeaseBUS.GetLastLeaseIDOfRoom(lease.RoomID); foreach (DataGridViewRow row in dgvCustomerData.Rows) { detail.CustomerName = row.Cells["CustomerName"].Value.ToString(); detail.CustomerPassportID = row.Cells["CustomerPassportID"].Value.ToString(); detail.CustomerTypeID = Convert.ToInt32(row.Cells["CustomerTypeID"].Value); detail.CustomerAddress = row.Cells["CustomerAddress"].Value.ToString(); RoomLeaseDetailBUS.InsertDetail(detail); } MainForm mainForm = (MainForm)Owner; mainForm.ReLoadAvailableRoom(); mainForm.ReLoadRoomData(); mainForm.ReCreateLease(); MessageBox.Show("Lập phiếu thuê phòng " + lease.RoomID + " thành công!", "LẬP PHIẾU THUÊ PHÒNG THÀNH CÔNG", MessageBoxButtons.OK, MessageBoxIcon.Information); } this.Close(); }
public RoomLeaseDTO GetRoomLease() { var lease = new RoomLeaseDTO(); lease.RoomID = cbLeaseRoomID.Text; lease.RoomTypeID = RoomTypeBUS.GetRoomTypeByID(lease.RoomID); lease.LeaseDate = DateTime.ParseExact(deLeaseRoomDate.Text, "d/M/yyyy", CultureInfo.InvariantCulture).ToString("d"); lease.RoomPrice = Convert.ToInt64(tbLeaseRoomPrice.Text.Split()[0].Replace(",", "")); return(lease); }
public static bool InsertRoomLease(RoomLeaseDTO lease) { return(RoomLeaseDAO.InsertRoomLease(lease)); }