<repo_name>priyankacheema/eTuition<file_sep>/RegisterTut.aspx.cs
﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;


public partial class RegisterTut : System.Web.UI.Page
{
    SqlConnection con;
   

    protected void Page_Load(object sender, EventArgs e)
    {
        con = new SqlConnection("Data Source=sandeep-pc\\priyanka;Initial Catalog=Priyanka;Integrated Security=True");
    }
    protected void btnRegister_Click(object sender, EventArgs e)
    {

        SqlConnection con = new SqlConnection("Data Source=sandeep-pc\\priyanka;Initial Catalog=Priyanka;Integrated Security=True");
        SqlCommand cmd = new SqlCommand();
        cmd.CommandType = CommandType.Text;
        cmd.CommandText = "insert into eTutor(FName,LName,EmailId,Password,Gender,Age,MotherTongue,Address,City,State,ContactNo,Qualification1,Qualification2,Subject,Experience)values('" + txtFName.Text + "','" + txtLName.Text + "','" + txtEmail.Text + "','" + txtPasswrd.Text + "','" + RadioButtonList1.SelectedItem.Text + "'," + txtAge.Text + ",'" + txtMotherTng.Text + "','" + txtAddr.Text + "','" + DropDnCity.SelectedItem.Text + "','" + DropDnState.SelectedItem.Text + "'," + txtContact.Text + ",'" + DropDnQual.SelectedItem.Text + "','" + txtQual.Text + "','" + txtSub.Text + "'," + txtExp.Text + ")";
        cmd.Connection = con;
        con.Open();
        int ok = cmd.ExecuteNonQuery();
        if (ok > 0)
        {
            Label19.ForeColor = System.Drawing.Color.DeepPink;
            Label19.Text = "Registration Successful";
            Clear();
        }
        else
        {
            Label19.ForeColor = System.Drawing.Color.DeepPink;
            Label19.Text = "Registration Failed";
        }
        con.Close();
    }



    private void Clear()
    {
        txtFName.Text = "";
        txtLName.Text = "";
        txtEmail.Text = "";
        txtPasswrd.Text = "";
        txtAge.Text = "";
        txtMotherTng.Text = "";
        txtAddr.Text = "";
        txtContact.Text = "";
        txtQual.Text = "";
        txtSub.Text = "";
        txtExp.Text = "";
    }
}<file_sep>/StuViewSPapers.aspx.cs
﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Text;
using System.Data.SqlClient;
using System.Data;

public partial class StuViewPapers : System.Web.UI.Page
{
    string query;
    SqlConnection con;
    SqlCommand com;
    string strCon = "Data Source=sandeep-pc\\priyanka;Initial Catalog=Priyanka;Integrated Security=True";

    protected void Page_Load(object sender, EventArgs e)
    {
        con = new SqlConnection("Data Source=sandeep-pc\\priyanka;Initial Catalog=Priyanka;Integrated Security=True");
        con.Open();
        query = "Select *from TutSPaper";
        SqlDataAdapter da = new SqlDataAdapter(query, con);
        DataSet ds = new DataSet();
        da.Fill(ds);
        GridView1.DataSource = ds;
        GridView1.DataBind();
        con.Close();
    }

    //This button click event is used to download files from gridview
    protected void lnkDownload_Click(object sender, EventArgs e)
    {
        LinkButton lnkbtn = sender as LinkButton;
        GridViewRow gvrow = lnkbtn.NamingContainer as GridViewRow;
        int fileid = Convert.ToInt32(GridView1.DataKeys[gvrow.RowIndex].Value.ToString());
        //string name, type;
        using (SqlConnection con = new SqlConnection(strCon))
        {
            using (SqlCommand cmd = new SqlCommand())
            {
                cmd.CommandText = "select FileName, FileType, FileData from TutSPaper where Id=@Id";
                cmd.Parameters.AddWithValue("@id", fileid);
                cmd.Connection = con;
                con.Open();
                SqlDataReader dr = cmd.ExecuteReader();
                if (dr.Read())
                {
                    Response.ContentType = dr["FileType"].ToString();
                    Response.AddHeader("Content-Disposition", "attachment;filename=\"" + dr["FileName"] + "\"");
                    Response.BinaryWrite((byte[])dr["FileData"]);
                    Response.End();
                }
            }
        }
    }

}<file_sep>/RegisterStu.aspx.cs
﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;

public partial class RegisterStu : System.Web.UI.Page
{
    SqlConnection con;

    protected void Page_Load(object sender, EventArgs e)
    {
        con = new SqlConnection("Data Source=sandeep-pc\\priyanka;Initial Catalog=Priyanka;Integrated Security=True");
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection("Data Source=sandeep-pc\\priyanka;Initial Catalog=Priyanka;Integrated Security=True");
        SqlCommand cmd = new SqlCommand();
        cmd.CommandType = CommandType.Text;
        cmd.CommandText = "insert into Student(FName,LName,EmailId,Password,Gender,Age,ParentName,Address,City,State,ContactNo,Class,Subject1,Subject2,Subject3)values('" + txtFName.Text + "','" + txtLName.Text + "','" + txtEmail.Text + "','" + txtPasswrd.Text + "','" + RadioButtonList1.SelectedItem.Text + "'," + txtAge.Text + ",'" + txtParent.Text + "','" + txtAddress.Text + "','" + DropDnCity.SelectedItem.Text + "','" + DropDnState.SelectedItem.Text + "'," + txtContact.Text + "," + txtClass.Text + ",'" + txtSub1.Text + "','" + txtSub2.Text + "','" + txtSub3.Text + "')";
        cmd.Connection = con;
        con.Open();
        int ok = cmd.ExecuteNonQuery();
        if (ok > 0)
        {
            Label19.ForeColor = System.Drawing.Color.DeepPink;
            Label19.Text = "Registration Successful";
            Clear();
        }
        else
        {
            Label19.ForeColor = System.Drawing.Color.DeepPink;
            Label19.Text = "Registration Failed";
        }
        con.Close();
    }

    private void Clear()
    {
        txtFName.Text = "";
        txtLName.Text = "";
        txtEmail.Text = "";
        txtPasswrd.Text = "";
        txtAge.Text = "";
        txtParent.Text = "";
        txtAddress.Text = "";
        txtContact.Text = "";
        txtClass.Text = "";
        txtSub1.Text = "";
        txtSub2.Text = "";
        txtSub3.Text = "";
    }
}