コード例 #1
0
 //
 //BTN CRAETE NEW INCIDENT CLICK
 /// <summary>
 /// Insert the new record in the database and update the gridview and formview accordingly
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void BtnCreateNewIncident_Click(object sender, EventArgs e)
 {
     try
     {
         //Call the Insert method against the SqlDataSource_Incidents which then updates the database
         SqlDataSource_Incidents.Insert();
         //Refresh both the gridview and formview with the new incident
         GridView_Incidents.DataBind();
         FormView_Incidents.DataBind();
         //Bring back to the incident list page
         this.Incidents_MultiView.ActiveViewIndex = 0;
         //Reset the form
         resetNewIncidentForm();
     }
     catch (InvalidOperationException ex)
     {
         Session["Exception"] = ex;
     }
     catch (Exception ex)
     {
         Session["Exception"] = ex;
     }
 }
コード例 #2
0
        //
        //UPDATE INCIDENT
        //
        #region UPDATE INCIDENT


        //
        //BTN UPDATE CLICK
        /// <summary>
        /// Perform the updating of the selected incident in the database and then refresh the gridview and the formview
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void BtnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                //Call the Update method of SqlDataSource_FormViewIncident which executes the update query updating the
                //selected record
                SqlDataSource_FormViewIncident.Update();
                //Call the DataBind method for both the gridview and the formview refreshing the incident with the new changes
                GridView_Incidents.DataBind();
                FormView_Incidents.DataBind();
                //Display the view incident details page
                this.Incidents_MultiView.ActiveViewIndex = 1;
                //Reset the form
                ResetUpdateForm();
            }
            catch (InvalidOperationException ex)
            {
                Session["Exception"] = ex;
            }
            catch (Exception ex)
            {
                Session["Exception"] = ex;
            }
        }