Beispiel #1
0
        public houseBLL GetLastinsertedHouseId()
        {
            houseBLL      h    = new houseBLL();
            SqlConnection conn = new SqlConnection(myconnstrng);
            DataTable     dt   = new DataTable();

            try
            {
                string         sql     = "SELECT MAX(house_id) AS house_id FROM tbl_house";
                SqlDataAdapter adapter = new SqlDataAdapter(sql, conn);
                conn.Open();

                adapter.Fill(dt);
                if (dt.Rows.Count > 0)
                {
                    h.house_id = int.Parse(dt.Rows[0]["house_id"].ToString());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conn.Close();
            }
            return(h);
        }
Beispiel #2
0
        public houseBLL GetToleByHouseID(int house_id)
        {
            houseBLL      h    = new houseBLL();
            SqlConnection conn = new SqlConnection(myconnstrng);
            DataTable     dt   = new DataTable();

            try
            {
                string         sql     = "SELECT tole FROM tbl_house WHERE house_id=" + house_id;
                SqlDataAdapter adapter = new SqlDataAdapter(sql, conn);
                conn.Open();

                adapter.Fill(dt);
                if (dt.Rows.Count > 0)
                {
                    h.tole = dt.Rows[0]["tole"].ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conn.Close();
            }
            return(h);
        }
Beispiel #3
0
        private void dgvVictims_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            int rowindex = e.RowIndex;

            txtFullName.Text   = dgvVictims.Rows[rowindex].Cells[0].Value.ToString();
            txtHouseGrade.Text = dgvVictims.Rows[rowindex].Cells[1].Value.ToString();

            //Get photo path First
            string photo = dgvVictims.Rows[rowindex].Cells[5].Value.ToString();

            if (photo != "")
            {
                //Display Image
                pictureBoxProfilePhoto.Image = new Bitmap(photo);
            }

            txtVictimID.Text = dgvVictims.Rows[rowindex].Cells[7].Value.ToString();

            //Now Shwing House Address Based on House ID
            int      house_id = int.Parse(dgvVictims.Rows[rowindex].Cells[6].Value.ToString());
            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;
        }
Beispiel #4
0
        public bool Insert(houseBLL h)
        {
            //DAtabase Connection First
            SqlConnection conn = new SqlConnection(myconnstrng);
            //Define Bool value and set its default value to false
            bool isSuccess = false;

            try
            {
                //SQL Query to Insert DAta
                string sql = "INSERT INTO tbl_house (district, vdc, ward_no, tole, latitude, longitude, altitude, added_date) VALUES (@district, @vdc, @ward_no, @tole, @latitude, @longitude, @altitude, @added_date)";

                SqlCommand cmd = new SqlCommand(sql, conn);

                cmd.Parameters.AddWithValue("@district", h.district);
                cmd.Parameters.AddWithValue("@vdc", h.vdc);
                cmd.Parameters.AddWithValue("@ward_no", h.ward_no);
                cmd.Parameters.AddWithValue("@tole", h.tole);
                cmd.Parameters.AddWithValue("@latitude", h.latitude);
                cmd.Parameters.AddWithValue("@longitude", h.longitude);
                cmd.Parameters.AddWithValue("@altitude", h.altitude);
                cmd.Parameters.AddWithValue("@added_date", h.added_date);

                conn.Open();

                int rows = cmd.ExecuteNonQuery();
                if (rows > 0)
                {
                    //Data Inserted Successfully
                    isSuccess = true;
                }
                else
                {
                    //Failed to Insert DAta
                    isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                //Database Connection Close
                conn.Close();
            }

            return(isSuccess);
        }
Beispiel #5
0
        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;
        }
Beispiel #6
0
        private void btnNext_Click(object sender, EventArgs e)
        {
            //Get all the Data from UI
            h.district   = txtDisctrict.Text;
            h.vdc        = txtVDC.Text;
            h.ward_no    = txtWardNo.Text;
            h.tole       = txtTole.Text;
            h.latitude   = txtLatitude.Text;
            h.longitude  = txtLongitude.Text;
            h.altitude   = txtAltitude.Text;
            h.added_date = DateTime.Now;

            bool success = hdal.Insert(h);

            if (success == true)
            {
                //House Registered Successfully
                MessageBox.Show("House Registerd Successfully. Proceed to Next Step.");

                //Get the Latest House ID and set it to house_id
                houseBLL hb = hdal.GetLastinsertedHouseId();
                house_id = hb.house_id;

                //Close this form if House Registration Success
                this.Hide();

                //Open House Condition Form if Success
                frmHouseCondition houseCondition = new frmHouseCondition();
                houseCondition.Show();
            }
            else
            {
                //FAiled to Register House
                MessageBox.Show("Failed to Register House. Try Again.");
            }
        }