I have one error on the code as shown below. R2.comboBox_Name_2 is in form Reservation2.
R2.comboBox_Name_2.Text = this.dataGridView2.CurrentRow.Cells[0].Value.ToString(); <<---- Error CS0122 on line 13
Error CS0122 'Reservation2.comboBox_Name_2' is inaccessible due to its protection level
T1.Property_Name is in form Tenant and there is no problem with it. Line 19
R1.Property_Name is in form Reservation1 and there is no problem with it. Line 26
R2.comboBox_Name_2.Text = this.dataGridView2.CurrentRow.Cells[0].Value.ToString(); <<---- Error CS0122 on line 13
Error CS0122 'Reservation2.comboBox_Name_2' is inaccessible due to its protection level
T1.Property_Name is in form Tenant and there is no problem with it. Line 19
R1.Property_Name is in form Reservation1 and there is no problem with it. Line 26
Code for Form Unit_2.CS:
private void dataGridView2_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
string Apartment_Status;
DateTime Date_Reserved = DateTime.Today;
object value = this.dataGridView2.CurrentRow.Cells[7].Value.ToString();
Apartment_Status = value.ToString();
switch (Apartment_Status)
{
case "Reserved":
Reservation2 R2 = new Reservation2();
R2.comboBox_Name_2.Text = this.dataGridView2.CurrentRow.Cells[0].Value.ToString();
R2.Show();
break;
case "Occupied":
Tenant T1 = new Tenant();
T1.Property_Name.Text = this.dataGridView2.CurrentRow.Cells[0].Value.ToString();
T1.Unit_Number.Text = this.dataGridView2.CurrentRow.Cells[1].Value.ToString();
T1.Show();
break;
case "Vacant":
Reservation1 R1 = new Reservation1();
R1.Property_Name.Text = this.dataGridView2.CurrentRow.Cells[0].Value.ToString();
R1.Unit_Number.Text = this.dataGridView2.CurrentRow.Cells[1].Value.ToString();
string Property_Name = R1.Property_Name.Text;
string Property_ID = Obtain_Property_ID(Property_Name);
R1.Reservation_Number.Text = "R-" + Property_ID + "-" + R1.Unit_Number.Text + "-" + Date_Reserved.ToString("MM-dd-yyyy");
R1.Date_Reserved.Text = Date_Reserved.ToString("MM/dd/yyyy");
R1.Date_Moved_In_Planned.Text = DateTime.Today.AddDays(30).ToString("MM/dd/yyyy");
R1.Lease_Months.Text = "12";
R1.Reservation_Cancelled.Text = "No";
R1.Show();
break;
default:
break;
}
string Obtain_Property_ID(string Property_Name)
{
using (var con = new OleDbConnection())
using (var cmd = new OleDbCommand())
{
con.ConnectionString = ConfigurationManager.ConnectionStrings["Apartment_Management.Properties.Settings.AMS_2007ConnectionString"].ToString();
con.Open();
cmd.CommandText = "SELECT Property_ID FROM Property WHERE Property_Name = @pn ";
cmd.Parameters.AddWithValue("@pn", Property_Name);
cmd.Connection = con;
return (string)cmd.ExecuteScalar();
}
}
}