Exemplo n.º 1
0
 protected void GvYearlyInspection_SelectedIndexChanged(object sender, EventArgs e)
 {
     // Get the Yearly Schedule Id
     Guid ScheduleId = (Guid)GvYearlyInspection.SelectedDataKey.Value;
     fldScheduleId.Value = Convert.ToString(ScheduleId);
     // Get the Monthly schedule details for the selected Schedule
     Inspection objInspection = new Inspection();
     DataTable dtScheduleDetails = objInspection.GetYearlyInspectionDetailsById(ScheduleId);
     DataTable dtOfficeDetails = new Inspection().GetMonthlyInspectionScheduleByDetailScheduleId(ScheduleId);
     string officeNames = "";
     // Get the selected Offices
     if (dtScheduleDetails.Rows.Count > 0)
     {
         foreach (DataRow drScheduleDetail in dtScheduleDetails.Rows)
         {
             officeNames = "";
             DataRow[] drOfficeDetail = dtOfficeDetails.Select("DetailScheduleId='" + drScheduleDetail["DetailScheduleId"].ToString() + "'");
             for (int i = 0; i < drOfficeDetail.Length; i++)
             {
                 officeNames += Convert.ToString(drOfficeDetail[i]["OfficeName"]) + ", ";
             }
             // Remove the coma at the end of the string
             if (officeNames.Length > 2)
             {
                 officeNames = officeNames.Substring(0, officeNames.Length - 2);
             }
             drScheduleDetail["OfficeName"] = officeNames;
         }
         GvInspectionDetails.DataSource = dtScheduleDetails;
         GvInspectionDetails.DataBind();
     }
     //DropDownList ddlInspectionMonth = ((DropDownList)FvInspectionIternary.FindControl("ddlMonth" + Mode));
 }
    protected void FvYearlySchedule_DataBound(object sender, EventArgs e)
    {
        if (FvYearlySchedule.CurrentMode == FormViewMode.Edit)
        {
            // Get the Yearly Schedule Id
            Guid ScheduleId = (Guid)GvYearlyInspection.SelectedDataKey.Values["ScheduleId"];
            // Get the Monthly schedule details for the selected Schedule
            Inspection objInspection = new Inspection();
            DataTable dtScheduleDetails = objInspection.GetYearlyInspectionDetailsById(ScheduleId);
            DataTable dtOfficeDetails = new Inspection().GetMonthlyInspectionScheduleByDetailScheduleId(ScheduleId);
            string officeNames = "";
            // Get the selected Offices
            if (dtScheduleDetails.Rows.Count > 0)
            {
                foreach (DataRow drScheduleDetail in dtScheduleDetails.Rows)
                {
                    officeNames = "";
                    DataRow[] drOfficeDetail = dtOfficeDetails.Select("DetailScheduleId='" + drScheduleDetail["DetailScheduleId"].ToString() + "'");
                    for (int i = 0; i < drOfficeDetail.Length; i++)
                    {
                        officeNames += Convert.ToString(drOfficeDetail[i]["OfficeName"]) + ", ";
                    }
                    // Remove the coma at the end of the string
                    if (officeNames.Length > 2)
                    {
                        officeNames = officeNames.Substring(0, officeNames.Length - 2);
                    }
                    drScheduleDetail["OfficeName"] = officeNames;
                }

                ViewState["ScheduleDetails"] = dtScheduleDetails;
                ViewState["SelectedOffices"] = dtOfficeDetails;

                GridView grd = (GridView)FvYearlySchedule.FindControl("GvInspectionDetailsUpd");
                grd.DataSource = dtScheduleDetails;
                grd.SelectedIndex = -1;
                grd.DataBind();
            }
        }
    }