示例#1
0
 public static Record CreateRecord(Data.Record record) => new Record
 {
     Day = record.Day,
     MobileCountryCode = record.Country.MobileCode.ToString(),
     PricePerSMS       = Math.Round(record.Country.PricePerSMS, 2),
     Count             = record.Count,
     TotalPrice        = Math.Round(record.Country.PricePerSMS * record.Count, 2)
 };
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string rms_record_id = Request.QueryString["rms_record_id"];
            string rms_audit_id  = Request.QueryString["rms_audit_id"];

            //If rms_record_id was passed, then set the RecordID variable and make sure the WSCID and OfficeID are changed to match the RecordIDs office and WSC
            if (!string.IsNullOrEmpty(rms_record_id))
            {
                RecordID   = Convert.ToInt32(rms_record_id);
                currRecord = db.Records.Where(p => p.rms_record_id == RecordID).FirstOrDefault();
                if (currRecord.RecordAltOffice == null)
                {
                    OfficeID = (int)currRecord.Site.office_id;
                }
                else
                {
                    OfficeID = (int)currRecord.RecordAltOffice.alt_office_id;
                }
                WSCID = (int)db.Offices.Where(p => p.office_id == OfficeID).FirstOrDefault().wsc_id;
            }
            else
            {
                RecordID = 0;
            }

            if (!string.IsNullOrEmpty(rms_audit_id))
            {
                AuditID   = Convert.ToInt32(rms_audit_id);
                currAudit = db.Audits.Where(p => p.rms_audit_id == AuditID).FirstOrDefault();
                WSCID     = (int)currAudit.wsc_id;
                OfficeID  = db.Offices.FirstOrDefault(p => p.wsc_id == WSCID).office_id;
            }
            else
            {
                AuditID = 0;
            }

            UserControlSetup();

            if (!Page.IsPostBack)
            {
                //If the user belongs to this site's WSC (or has an exception to work in the WSC), or is a SuperUser, then allow them to edit the page
                if (user.WSCID.Contains(WSCID) || user.IsSuperUser)
                {
                    pnlHasAccess.Visible = true;
                    pnlNoAccess.Visible  = false;

                    InitialView();
                }
                else
                {
                    pnlHasAccess.Visible = false;
                    pnlNoAccess.Visible  = true;
                }
            }
        }
示例#3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string office_id = Request.QueryString["office_id"];

            if (!string.IsNullOrEmpty(office_id))
            {
                OfficeID = Convert.ToInt32(office_id);
                WSCID    = Convert.ToInt32(db.Offices.FirstOrDefault(p => p.office_id == OfficeID).wsc_id);
            }
            else
            {
                //If the office id and wsc id session variables are empty, set these values to the user's assigned office
                if (OfficeID == 0 && WSCID == 0)
                {
                    OfficeID = user.OfficeID;
                    WSCID    = (int)db.Offices.FirstOrDefault(p => p.office_id == OfficeID).wsc_id;
                }
                else if (OfficeID == 0 && WSCID > 0)
                {
                    OfficeID = db.Offices.FirstOrDefault(p => p.wsc_id == WSCID).office_id;
                }
                else if (OfficeID > 0 && WSCID == 0)
                {
                    WSCID = (int)db.Offices.FirstOrDefault(p => p.office_id == OfficeID).wsc_id;
                }
            }

            string wsc_nm = db.WSCs.FirstOrDefault(p => p.wsc_id == WSCID).wsc_nm;

            ph1.Title = "Retrieve Record Period Details";

            if (RecordID == 0 || Request.QueryString["type"] == "wsc")
            {
                ph1.SubTitle   = "For the " + wsc_nm + " WSC";
                ph1.RecordType = " ";
            }
            else
            {
                currRecord     = db.Records.FirstOrDefault(p => p.rms_record_id == RecordID);
                ph1.SubTitle   = currRecord.Site.site_no + " " + db.vSITEFILEs.FirstOrDefault(s => s.site_id == currRecord.Site.nwisweb_site_id).station_nm;
                ph1.RecordType = currRecord.RecordType.type_ds + " Record for";
            }

            if (!Page.IsPostBack)
            {
                InitialDataBind();
            }
        }
示例#4
0
 protected void rgSANAL_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
 {
     if (rddlRecords.SelectedIndex > 0)
     {
         record             = db.Records.FirstOrDefault(p => p.rms_record_id == Convert.ToInt32(rddlRecords.SelectedValue));
         rgSANAL.DataSource = record.RecordAnalysisPeriods.Where(p => p.status_va == "Approved").Select(p => new {
             period_id             = p.period_id,
             rms_record_id         = p.rms_record_id,
             period_beg_dt         = p.period_beg_dt,
             period_end_dt         = p.period_end_dt,
             status_va             = p.status_va,
             site_no               = p.Record.Site.site_no,
             station_nm            = p.Record.Site.station_full_nm,
             type_ds               = p.Record.RecordType.type_ds,
             status_set_by_role_va = p.status_set_by_role_va
         }).OrderBy(p => p.period_beg_dt).ToList();
     }
 }
示例#5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string rms_record_id = Request.QueryString["rms_record_id"];
            string rms_audit_id  = Request.QueryString["rms_audit_id"];
            string office_id     = Request.QueryString["office_id"];

            if (!string.IsNullOrEmpty(office_id))
            {
                OfficeID = Convert.ToInt32(office_id);
                WSCID    = Convert.ToInt32(db.Offices.FirstOrDefault(p => p.office_id == OfficeID).wsc_id);
            }
            else
            {
                //If rms_record_id was passed, then set the RecordID variable and make sure the WSCID and OfficeID are changed to match the RecordIDs office and WSC
                if (!string.IsNullOrEmpty(rms_record_id))
                {
                    RecordID   = Convert.ToInt32(rms_record_id);
                    currRecord = db.Records.Where(p => p.rms_record_id == RecordID).FirstOrDefault();
                    if (currRecord.RecordAltOffice == null)
                    {
                        OfficeID = (int)currRecord.Site.office_id;
                    }
                    else
                    {
                        OfficeID = (int)currRecord.RecordAltOffice.alt_office_id;
                    }
                    WSCID = (int)db.Offices.Where(p => p.office_id == OfficeID).FirstOrDefault().wsc_id;
                }
                else
                {
                    RecordID = 0;
                }

                if (!string.IsNullOrEmpty(rms_audit_id))
                {
                    AuditID   = Convert.ToInt32(rms_audit_id);
                    currAudit = db.Audits.Where(p => p.rms_audit_id == AuditID).FirstOrDefault();
                    WSCID     = (int)currAudit.wsc_id;
                    OfficeID  = db.Offices.FirstOrDefault(p => p.wsc_id == WSCID).office_id;
                }
                else
                {
                    AuditID = 0;
                }
            }

            if (OfficeID == 0 || WSCID == 0)
            {
                OfficeID = user.OfficeID;
                WSCID    = (int)db.Offices.FirstOrDefault(p => p.office_id == OfficeID).wsc_id;
            }
            else if (OfficeID == 0 && WSCID > 0)
            {
                OfficeID = db.Offices.FirstOrDefault(p => p.wsc_id == WSCID).office_id;
            }
            else if (OfficeID > 0 && WSCID == 0)
            {
                WSCID = (int)db.Offices.FirstOrDefault(p => p.office_id == OfficeID).wsc_id;
            }

            if (!Page.IsPostBack)
            {
                UserControlSetup();
            }
        }
示例#6
0
        protected void EditRecord(object sender, EventArgs e)
        {
            string error = GetErrorText();

            if (string.IsNullOrEmpty(error))
            {
                //If updating a current record
                if (record != null)
                {
                    //Update the time-series ID
                    if (hfEditIDs.Value == "true")
                    {
                        db.RecordDDs.DeleteAllOnSubmit(record.RecordDDs);
                        db.SubmitChanges();

                        foreach (ButtonListItem item in rcblIDs.Items)
                        {
                            if (item.Selected)
                            {
                                //Using the selected IDs gu_id value, find the full details for the ID in the TS_ID_CACHE, and create a new entry in the Record DD table
                                var           ts_id = db.vTS_ID_CACHEs.FirstOrDefault(p => p.gu_id == item.Value);
                                Data.RecordDD id;

                                id = new Data.RecordDD()
                                {
                                    rms_record_id = record.rms_record_id,
                                    iv_ts_id      = ts_id.iv_ts_id,
                                    dd_nu         = ts_id.adaps_dd_nu,
                                    gu_id         = ts_id.gu_id
                                };
                                db.RecordDDs.InsertOnSubmit(id);
                                db.SubmitChanges();
                            }
                        }
                    }

                    //Update the record-type
                    record.record_type_id = Convert.ToInt32(rddlRecordTypes.SelectedValue);
                    //Update the category number
                    record.category_no = Convert.ToInt32(rddlCatNumber.SelectedValue);
                    record.cat_reason  = rtbCatReason.Text;
                    //Update the operator, analyzer and approver
                    record.operator_uid = rddlOperator.SelectedValue;
                    record.analyzer_uid = rddlAnalyzer.SelectedValue;
                    record.approver_uid = rddlApprover.SelectedValue;
                    record.auditor_uid  = rddlAuditor.SelectedValue;
                    //Update the responsible office
                    if (record.RecordAltOffice != null)
                    {
                        //First delete the alt office that might be there
                        db.RecordAltOffices.DeleteOnSubmit(record.RecordAltOffice);
                        db.SubmitChanges();
                    }
                    //If an alt office was selected other than the site assigned office, add it to the alt office table
                    if (rddlResponsibleOffice.SelectedValue != record.Site.office_id.ToString())
                    {
                        db.RecordAltOffices.InsertOnSubmit(new Data.RecordAltOffice()
                        {
                            rms_record_id = record.rms_record_id,
                            site_id       = record.site_id,
                            alt_office_id = Convert.ToInt32(rddlResponsibleOffice.SelectedValue)
                        });
                        db.SubmitChanges();
                    }
                    //Update the threatened gage
                    var tg_newest = record.EndangeredGages.OrderByDescending(p => p.entered_dt).FirstOrDefault();
                    if ((bool)rcbThreatenedGage.Checked)
                    {
                        if (tg_newest != null)
                        {
                            //If there was a change to any of the threatened gage field values, then need to create a new record for it in the database table
                            if (tg_newest.remarks != tbRemarks.Text || tg_newest.years_of_record != rntbYearsOfRecord.Value || tg_newest.status != rcbStatus.SelectedValue.ToString() || tg_newest.sunset_dt != rdpSunsetDt.SelectedDate)
                            {
                                var tg_new = new Data.EndangeredGage();
                                tg_new.rms_record_id   = record.rms_record_id;
                                tg_new.remarks         = tbRemarks.Text;
                                tg_new.years_of_record = Convert.ToInt32(rntbYearsOfRecord.Value);
                                tg_new.status          = rcbStatus.SelectedValue.ToString();
                                tg_new.sunset_dt       = rdpSunsetDt.SelectedDate;
                                tg_new.entered_by      = user.ID;
                                tg_new.entered_dt      = DateTime.Now;
                                db.EndangeredGages.InsertOnSubmit(tg_new);
                            }
                            //Otherwise, do nothing
                        }
                        else //Adding to the threatened gage table for the first time
                        {
                            var tg_new = new Data.EndangeredGage();
                            tg_new.rms_record_id   = record.rms_record_id;
                            tg_new.remarks         = tbRemarks.Text;
                            tg_new.years_of_record = Convert.ToInt32(rntbYearsOfRecord.Value);
                            tg_new.status          = rcbStatus.SelectedValue.ToString();
                            tg_new.sunset_dt       = rdpSunsetDt.SelectedDate;
                            tg_new.entered_by      = user.ID;
                            tg_new.entered_dt      = DateTime.Now;
                            db.EndangeredGages.InsertOnSubmit(tg_new);
                        }
                    }
                    else //The checkbox was not checked
                    {
                        //But, there is history of threatened gage data for this record, what happens now?? - NEED SONYA OR BRIAN HELP!
                        if (tg_newest != null)
                        {
                        }
                    }
                    //Checkbox
                    record.not_used_fg = rcbRecordInactive.Checked;

                    if ((bool)record.not_used_fg) //If setting the record to inactive, make sure to delete any TS IDs tied to the record
                    {
                        var tsIDs = record.RecordDDs.ToList();
                        db.RecordDDs.DeleteAllOnSubmit(tsIDs);
                    }

                    db.SubmitChanges();
                }
                else //Create a new record
                {
                    Data.Record new_record = new Data.Record();

                    new_record.site_id        = site.site_id;
                    new_record.operator_uid   = rddlOperator.SelectedValue;
                    new_record.analyzer_uid   = rddlAnalyzer.SelectedValue;
                    new_record.approver_uid   = rddlApprover.SelectedValue;
                    new_record.auditor_uid    = rddlAuditor.SelectedValue;
                    new_record.not_used_fg    = rcbRecordInactive.Checked;
                    new_record.record_type_id = Convert.ToInt32(rddlRecordTypes.SelectedValue);
                    new_record.category_no    = Convert.ToInt32(rddlCatNumber.SelectedValue);
                    new_record.cat_reason     = rtbCatReason.Text;

                    db.Records.InsertOnSubmit(new_record);
                    db.SubmitChanges();

                    //Add the time-series ID
                    if (hfEditIDs.Value == "true")
                    {
                        foreach (ButtonListItem item in rcblIDs.Items)
                        {
                            if (item.Selected)
                            {
                                //Using the selected IDs gu_id value, find the full details for the ID in the TS_ID_CACHE, and create a new entry in the Record DD table
                                var           ts_id = db.vTS_ID_CACHEs.FirstOrDefault(p => p.gu_id == item.Value);
                                Data.RecordDD id;

                                id = new Data.RecordDD()
                                {
                                    rms_record_id = new_record.rms_record_id,
                                    iv_ts_id      = ts_id.iv_ts_id,
                                    dd_nu         = ts_id.adaps_dd_nu,
                                    gu_id         = ts_id.gu_id
                                };
                                db.RecordDDs.InsertOnSubmit(id);
                                db.SubmitChanges();
                            }
                        }
                    }

                    //If an alt office was selected other than the site assigned office, add it to the alt office table
                    if (rddlResponsibleOffice.SelectedValue != site.office_id.ToString())
                    {
                        db.RecordAltOffices.InsertOnSubmit(new Data.RecordAltOffice()
                        {
                            rms_record_id = new_record.rms_record_id,
                            site_id       = site.site_id,
                            alt_office_id = Convert.ToInt32(rddlResponsibleOffice.SelectedValue)
                        });
                        db.SubmitChanges();
                    }

                    //Insert the threatened gage
                    if ((bool)rcbThreatenedGage.Checked)
                    {
                        var tg_new = new Data.EndangeredGage();
                        tg_new.rms_record_id   = new_record.rms_record_id;
                        tg_new.remarks         = tbRemarks.Text;
                        tg_new.years_of_record = Convert.ToInt32(rntbYearsOfRecord.Value);
                        tg_new.status          = rcbStatus.SelectedValue.ToString();
                        tg_new.sunset_dt       = rdpSunsetDt.SelectedDate;
                        tg_new.entered_by      = user.ID;
                        tg_new.entered_dt      = DateTime.Now;
                        db.EndangeredGages.InsertOnSubmit(tg_new);
                    }
                }


                ScriptManager.RegisterStartupScript(this, GetType(), "close", "CloseModal();", true);
            }
            else
            {
                ltlError.Visible = true;
                ltlError.Text    = error;
            }
        }
示例#7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string type          = Request.QueryString["type"];
            int    rms_record_id = Convert.ToInt32(Request.QueryString["rms_record_id"]);
            int    site_id       = Convert.ToInt32(Request.QueryString["site_id"]);

            if (rms_record_id > 0)
            {
                record = db.Records.FirstOrDefault(p => p.rms_record_id == rms_record_id);
            }
            if (site_id > 0)
            {
                site = db.Sites.FirstOrDefault(p => p.site_id == site_id);
            }
            else
            {
                site = db.Sites.FirstOrDefault(p => p.site_id == record.site_id);
            }

            if (!Page.IsPostBack)
            {
                if (type == "newrecord")
                {
                    ltlTitle.Text             = "Add New Record";
                    ltlRecordType.Visible     = false;
                    ltlSite.Text              = site.site_no.Trim() + " " + db.vSITEFILEs.FirstOrDefault(s => s.site_id == site.nwisweb_site_id).station_nm;
                    pnlNewRecord.Visible      = true;
                    pnlRecordNotUsed.Visible  = false;
                    pnlEditRecord.Visible     = false;
                    pnlThreatenedGage.Visible = false;
                    PopulateNewRecordPanel();
                }
                else if (type == "record")
                {
                    ltlTitle.Text = "Modify Record";
                    var dds = db.SP_RMS_Get_Record_DDs(record.rms_record_id);
                    if (dds.Count() > 1)
                    {
                        ltlRecordType.Text = "Multi-Parameter, " + record.RecordType.type_ds + " Record for";
                    }
                    else
                    {
                        try { ltlRecordType.Text = db.SP_RMS_Get_Record_DDs(record.rms_record_id).FirstOrDefault().parm_nm + ", " + record.RecordType.type_ds + " Record for"; }
                        catch (Exception ex) { ltlRecordType.Text = record.RecordType.type_ds + " Record for"; }
                    }
                    ltlSite.Text         = record.Site.site_no.Trim() + " " + db.vSITEFILEs.FirstOrDefault(s => s.site_id == record.Site.nwisweb_site_id).station_nm;
                    pnlNewRecord.Visible = false;
                    if ((bool)record.not_used_fg)
                    {
                        pnlRecordNotUsed.Visible = true;
                        pnlEditRecord.Visible    = false;
                    }
                    else
                    {
                        pnlRecordNotUsed.Visible = false;
                        pnlEditRecord.Visible    = true;
                    }

                    PopulateEditRecordPanel("editcurrentrecord");
                }
            }
        }
示例#8
0
        public void Values_Not_Null()
        {
            var target = new Data.Record();

            Assert.False(target.Values.IsDefault);
        }
示例#9
0
        public void Inherits_From_ObservableObject()
        {
            var target = new Data.Record();

            Assert.True(target is ObservableObject);
        }