Ejemplo n.º 1
0
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        int           userid = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value.ToString());
        SqlConnection con    = ConnectionString.Connect();

        con.Open();
        SqlCommand cmd = new SqlCommand("delete from FIR where firID = '" + userid + "'", con);

        cmd.ExecuteNonQuery();
        con.Close();
        LoadGrid();
    }
Ejemplo n.º 2
0
    private void LoadGrid()
    {
        SqlConnection con = ConnectionString.Connect();

        con.Open();
        SqlDataAdapter sda = new SqlDataAdapter("SELECT * FROM FIR", con);
        DataTable      dt  = new DataTable();

        sda.Fill(dt);
        GridView1.DataSource = dt;
        GridView1.DataBind();
        con.Close();
    }
Ejemplo n.º 3
0
    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        int         userid = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value.ToString());
        GridViewRow row    = (GridViewRow)GridView1.Rows[e.RowIndex];
        TextBox     Status = (TextBox)GridView1.Rows[e.RowIndex].FindControl("TextBox1");

        if (string.IsNullOrWhiteSpace(Status.Text))
        {
            string str = Status.Text;
        }
        SqlConnection con = ConnectionString.Connect();

        con.Open();
        SqlCommand cmd = new SqlCommand("update deptAdmin set post = '" + Status.Text + "' where deptAdminID = '" + userid + "'", con);

        cmd.ExecuteNonQuery();
        GridView1.EditIndex = -1;
        loadGrid();
        con.Close();
    }
Ejemplo n.º 4
0
    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        int         userid = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value.ToString());
        GridViewRow row    = (GridViewRow)GridView1.Rows[e.RowIndex];
        //TextBox textName = (TextBox)GridView1.Rows[e.RowIndex].FindControl("Complainant"); //row.FindControl("Complainant");
        //TextBox textName = (TextBox)GridView1.Rows[e.RowIndex].FindControl("Complainant");
        //if(string.IsNullOrWhiteSpace(textName.Text))
        //{
        //    textName.Text = "*****@*****.**";
        //}
        string textName = "*****@*****.**";

        SqlConnection con = ConnectionString.Connect();

        con.Open();
        SqlCommand cmd = new SqlCommand("update FIR set Complainant = '" + textName + "' where firID = '" + userid + "'", con);

        cmd.ExecuteNonQuery();
        con.Close();
        GridView1.EditIndex = -1;
        LoadGrid();
    }
Ejemplo n.º 5
0
 protected void Submit_Click(object sender, EventArgs e)
 {
     if (password.Text != reTypePassword.Text)
     {
         Response.Write("<script>alert('Passwords do not match');</script>");
     }
     else
     {
         SqlConnection con = ConnectionString.Connect();
         con.Open();
         SqlCommand cmd = new SqlCommand("RegDeptAdmin", con);
         cmd.CommandType = System.Data.CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@firstName", deptAdminFname.Text);
         cmd.Parameters.AddWithValue("@lastName", deptAdminLname.Text);
         cmd.Parameters.AddWithValue("@city", deptAdminCity.Text);
         cmd.Parameters.AddWithValue("@policeStation", deptAdminPoliceStation.Text);
         cmd.Parameters.AddWithValue("@post", deptAdminPost.Text);
         cmd.Parameters.AddWithValue("@email", deptAdminEmail.Text);
         cmd.Parameters.AddWithValue("@password", password.Text);
         cmd.ExecuteNonQuery();
         Response.Write("<script>alert('Admin Added Succesfully');</script>");
     }
 }