Exemplo n.º 1
0
    //Method called when the update and confirm button has been pressed
    protected void EmployeeGridView_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        //Collects info from edited lines in the table
        GridViewRow row = (GridViewRow)EmployeeGridView.Rows[e.RowIndex];

        Label   textid    = EmployeeGridView.Rows[e.RowIndex].FindControl("lbl_ID") as Label;
        TextBox textAdmin = (TextBox)row.Cells[4].Controls[0];
        TextBox textDepID = (TextBox)row.Cells[5].Controls[0];
        TextBox textPhone = (TextBox)row.Cells[7].Controls[0];
        TextBox textEmail = (TextBox)row.Cells[8].Controls[0];

        //Converts the admin text from yes or no into a 1/0 bit
        textAdmin.Text = textAdmin.Text == "YES" ? "1" : "0";

        //Resets the edit index
        EmployeeGridView.EditIndex = -1;

        //A new transactionscope is sent and returns and displays whether it is successful or not
        if (CreateTransactionScope.MakeTransactionScope(String.Format("Exec EmployeeModal @Action = 'Update', @EmployeeID = '{0}', @Admin = '{1}', @DepartmentID = '{2}', @Email = '{3}', @Phone = '{4}'",
                                                                      textid.Text, textAdmin.Text, textDepID.Text, textEmail.Text, textPhone.Text)) > 0)
        {
            //Sets the label text to saying the transaction was successful
            emplbl.Text    = "Employee was successfully edited";
            emplbl.Visible = true;
        }
        else
        {
            //Sets the label text to saying the transaction was not successful
            emplbl.Text    = "One or more fields were invalid changes reverted";
            emplbl.Visible = true;
        }

        //The table is refreshed
        Binding(Base.RefreshTable());
    }
    //Method called when pressing the update button
    protected void DepartmentsGridView_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        //Collects info from edited lines in the table
        GridViewRow row      = (GridViewRow)DepartmentsGridView.Rows[e.RowIndex];
        Label       textid   = DepartmentsGridView.Rows[e.RowIndex].FindControl("lbl_DID") as Label;
        TextBox     textName = (TextBox)row.Cells[3].Controls[0];


        //Resets the edit index
        DepartmentsGridView.EditIndex = -1;

        //A new transactionscope is sent and returns and displays whether it is successful or not
        if (CreateTransactionScope.MakeTransactionScope(String.Format("Exec DepartmentModal @Action = 'Update', @ID = '{0}', @Name = '{1}'", textid.Text, textName.Text)) > 0)

        {
            //Sets the label text to saying the transaction was successful
            deplbl.Text    = "Department was successfully edited";
            deplbl.Visible = true;
        }
        else
        {
            //Sets the label text to saying the transaction was not successful
            deplbl.Text    = "One or more fields were invalid changes reverted";
            deplbl.Visible = true;
        }
        //The table is refreshed
        Binding(Base.RefreshTable());
    }
Exemplo n.º 3
0
    //Used and called when details button is pressed on the gridview
    protected void GridView1_OnRowCommand(object sender, GridViewCommandEventArgs e)
    {
        //Used to see which command on the row is being called
        if (e.CommandName == "Details")
        {
            //converts retrieved command argument to int for index
            int         index = Convert.ToInt32(e.CommandArgument.ToString());
            GridViewRow row   = PurchaseOrdersGridView.Rows[index];

            //temporary array to store all needed strings for string query
            string[] squery = { row.Cells[0].Text, row.Cells[2].Text, row.Cells[3].Text, row.Cells[4].Text };
            //appends array strings to be sent to response redirect
            string qstring = "/purchaseorderlines.aspx?purchid=" + squery[0] + "&name=" + squery[1] + "&odate=" + squery[2] + "&ddate=" + squery[3];

            //Redirects and attaches purchid of purchase order to query string
            Response.Redirect(qstring);
        }
        else if (e.CommandName == "ConfDeliv")
        {
            int         index = Convert.ToInt32(e.CommandArgument.ToString());
            GridViewRow row   = PurchaseOrdersGridView.Rows[index];

            CreateTransactionScope.MakeTransactionScope(String.Format("Update PurchaseOrder SET DateDelivered = '{0}' WHERE PurchID = '{1}'", DateTime.Now, row.Cells[0].Text));
            this.Binding(Base.RefreshTable());
        }
    }
 protected void ItemLookUpGridView_RowEditing(object sender, GridViewEditEventArgs e)
 {
     //NewEditIndex property used to determine the index of the row being edited.
     ItemLookUpGridView.EditIndex = e.NewEditIndex;
     Binding(Base.RefreshTable());
 }