Example #1
0
        public jobs getJob(int jobID)
        {
            string connection = @"Server=ADMIN-DC8F2C7DE\SQLEXPRESS;Database=InstituteSite;Trusted_Connection=True;";

            string        query        = "select Job_ID , Job_Name, Job_Salary, Job_Qualification from Jobs where Job_ID=" + jobID;
            SqlConnection dbConnection = new SqlConnection(connection);

            dbConnection.Open();

            SqlCommand dbCommand = new SqlCommand();

            dbCommand = new SqlCommand(query, dbConnection);
            SqlDataReader queryData = dbCommand.ExecuteReader();
            DataTable     dt        = new DataTable();

            if (queryData.HasRows)
            {
                dt.Load(queryData);
                jobs job = new jobs();
                job.Job_ID            = int.Parse(dt.Rows[0][0].ToString());
                job.Job_Name          = dt.Rows[0][1].ToString();
                job.Job_Salary        = decimal.Parse(dt.Rows[0][2].ToString());
                job.Job_Qualification = dt.Rows[0][3].ToString();
                return(job);
            }
            else
            {
                return(null);
            }
        }
Example #2
0
 private void exposeData(jobs job)
 {
     hdnID2.Value      = job.Job_ID.ToString();
     txtJobName.Text   = job.Job_Salary.ToString();
     txtJobSalary.Text = job.Job_Salary.ToString();
     txtJobName.Text   = job.Job_Qualification.ToString();
     div1.Visible      = true;
 }
Example #3
0
        private jobs GetDataFormPage()
        {
            jobs job = new jobs();

            job.Job_Name          = txtJobName.Text;
            job.Job_Salary        = decimal.Parse(txtJobSalary.Text.ToString());
            job.Job_Qualification = txtJobName.Text;
            return(job);
        }
Example #4
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            jobs job = GetDataFormPage();

            job.Job_ID = int.Parse(hdnID2.Value);
            deleteJob(job.Job_ID);

            grdJobs.DataSource = getAllJobs();
            grdJobs.DataBind();
            div1.Visible = false;
        }
Example #5
0
 protected void grdJobs_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
 {
     if (e.CommandName == "EditData")
     {
         HiddenField hdnID = (HiddenField)e.Item.FindControl("hdnID");
         int         jobID = int.Parse(hdnID.Value);
         jobs        job   = getJob(jobID);
         if (job != null)
         {
             Mode = PageMode.Edit;
             exposeData(job);
         }
     }
 }
Example #6
0
        public static int updateJob(jobs job)
        {
            string query = "update jobs Job_Name='" + job.Job_Name + "', Job_Salary = " + job.Job_Salary +
                           ", Job_Qualification ='" + job.Job_Qualification + "') where Job_ID = " + job.Job_ID;

            string connection = @"Server=ADMIN-DC8F2C7DE\SQLEXPRESS;Database=InstituteSite;Trusted_Connection=True;";

            SqlConnection dbConnection = new SqlConnection(connection);

            dbConnection.Open();
            SqlCommand dbCommand = new SqlCommand();

            SqlCommand myCommand = new SqlCommand(query, dbConnection);
            int        rows      = myCommand.ExecuteNonQuery();

            return(rows);
        }
Example #7
0
        public static int insertJob(jobs job)
        {
            string query = "insert into jobs (Job_ID , Job_Name, Job_Salary, Job_Qualification) values (" + job.Job_ID +
                           ",'" + job.Job_Name + "'," + job.Job_Salary + ",'" + job.Job_Qualification + "')";

            string connection = @"Server=ADMIN-DC8F2C7DE\SQLEXPRESS;Database=InstituteSite;Trusted_Connection=True;";

            SqlConnection dbConnection = new SqlConnection(connection);

            dbConnection.Open();
            SqlCommand dbCommand = new SqlCommand();

            SqlCommand myCommand = new SqlCommand(query, dbConnection);
            int        rows      = myCommand.ExecuteNonQuery();

            return(rows);
        }
Example #8
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            jobs job = GetDataFormPage();

            if (Mode == PageMode.Add)
            {
                insertJob(job);
            }
            else
            {
                job.Job_ID = int.Parse(hdnID2.Value);
                updateJob(job);
            }

            grdJobs.DataSource = getAllJobs();
            grdJobs.DataBind();
            div1.Visible = false;
        }