Thread: ASP & PHP

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    1
    Rep Power
    0

    ASP & PHP


    I have following code made by some other program.. I am not able to understand what is Administration and how to create "webdev" similar like getemployee is created in the code like "DataView dataView = myAdmin.GetEmployees();"

    code...

    using System;
    using System.Collections;
    using System.Configuration;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Linq;

    public partial class Admin_Staff : System.Web.UI.Page
    {
    Administration myAdmin = new Administration();

    protected void Page_Load(object sender, EventArgs e)
    {
    if (!Page.IsPostBack)
    {
    BindData();
    }
    }


    protected void gridEmployees_RowCommand(object sender, GridViewCommandEventArgs e)
    {
    if (e.CommandName.Equals("Insert"))
    {

    myEmployee myEmployee = new myEmployee();
    myEmployee.name = ((TextBox)gridEmployees.FooterRow.FindControl("nameTextboxInsert")).Text;
    myEmployee.title = ((TextBox)gridEmployees.FooterRow.FindControl("titleTextboxInsert")).Text;
    myEmployee.phone = ((TextBox)gridEmployees.FooterRow.FindControl("phoneTextboxInsert")).Text;
    myEmployee.fax = ((TextBox)gridEmployees.FooterRow.FindControl("faxTextboxInsert")).Text;
    myEmployee.email = ((TextBox)gridEmployees.FooterRow.FindControl("emailTextboxInsert")).Text;
    myEmployee.position = ((TextBox)gridEmployees.FooterRow.FindControl("positionTextboxInsert")).Text;

    myAdmin.InsertEmployee(myEmployee);

    gridEmployees.ShowFooter = false;
    BindData();
    }

    }

    protected void gridEmployees_RowEditing(object sender, GridViewEditEventArgs e)
    {
    gridEmployees.EditIndex = e.NewEditIndex;
    BindData();
    }

    protected void gridEmployees_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
    {
    gridEmployees.EditIndex = -1;
    gridEmployees.ShowFooter = false;
    BindData();
    }

    protected void gridEmployees_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {

    myEmployee myEmployee = new myEmployee();
    myEmployee.employeeID = (int)gridEmployees.DataKeys[e.RowIndex].Value;
    myEmployee.name = ((TextBox)gridEmployees.Rows[e.RowIndex].FindControl("nameTextbox")).Text;
    myEmployee.title = ((TextBox)gridEmployees.Rows[e.RowIndex].FindControl("titleTextbox")).Text;
    myEmployee.phone = ((TextBox)gridEmployees.Rows[e.RowIndex].FindControl("phoneTextbox")).Text;
    myEmployee.fax = ((TextBox)gridEmployees.Rows[e.RowIndex].FindControl("faxTextbox")).Text;
    myEmployee.email = ((TextBox)gridEmployees.Rows[e.RowIndex].FindControl("emailTextbox")).Text;
    myEmployee.position = ((TextBox)gridEmployees.Rows[e.RowIndex].FindControl("positionTextbox")).Text;

    myAdmin.UpdateEmployee(myEmployee);

    gridEmployees.EditIndex = -1;
    BindData();
    }

    protected void gridEmployees_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
    Int32 employeeID = (int)gridEmployees.DataKeys[e.RowIndex].Value;

    myAdmin.DeleteEmployee(employeeID);

    gridEmployees.EditIndex = -1;
    BindData();

    }

    protected void InsertRecord(object sender, EventArgs e)
    {
    gridEmployees.ShowFooter = true;
    BindData();

    //go to the template bottom
    Page.MaintainScrollPositionOnPostBack = false;
    ClientScript.RegisterStartupScript(this.GetType(), "hash", "location.hash = '#new';", true);
    }


    // Sorting Gridview
    protected void gridEmployees_Sorting(object sender, GridViewSortEventArgs e)
    {

    if (Session["AdminTaskTable"] != null)
    {
    DataView dataView = Session["AdminTaskTable"] as DataView;
    dataView.Sort = e.SortExpression + " " + ConvertSortDirectionToSql();

    gridEmployees.DataSource = dataView;
    gridEmployees.DataBind();
    }

    }

    private string ConvertSortDirectionToSql()
    {

    string newSortDirection = String.Empty;

    if (ViewState["sortOrder"] == null || ViewState["sortOrder"].ToString() == "DESC")
    {
    newSortDirection = "ASC";
    }
    else
    {
    newSortDirection = "DESC";
    }


    ViewState["sortOrder"] = newSortDirection;
    return newSortDirection;

    }


    private void BindData()
    {

    DataView dataView = myAdmin.GetEmployees();
    Session["AdminTaskTable"] = dataView;
    gridEmployees.DataSource = dataView;
    gridEmployees.DataBind();

    }
    }
  2. #2
  3. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,429
    Rep Power
    4539
    I don't know what you're asking, but please use forum CODE tags around posted code. Try re-phrasing your question with more specific details.
    ======
    Doug G
    ======
    Bartender to Rene Descartes "have another beer?" Descartes: "I think not" and he vanished.
    --Alfred Bester

IMN logo majestic logo threadwatch logo seochat tools logo