public houseConditionBLL GetlastHouseConditionId() { SqlConnection conn = new SqlConnection(myconnstrng); houseConditionBLL hcb = new houseConditionBLL(); DataTable dt = new DataTable(); try { string sql = "SELECT MAX(house_condition_id) AS house_condition_id FROM tbl_house_condition"; SqlDataAdapter adapter = new SqlDataAdapter(sql, conn); conn.Open(); adapter.Fill(dt); if (dt.Rows.Count > 0) { hcb.house_condition_id = int.Parse(dt.Rows[0]["house_condition_id"].ToString()); } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { conn.Close(); } return(hcb); }
public houseConditionBLL GetHouseGradeByHouseId(int house_id) { SqlConnection conn = new SqlConnection(myconnstrng); houseConditionBLL hcb = new houseConditionBLL(); DataTable dt = new DataTable(); try { string sql = "SELECT damage_grade FROM tbl_house_condition WHERE house_id = " + house_id; SqlDataAdapter adapter = new SqlDataAdapter(sql, conn); conn.Open(); adapter.Fill(dt); if (dt.Rows.Count > 0) { hcb.damage_grade = dt.Rows[0]["damage_grade"].ToString(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { conn.Close(); } return(hcb); }
public bool Insert(houseConditionBLL h) { SqlConnection conn = new SqlConnection(myconnstrng); bool isSuccess = false; try { string sql = "INSERT INTO tbl_house_condition (no_of_flats_before, no_of_flats_after, life_span_of_house, area_of_house, surface_of_house, base_of_house, super_structure_of_house, materials_for_other_floors, roof_of_house, position_of_house, plan_configuration, house_analysed_part, damage_grade, started_maintenance, other_dangers, house_id, added_date, technical_assistance) VALUES (@no_of_flats_before, @no_of_flats_after, @life_span_of_house, @area_of_house, @surface_of_house, @base_of_house, @super_structure_of_house, @materials_for_other_floors, @roof_of_house, @position_of_house, @plan_configuration, @house_analysed_part, @damage_grade, @started_maintenance, @other_dangers, @house_id, @added_date, @technical_assistance)"; SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.AddWithValue("@no_of_flats_before", h.no_of_flats_before); cmd.Parameters.AddWithValue("@no_of_flats_after", h.no_of_flats_after); cmd.Parameters.AddWithValue("@life_span_of_house", h.life_span_of_house); cmd.Parameters.AddWithValue("@area_of_house", h.area_of_house); cmd.Parameters.AddWithValue("@surface_of_house", h.surface_of_house); cmd.Parameters.AddWithValue("@base_of_house", h.base_of_house); cmd.Parameters.AddWithValue("@super_structure_of_house", h.super_structure_of_house); cmd.Parameters.AddWithValue("@materials_for_other_floors", h.materials_for_other_floors); cmd.Parameters.AddWithValue("@roof_of_house", h.roof_of_house); cmd.Parameters.AddWithValue("@position_of_house", h.position_of_house); cmd.Parameters.AddWithValue("@plan_configuration", h.plan_configuration); cmd.Parameters.AddWithValue("@house_analysed_part", h.house_analysed_part); cmd.Parameters.AddWithValue("@damage_grade", h.damage_grade); cmd.Parameters.AddWithValue("@started_maintenance", h.started_maintenance); cmd.Parameters.AddWithValue("@other_dangers", h.other_dangers); cmd.Parameters.AddWithValue("@house_id", h.house_id); cmd.Parameters.AddWithValue("@added_date", h.added_date); cmd.Parameters.AddWithValue("@technical_assistance", h.technical_assistance); conn.Open(); int rows = cmd.ExecuteNonQuery(); if (rows > 0) { //House Condition Registered Successfully isSuccess = true; } else { //Failed to REgister house Condition isSuccess = false; } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { conn.Close(); } return(isSuccess); }
private void btnNext_Click(object sender, EventArgs e) { //Get the Details from UI hc.no_of_flats_before = txtNoOfFlatsBefore.Text; hc.no_of_flats_after = txtNoOfFlatsAfter.Text; hc.life_span_of_house = txtLifeSpanOfhouse.Text; hc.area_of_house = txtAreaOfhouse.Text; hc.surface_of_house = cmbSurfaceOfHouse.Text; hc.base_of_house = cmbBaseOfHouse.Text; hc.super_structure_of_house = cmbSuperStructure.Text; hc.materials_for_other_floors = cmbMaterialsForOtherFloors.Text; hc.roof_of_house = cmbRoofOfHouse.Text; hc.position_of_house = cmbPositionOfHouse.Text; hc.plan_configuration = cmbPlanConfiguration.Text; hc.house_analysed_part = cmbHouseAnalysedPart.Text; hc.damage_grade = cmbDamageGrade.Text; hc.technical_assistance = cmbTechnicalAssistance.Text; hc.started_maintenance = cmbStartedMaintenance.Text; hc.other_dangers = cmbOtherDangers.Text; //House ID get from previous submission hc.house_id = frmHouse.house_id; hc.added_date = DateTime.Now; bool success = hcdal.Insert(hc); if (success == true) { //House Condition Registered Successfully MessageBox.Show("House Condition Registered Successfully Proceed to Final Step."); //Get the Latest House Condition ID and set it to static house_condition_id houseConditionBLL hcbl = hcdal.GetlastHouseConditionId(); house_condition_id = hcbl.house_condition_id; //Then Close this Form this.Hide(); //Open House Owner Details frmVictim victim = new frmVictim(); victim.Show(); } else { //Failed to REgister House Condition MessageBox.Show("Failed to Register House Condition. Try Again."); } }
private void dgvVictims_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) { int RowIndex = e.RowIndex; txtFullName.Text = dgvVictims.Rows[RowIndex].Cells[0].Value.ToString(); txtFirstPayment.Text = dgvVictims.Rows[RowIndex].Cells[1].Value.ToString(); txtSecondPayment.Text = dgvVictims.Rows[RowIndex].Cells[2].Value.ToString(); txtThirdPayment.Text = dgvVictims.Rows[RowIndex].Cells[3].Value.ToString(); //For Displaying Profile Picture string photo = dgvVictims.Rows[RowIndex].Cells[4].Value.ToString(); if (photo != "") { //Display Image pictureBoxProfilePhoto.Image = new Bitmap(photo); } //For Displaying House Grade and house Address int house_id = int.Parse(dgvVictims.Rows[RowIndex].Cells[5].Value.ToString()); houseConditionBLL hcb = hcdal.GetHouseGradeByHouseId(house_id); txtHouseGrade.Text = hcb.damage_grade; //Dislaying House Address Based on house_id houseBLL hbd = hdal.GetDistrictByHouseID(house_id); string district = hbd.district; houseBLL hbv = hdal.GetVDCByHouseID(house_id); string vdc = hbv.vdc; houseBLL hbw = hdal.GetWardNoByHouseID(house_id); string ward = hbw.ward_no; houseBLL hbt = hdal.GetToleByHouseID(house_id); string tole = hbt.tole; txtAddress.Text = district + ", " + vdc + " - " + ward + ", " + tole; }