Exemple #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));
    }
Exemple #2
0
    protected void FvInspectionIternary_DataBound(object sender, EventArgs e)
    {
        string Mode = String.Empty;

        switch (FvInspectionIternary.CurrentMode)
        {
        case FormViewMode.Edit:
            Mode = "Upd";
            break;

        case FormViewMode.Insert:
            Mode = "Ins";
            break;

        case FormViewMode.ReadOnly:
            Mode = "Itm";
            break;

        default:
            break;
        }

        // Get the Yearly Schedule Id
        Guid ScheduleId = new Guid(fldScheduleId.Value);
        // Get the Monthly schedule details for the selected Schedule
        Inspection   objInspection      = new Inspection();
        DataTable    dtScheduleDetails  = objInspection.GetYearlyInspectionDetailsById(ScheduleId);
        DropDownList ddlInspectionMonth = ((DropDownList)FvInspectionIternary.FindControl("ddlMonth" + Mode));

        GvInspectionDetails.DataSource = dtScheduleDetails;
        GvInspectionDetails.DataBind();
        if (dtScheduleDetails.Rows.Count > 0)
        {
            //int year= (int)dtScheduleDetails.Rows[0]["Year"];
            //Label lblYear = (Label)FvInspectionIternary.FindControl("lblYear" + Mode);
            //if (lblYear != null)
            //    lblYear.Text = Convert.ToString(year);

            //PopCalendar popInspectingDate = (PopCalendar)FvInspectionIternary.FindControl("popInspectingDate" + Mode);

            //RangeFrom DateFrom = new RangeFrom();
            //RangeTo DateTo = new RangeTo();

            //DateFrom.Date = new DateTime(year, ddlInspectionMonth.SelectedIndex, 01);
            //DateTo.Date = new DateTime(year, ddlInspectionMonth.SelectedIndex, DateTime.DaysInMonth(year, ddlInspectionMonth.SelectedIndex));

            //if (popInspectingDate != null){
            //popInspectingDate.From = DateFrom;
            //popInspectingDate.To = DateTo;
            //}
            ddlInspectionMonth.SelectedIndex = Convert.ToInt32(dtScheduleDetails.Rows[0]["Month"]);
        }
    }