public bool insert_doanhThuParking(doanhThuParkingDTO doanhThu) { try { this.openConnection(); SqlCommand cmd = new SqlCommand("INSERT INTO REVENUE_PARKING (id, timeOut, totalFee)" + "VALUES (@id, @timeOut, @totalFee)", this.getConnection); cmd.Parameters.Add("@id", SqlDbType.NChar).Value = doanhThu.id; cmd.Parameters.Add("@timeOut", SqlDbType.DateTime).Value = doanhThu.timeOut; cmd.Parameters.Add("@totalFee", SqlDbType.Int).Value = doanhThu.totalFee; if (cmd.ExecuteNonQuery() == 1) { return(true); } } catch (Exception ex) { MessageBox.Show("Error: ", ex.Message); } finally { this.closeConnection(); } return(false); }
private void btnThanhToan_Click(object sender, EventArgs e) { try { if (this.dgvXe.CurrentRow != null) { string IDxe = this.dgvXe.CurrentRow.Cells[0].Value.ToString(); if (MessageBox.Show("Do you want to take out : " + IDxe, "Take Out vehicle", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { if (checkHetHan(IDxe)) { MessageBox.Show("Xe đã quá hạn chi phí thanh toán: " + this.totalfee(IDxe), "Lấy Xe", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Thanh toán: " + this.totalfee(IDxe), "Lấy Xe", MessageBoxButtons.OK, MessageBoxIcon.Information); } doanhThuParkingDTO doanhthuDTO = new doanhThuParkingDTO(IDxe, DateTime.Now, this.totalfee(IDxe)); this.doanhThuBUS.insert_doanhThuParking(doanhthuDTO); if (this.vehParkingBUS.DelVehicle(IDxe) && this.vehBUS.UpdateStatusVehicle(IDxe, "PARK", 0)) { MessageBox.Show("Vehicle is taken out", "Lấy Xe", MessageBoxButtons.OK, MessageBoxIcon.Information); if (!this.checkOtherService(IDxe)) { if (this.vehBUS.DelVehicle(IDxe)) { MessageBox.Show("Đã Xóa Trong Table VEHICLE", "Lấy Xe", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Đã Xóa Không Thành Công Trong Table VEHICLE", "Lấy Xe", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else { MessageBox.Show("Vehicle is taken out Error", "Lấy Xe", MessageBoxButtons.OK, MessageBoxIcon.Error); } this.cbTypeFilter.SelectedIndex = 5; this.LoadProgressBar(); DataTable table = this.vehParkingBUS.getAllVehicle(); if (table != null) { this.designDataGridView(table, 2, 3); this.lbCount.Text = "Số Lượng Xe: " + this.dgvXe.Rows.Count; } else { this.dgvXe.DataSource = null; this.lbCount.Text = "Số Lượng Xe: " + this.dgvXe.Rows.Count; } } else { //Nothing } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Lấy Xe"); } }
//lưu ngày lấy xe ra public bool insert_doanhThuParking(doanhThuParkingDTO doanhThuDTO) { return(this.doanhthuDAL.insert_doanhThuParking(doanhThuDTO)); }