Example #1
0
        public int update_data(tbl_rescue_place_victim_DAL objdal)
        {
            SqlConnection cn = new SqlConnection(ConfigurationSettings.AppSettings["dbconnect"]);
            SqlCommand    cm = new SqlCommand("update_tbl_rescue_place_victim", cn);

            cm.CommandType = CommandType.StoredProcedure;

            cm.Parameters.AddWithValue("@int_victim_id", objdal.int_victim_id);
            cm.Parameters.AddWithValue("@str_victim_name", objdal.str_victim_name);
            cm.Parameters.AddWithValue("@int_victim_age", objdal.int_victim_age);
            cm.Parameters.AddWithValue("@str_gender", objdal.str_gender);
            cm.Parameters.AddWithValue("@str_address", objdal.str_address);
            cm.Parameters.AddWithValue("@str_victim_image_path", objdal.str_victim_image_path);



            SqlDataAdapter da = new SqlDataAdapter(cm);
            DataSet        ds = new DataSet();

            da.Fill(ds);
            cn.Open();
            int val = Convert.ToInt16(cm.ExecuteNonQuery());

            cn.Close();
            return(val);
        }
    protected void btn_update_Click(object sender, EventArgs e)
    {
        try
        {
            tbl_rescue_place_victim_BAL objbal = new tbl_rescue_place_victim_BAL();
            tbl_rescue_place_victim_DAL objdal = new tbl_rescue_place_victim_DAL();

            objdal.int_victim_id = Convert.ToInt16(ViewState["id"]);

            objdal.str_victim_name = txt_victim_name.Text;
            objdal.int_victim_age  = Convert.ToInt32(txt_age.Text);
            objdal.str_gender      = btn_rdo_gender.SelectedItem.Value;
            objdal.str_address     = txt_address.Text;

            objdal.str_victim_image_path = fu_victim.FileName;
            if (fu_victim.HasFile)
            {
                //if (fu_img.PostedFile.ContentLength <= 250000)
                //{
                string path = Server.MapPath("~/upload/rescue_place_victim_page/");
                fu_victim.SaveAs(path + fu_victim.FileName);
                //}
            }



            lblmsg.Visible = true;


            int val = objbal.update_data(objdal);

            objbal.update_data(objdal);
            binddata("");
            if (val > 0)
            {
                lblmsg.Text      = "Data Update";
                lblmsg.ForeColor = System.Drawing.Color.Green;
            }
            else
            {
                lblmsg.Text      = "Error in Process,try again";
                lblmsg.ForeColor = System.Drawing.Color.Red;
            }
            changepanel(1, 0);
        }
        catch (Exception ex)
        {
        }
    }
Example #3
0
        public int delete_data(tbl_rescue_place_victim_DAL objdal)
        {
            SqlCommand cm = new SqlCommand("delete_tbl_rescue_place_victim", cn);

            cm.CommandType = CommandType.StoredProcedure;

            cm.Parameters.AddWithValue("@int_victim_id", objdal.int_victim_id);

            cn.Open();
            int val = Convert.ToInt16(cm.ExecuteScalar());

            cn.Close();

            return(val);
        }
Example #4
0
        public int insert_data(tbl_rescue_place_victim_DAL objdal)
        {
            SqlCommand cm = new SqlCommand("insert_tbl_rescue_place_victim", cn);

            cm.CommandType = CommandType.StoredProcedure;

            cm.Parameters.AddWithValue("@str_victim_name", objdal.str_victim_name);
            cm.Parameters.AddWithValue("@int_victim_age", objdal.int_victim_age);
            cm.Parameters.AddWithValue("@str_gender", objdal.str_gender);
            cm.Parameters.AddWithValue("@str_address", objdal.str_address);
            cm.Parameters.AddWithValue("@str_victim_image_path", objdal.str_victim_image_path);

            cn.Open();
            int val = Convert.ToInt16(cm.ExecuteScalar());

            cn.Close();

            return(val);
        }
    protected void btn_add_Click(object sender, EventArgs e)
    {
        try
        {
            tbl_rescue_place_victim_BAL objbal = new tbl_rescue_place_victim_BAL();
            tbl_rescue_place_victim_DAL objdal = new tbl_rescue_place_victim_DAL();


            objdal.str_victim_name = txt_victim_name.Text;
            objdal.int_victim_age  = Convert.ToInt32(txt_age.Text);
            objdal.str_gender      = btn_rdo_gender.SelectedItem.Value;


            objdal.str_address = txt_address.Text;

            objdal.str_victim_image_path = fu_victim.FileName;

            if (fu_victim.HasFile)
            {
                string path = Server.MapPath("~/upload/rescue_place_victim_page/");
                fu_victim.SaveAs(path + fu_victim.FileName);
            }

            int val = objbal.insert_data(objdal);


            if (val > 0)
            {
                binddata("");
                lblmsg.Text      = "Data successfully inserted";
                lblmsg.ForeColor = System.Drawing.Color.Green;
            }
            changepanel(1, 0);
        }
        catch (Exception ex)
        {
        }
    }
Example #6
0
    protected void btn_select_delete_Click(object sender, EventArgs e)
    {
        try
        {
            tbl_rescue_place_victim_BAL objbal = new tbl_rescue_place_victim_BAL();
            tbl_rescue_place_victim_DAL objdal = new tbl_rescue_place_victim_DAL();

            foreach (GridViewRow row in gvlist.Rows)
            {
                var check = row.FindControl("chkselect") as CheckBox;
                if (check.Checked)
                {
                    var id = row.FindControl("Hiddenid") as HiddenField;
                    objdal.int_victim_id = Convert.ToInt16(id.Value);
                    objbal.delete_data(objdal);
                    binddata("");
                }
            }
        }
        catch (Exception ex)
        {
        }
    }