Exemplo n.º 1
0
    protected void btn_add_Click1(object sender, EventArgs e)
    {
        try
        {
            tbl_district_BAL objbal = new tbl_district_BAL();
            tbl_district_DAL objdal = new tbl_district_DAL();


            objdal.str_district_name = txt_district_name.Text;
            objdal.int_state_id      = Convert.ToInt16(ddl_state.SelectedItem.Value);
            lblmsg.Visible           = true;
            int val = objbal.insert_data(objdal);
            if (val > 0)
            {
                binddata("");
                lblmsg.Text      = "Data successfully inserted";
                lblmsg.ForeColor = System.Drawing.Color.Green;
            }
            else if (val == -1)
            {
                lblmsg.Text      = "name duplicate is not allowed";
                lblmsg.ForeColor = System.Drawing.Color.Red;
            }



            changepanel(1, 0);
        }
        catch (Exception ex)
        {
        }
    }
Exemplo n.º 2
0
    protected void btn_update_Click(object sender, EventArgs e)
    {
        try
        {
            tbl_district_BAL objbal = new tbl_district_BAL();
            tbl_district_DAL objdal = new tbl_district_DAL();



            objdal.str_district_name = txt_district_name.Text;
            objdal.int_district_id   = Convert.ToInt16(ViewState["id"]);
            objdal.int_state_id      = Convert.ToInt16(ddl_state.SelectedItem.Value);
            lblmsg.Visible           = true;
            int val = objbal.update_data(objdal);

            objbal.update_data(objdal);
            binddata("");
            changepanel(1, 0);
            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;
            }
        }
        catch (Exception ex)
        {
        }
    }
Exemplo n.º 3
0
        public int delete_data(tbl_district_DAL objdal)
        {
            SqlCommand cm = new SqlCommand("delete_tbl_district", cn);

            cm.CommandType = CommandType.StoredProcedure;

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

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

            cn.Close();

            return(val);
        }
Exemplo n.º 4
0
        public int update_data(tbl_district_DAL objdal)
        {
            SqlConnection cn = new SqlConnection(ConfigurationSettings.AppSettings["dbconnect"]);
            SqlCommand    cm = new SqlCommand("update_tbl_district", cn);

            cm.CommandType = CommandType.StoredProcedure;
            cm.Parameters.AddWithValue("@int_district_id", objdal.int_district_id);
            cm.Parameters.AddWithValue("@str_district_name", objdal.str_district_name);
            cm.Parameters.AddWithValue("@int_state_id", objdal.int_state_id);

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

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

            cn.Close();
            return(val);
        }
Exemplo n.º 5
0
    protected void btn_select_delete_Click(object sender, EventArgs e)
    {
        try
        {
            tbl_district_BAL objbal = new tbl_district_BAL();
            tbl_district_DAL objdal = new tbl_district_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_district_id = Convert.ToInt16(id.Value);
                    objbal.delete_data(objdal);
                    binddata("");
                }
            }
        }
        catch (Exception ex)
        {
        }
    }