void SelectBooking(string BookingNo) { DBConnect conn = new DBConnect(); SqlConnection myconn = conn.GetSqlConnection(); SqlCommand cmn; SqlDataReader dr; string sql = "select * from booking where id=@ID"; cmn = new SqlCommand(sql, myconn); cmn.Parameters.AddWithValue("@ID", BookingNo); try { myconn.Open(); dr = cmn.ExecuteReader(); if (dr.HasRows) { dr.Read(); if (dr["Status"].ToString() == "Not Confirmed" && (dr["Type"].ToString() == "Tour Package & Hotel" || dr["Type"].ToString() == "Tour Package")) { MessageBox.Show("You have to pay the deposit firstly to confirm the booking", "Unconfirmed Booking", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { labelStatus.Visible = true; lblStatus.Visible = true; labelTotalAmount.Visible = true; lblTotalAmount.Visible = true; lblBookingAmount.Visible = true; labelBookingAmount.Visible = true; labelCharge.Visible = true; lblCharge.Visible = true; labelDeposit.Visible = true; lblDeposit.Visible = true; labelDepositPaid.Visible = true; lblDepositPaid.Visible = true; labelDepositPaid.Text = "Deposit Paid"; labelDeposit.Text = "Discount"; labelCharge.Text = "Charge"; lblBookingNo.Text = dr["ID"].ToString(); lblCustomerID.Text = dr["CustomerID"].ToString(); lblType.Text = dr["Type"].ToString(); date = DateTime.Parse(dr["Date"].ToString()); lblDate.Text = date.ToShortDateString(); charge = double.Parse(dr["Charge"].ToString()); lblCharge.Text = charge.ToString("C3"); discount = double.Parse(dr["Discount"].ToString()); lblDeposit.Text = discount.ToString("C3"); deposit = 0; lblDepositPaid.Text = deposit.ToString("C3"); bookingAmount = double.Parse(dr["Total"].ToString()); lblBookingAmount.Text = bookingAmount.ToString("C3"); Total = double.Parse(dr["Total"].ToString()) + double.Parse(dr["Charge"].ToString()) - double.Parse(dr["Discount"].ToString()); lblTotalAmount.Text = Total.ToString("C3"); if (dr["DepositStatus"].ToString() == string.Empty) { lblStatus.Text = "Null"; } else { lblStatus.Text = dr["DepositStatus"].ToString(); } if (dr["Status"].ToString() == "Confirmed" && dr["DepositStatus"].ToString() == string.Empty) { deposit = double.Parse(dr["Deposit"].ToString()); lblDepositPaid.Text = deposit.ToString("C3"); Total = double.Parse(dr["Total"].ToString()) + double.Parse(dr["Charge"].ToString()) - double.Parse(dr["Discount"].ToString()) - double.Parse(dr["deposit"].ToString()); lblTotalAmount.Text = Total.ToString("C3"); } else if (dr["DepositStatus"].ToString() == "forfeited") { deposit = double.Parse(dr["Deposit"].ToString()); lblDepositPaid.Text = deposit.ToString("C3"); Total = double.Parse(dr["Total"].ToString()) + double.Parse(dr["Charge"].ToString()) - double.Parse(dr["Discount"].ToString()); lblTotalAmount.Text = Total.ToString("C3"); } gropboxPayment.Visible = true; } } } catch (SqlException ex) {//display on the console the exeception message Console.WriteLine(ex.ToString()); Console.ReadLine(); } finally {// Close the connection myconn.Close(); } }