private void buttonPay_Click(object sender, EventArgs e) { try { string id = dataGridVManageVehicle.CurrentRow.Cells[0].Value.ToString(); paymentForm pay = new paymentForm(id); // pay.ID = id; //string c = pay.ID; //MessageBox.Show(c); pay.ShowDialog(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void paymentForm_Load(object sender, EventArgs e) { paymentForm pay = new paymentForm(); SqlCommand command = new SqlCommand("SELECT MaTheXe, LoaiXe, ThoiGianVao, AnhXe FROM Xe WHERE MaTheXe = " + id); DataTable table = vehicle.getVehicle(command); if (table.Rows.Count > 0) { labelCardID.Text = table.Rows[0]["MaTheXe"].ToString(); labelTypeOfVehicle.Text = table.Rows[0]["LoaiXe"].ToString(); labelInTime.Text = table.Rows[0]["ThoiGianVao"].ToString(); byte[] pic = (byte[])table.Rows[0]["AnhXe"]; MemoryStream AnhXe = new MemoryStream(pic); pictureBoxVehiclePicture.Image = Image.FromStream(AnhXe); } // DateTime time = DateTime.Parse(labelInTime.Text); }
private void buttonPay_Click(object sender, EventArgs e) { try { if (dataGridVManageVehicle.CurrentRow.Cells["TrangThaiGui"].Value.ToString() == "Dang Gui") { string id = dataGridVManageVehicle.CurrentRow.Cells[0].Value.ToString(); paymentForm pay = new paymentForm(id); pay.ShowDialog(); } else { MessageBox.Show("This vehicle paid!", "Pay", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void paymentForm_Load(object sender, EventArgs e) { paymentForm pay = new paymentForm(); SqlCommand command = new SqlCommand("SELECT MaTheXe, LoaiXe, ThoiGianVao, AnhXe, BienSo, HinhThucGui FROM Xe WHERE MaTheXe = " + id); DataTable table = vehicle.getVehicle(command); Calculate calculate = new Calculate(); if (table.Rows.Count > 0) { labelCardID.Text = table.Rows[0]["MaTheXe"].ToString(); labelTypeOfVehicle.Text = table.Rows[0]["LoaiXe"].ToString(); labelInTime.Text = table.Rows[0]["ThoiGianVao"].ToString(); labelShape.Text = table.Rows[0]["HinhThucGui"].ToString(); if (table.Rows[0][1].ToString() == "Xe Dap") { labelPicture.Text = "Vehicle Picture:"; byte[] pic = (byte[])table.Rows[0]["AnhXe"]; MemoryStream AnhXe = new MemoryStream(pic); pictureBoxVehiclePicture.Image = Image.FromStream(AnhXe); } else { labelPicture.Text = "License Picture:"; byte[] pic = (byte[])table.Rows[0]["BienSo"]; MemoryStream BienSo = new MemoryStream(pic); pictureBoxVehiclePicture.Image = Image.FromStream(BienSo); } TimeSpan parkingTime = DateTime.Now.Subtract((DateTime)table.Rows[0]["ThoiGianVao"]); labelDays.Text = parkingTime.Days.ToString(); labelHours.Text = parkingTime.Hours.ToString(); var Fee = calculate.parkingFeeAndFine(labelTypeOfVehicle.Text, labelShape.Text, parkingTime); labelParkingFee.Text = Fee.Item1.ToString(); labelFine.Text = Fee.Item2.ToString(); labelTotal.Text = (Fee.Item1 + Fee.Item2).ToString(); } }