Exemple #1
0
        protected void rgSANAL_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item.IsInEditMode)
            {
                GridEditableItem item = (GridEditableItem)e.Item;

                int period_id = Convert.ToInt32(item.GetDataKeyValue("period_id"));
                var period    = db.RecordAnalysisPeriods.FirstOrDefault(p => p.period_id == period_id);

                RadDropDownList rddlAnalyzedBy = (RadDropDownList)item.FindControl("rddlAnalyzedBy");
                RadDatePicker   rdpAnalyzedDt  = (RadDatePicker)item.FindControl("rdpAnalyzedDt");
                RadDropDownList rddlApprovedBy = (RadDropDownList)item.FindControl("rddlApprovedBy");
                RadDatePicker   rdpApprovedDt  = (RadDatePicker)item.FindControl("rdpApprovedDt");
                RadEditor       reSANAL        = (RadEditor)item.FindControl("reSANAL");

                //Analyzer & Approver
                var personnel = db.SP_Personnel_by_WSC_office_or_user_id(period.Record.Site.Office.wsc_id, 0, "", "no", "All", "no");
                rddlAnalyzedBy.DataSource = personnel;
                rddlAnalyzedBy.DataBind();
                rddlApprovedBy.DataSource = personnel;
                rddlApprovedBy.DataBind();
                if (!string.IsNullOrEmpty(period.analyzed_by))
                {
                    rddlAnalyzedBy.SelectedValue = period.analyzed_by;
                    rdpAnalyzedDt.SelectedDate   = period.analyzed_dt;
                }
                else
                {
                    rddlAnalyzedBy.Items.Insert(0, new DropDownListItem {
                        Value = "", Text = ""
                    });
                }
                if (!string.IsNullOrEmpty(period.approved_by))
                {
                    rddlApprovedBy.SelectedValue = period.approved_by;
                    rdpApprovedDt.SelectedDate   = period.approved_dt;
                }
                else
                {
                    rddlApprovedBy.Items.Insert(0, new DropDownListItem {
                        Value = "", Text = ""
                    });
                }

                reSANAL.Content = period.analysis_notes_va.FormatParagraphEdit();
            }
        }
Exemple #2
0
        protected void PopulateEditRecordPanel(string option)
        {
            //Time-series IDs
            if (option == "nonts_noid") //Creating a non-ts record with no IDs
            {
                ltlTimeSeriesLabel.Visible = false;
                pnlAssignedIDs.Visible     = false;
            }
            else //Creating or editing a non-ts or ts record with IDs
            {
                if (option == "editcurrentrecord") //editing a current record
                {
                    if (record.RecordDDs.Count() > 0)
                    {
                        ltlTimeSeriesLabel.Visible = true;
                        pnlAssignedIDs.Visible     = true;
                        ltlAssignedIDs.Text        = "";
                        var ts_ids = db.SP_RMS_Get_Record_DDs(record.rms_record_id);
                        foreach (var id in ts_ids)
                        {
                            ltlAssignedIDs.Text += id.dd_ts_ds + ", ";
                        }
                        ltlAssignedIDs.Text.TrimEnd(' ').TrimEnd(',');
                    }
                    else if (!(bool)record.RecordType.ts_fg)
                    {
                        ltlTimeSeriesLabel.Visible = false;
                        pnlAssignedIDs.Visible     = false;
                    }
                    else
                    {
                        ltlTimeSeriesLabel.Visible = true;
                        pnlAssignedIDs.Visible     = true;
                    }
                }
                else //creating a new record with IDs
                {
                    ltlTimeSeriesLabel.Visible = true;
                    pnlAssignedIDs.Visible     = false;
                    pnlEditIDs.Visible         = true;
                    SetupIDCheckBoxList();
                }
            }

            //Record-type drop down
            var ts_record_types    = db.RecordTypes.Where(p => p.wsc_id == site.Office.wsc_id && p.ts_fg == true);
            var nonts_record_types = db.RecordTypes.Where(p => p.wsc_id == site.Office.wsc_id && p.ts_fg == false);

            if (option == "editcurrentrecord") //Editing record
            {
                if ((bool)record.RecordType.ts_fg)
                {
                    rddlRecordTypes.DataSource = ts_record_types;
                }
                else
                {
                    rddlRecordTypes.DataSource = nonts_record_types;
                }

                rddlRecordTypes.SelectedValue = record.record_type_id.ToString();
            }
            else if (option == "ts_id") //Creating a time-series record, so populate record-type drop down with time-series record types
            {
                rddlRecordTypes.DataSource = ts_record_types;
            }
            else //Creating a non-time-series record, so populate record-type drop down with non-time-series record types
            {
                rddlRecordTypes.DataSource = nonts_record_types;
            }

            rddlRecordTypes.DataBind();

            //Category Number
            if (option == "editcurrentrecord") //Show, and populate
            {
                //Show the category selection for both ts and nts records
                rddlCatNumber.SelectedValue = record.category_no.ToString();
                if (record.category_no > 1)
                {
                    rtbCatReason.Visible = true;
                    rtbCatReason.Text    = record.cat_reason;
                }
                else
                {
                    rtbCatReason.Visible = false;
                }
            }
            else //Show, and enable
            {
                rtbCatReason.Visible = false;
            }

            //Operator/Analyzer/Approver/Auditor
            var personnel = db.SP_Personnel_by_WSC_office_or_user_id(site.Office.wsc_id, 0, "", "no", "True", "no");

            rddlOperator.DataSource = personnel;
            rddlOperator.DataBind();
            rddlAnalyzer.DataSource = personnel;
            rddlAnalyzer.DataBind();
            rddlApprover.DataSource = personnel;
            rddlApprover.DataBind();
            rddlAuditor.DataSource = personnel;
            rddlAuditor.DataBind();
            if (option == "editcurrentrecord")
            {
                rddlOperator.SelectedValue = record.operator_uid;
                rddlAnalyzer.SelectedValue = record.analyzer_uid;
                rddlApprover.SelectedValue = record.approver_uid;
                rddlAuditor.SelectedValue  = record.auditor_uid;
                //if (!string.IsNullOrEmpty(record.operator_uid)) rddlOperator.SelectedValue = record.operator_uid; else rddlOperator.Items.Insert(0, new DropDownListItem { Value = "", Text = "" });
                //if (!string.IsNullOrEmpty(record.analyzer_uid)) rddlAnalyzer.SelectedValue = record.analyzer_uid; else rddlAnalyzer.Items.Insert(0, new DropDownListItem { Value = "", Text = "" });
                //if (!string.IsNullOrEmpty(record.approver_uid)) rddlApprover.SelectedValue = record.approver_uid; else rddlApprover.Items.Insert(0, new DropDownListItem { Value = "", Text = "" });
                //if (!string.IsNullOrEmpty(record.auditor_uid)) rddlAuditor.SelectedValue = record.auditor_uid; else rddlAuditor.Items.Insert(0, new DropDownListItem { Value = "", Text = "" });
            }

            rddlOperator.Items.Insert(0, new DropDownListItem {
                Value = "", Text = ""
            });
            rddlAnalyzer.Items.Insert(0, new DropDownListItem {
                Value = "", Text = ""
            });
            rddlApprover.Items.Insert(0, new DropDownListItem {
                Value = "", Text = ""
            });
            rddlAuditor.Items.Insert(0, new DropDownListItem {
                Value = "", Text = ""
            });


            //Approver email
            int office_id = Convert.ToInt32(site.office_id);

            if (option == "editcurrentrecord")
            {
                if (record.RecordAltOffice != null)
                {
                    office_id = Convert.ToInt32(record.RecordAltOffice.alt_office_id);
                }
            }
            ltlApproverEmail.Text = db.Offices.FirstOrDefault(p => p.office_id == office_id).reviewer_email;

            //Field Trips
            string fieldtrips = "";

            foreach (var trip in site.TripSites.ToList())
            {
                fieldtrips += trip.Trip.trip_nm + " - " + trip.Trip.user_id + ", ";
            }
            if (!string.IsNullOrEmpty(fieldtrips))
            {
                ltlFieldTrips.Text = fieldtrips.TrimEnd(' ').TrimEnd(',');
            }
            else
            {
                ltlFieldTrips.Text = "<i>none assigned</i>";
            }

            //Responsible Office
            rddlResponsibleOffice.DataSource = db.Offices.Where(p => p.wsc_id == site.Office.wsc_id).ToList();
            rddlResponsibleOffice.DataBind();
            rddlResponsibleOffice.SelectedValue = office_id.ToString();

            //Threatened Gage
            if (record != null)
            {
                var tg_newest = record.EndangeredGages.OrderByDescending(p => p.entered_dt).FirstOrDefault();
                if (tg_newest != null)
                {
                    pnlThreatenedGage.Visible = true;
                    rcbThreatenedGage.Checked = true;
                    tbRemarks.Text            = tg_newest.remarks;
                    rntbYearsOfRecord.Value   = tg_newest.years_of_record;
                    rcbStatus.SelectedValue   = tg_newest.status;
                    rdpSunsetDt.SelectedDate  = tg_newest.sunset_dt;
                    if (tg_newest.status != "Discontinued")
                    {
                        rcbRecordInactive.Enabled = false; //If this is an endangered gage, and the status it not discontinued, do not allow them to set the record to inactive
                        ltlInactiveNotice.Visible = true;
                    }
                }
                else
                {
                    pnlThreatenedGage.Visible = false;
                    rcbThreatenedGage.Checked = false;
                }
            }
            else
            {
                pnlThreatenedGage.Visible = false;
                rcbThreatenedGage.Checked = false;
            }

            //Checkboxesif
            if (option == "editcurrentrecord")
            {
                rcbRecordInactive.Checked = record.not_used_fg;
            }

            //Other records Panel
            if (option == "editcurrentrecord")
            {
                pnlOtherRecords.Visible = false;
            }
            else
            {
                pnlOtherRecords.Visible = true;
                PopulateOtherRecordsPanel();
            }
        }