Ejemplo n.º 1
0
        protected void InitialDataBind()
        {
            rddlOffice.DataSource = db.Offices
                                    .Where(p => p.wsc_id == WSCID)
                                    .Select(p => new { office_id = p.office_id, office_nm = p.office_nm })
                                    .OrderBy(p => p.office_nm).ToList();
            rddlOffice.DataBind();
            rddlOffice.Items.Insert(0, "");

            rddlRecords.DataSource = db.Records
                                     .Where(p => p.Site.Office.wsc_id == WSCID)
                                     .Select(p => new { rms_record_id = p.rms_record_id, SiteRecord = p.Site.site_no + " " + p.Site.station_full_nm + " (" + p.RecordType.type_cd + ")" })
                                     .OrderBy(p => p.SiteRecord).ToList();
            rddlRecords.DataBind();
            rddlRecords.Items.Insert(0, "");

            if (RecordID > 0)
            {
                rddlRecords.SelectedValue = RecordID.ToString();
            }

            rdpBeginDt.SelectedDate = Convert.ToDateTime("10/1/" + (DateTime.Now.Year - 1).ToString());
            rdpEndDt.SelectedDate   = DateTime.Now;

            ltlNotice1.Visible = true;
            ltlNotice2.Visible = true;
            ltlNotice3.Visible = true;
            ltlError.Visible   = false;
        }
Ejemplo n.º 2
0
        public string this[string columnName]
        {
            get
            {
                Error = string.Empty;

                if (columnName == "Till")
                {
                    if (Till == null)
                    {
                        Error = "Please select the Till.";
                    }
                }

                if (columnName == "Name")
                {
                    if (string.IsNullOrWhiteSpace(Name))
                    {
                        Error = "Group Name can't be empty";
                    }
                }

                if (columnName == "RecordID")
                {
                    if (string.IsNullOrWhiteSpace(RecordID.ToString()))
                    {
                        Error = "Record Id can't be empty";
                    }
                    else if (RecordID < 1 || RecordID > 256)
                    {
                        Error = "Record Id must be between 1 and 256";
                    }
                }

                return(Error);
            }
        }
Ejemplo n.º 3
0
        protected void SetupAuditForm(string type)
        {
            if (type == "single")
            {
                if (rlbRecordPeriods.CheckedItems.Count == 0)
                {
                    ltlAuditDateRange.Text = String.Format("{0:MM/dd/yyyy} - {1:MM/dd/yyyy}", rdpBeginDt1.SelectedDate, rdpEndDt1.SelectedDate);
                }
                else
                {
                    ltlAuditDateRange.Text = String.Format("{0:MM/dd/yyyy} - {1:MM/dd/yyyy}", PeriodDate("begin"), PeriodDate("end"));

                    bool consecutive = false;
                    bool theend      = false;
                    foreach (RadListBoxItem item in rlbRecordPeriods.Items)
                    {
                        if (item.Checked && !consecutive) //will enter this part of the statement upon reaching the first checked item
                        {
                            consecutive = true;
                        }
                        else if (!item.Checked && consecutive) //will enter this part of the statement upon reaching the first unchecked item after a checked item
                        {
                            theend = true;
                        }
                        else if (item.Checked && consecutive && theend) //will enter this part of the statement if another checked period is found after a series of checked and unchecked - non-consecutive periods were selected!!
                        {
                            consecutive = false;
                            break;
                        }
                    }

                    if (!consecutive)
                    {
                        pnlNotice.Visible = true;
                        ltlNotice.Text    = "<b>You did not select consecutive periods.</b> The audit date range is determined by the earliest selected period begin date and " +
                                            "latest selected period end date, and this audit includes all periods within the audit date range.";
                    }
                }
                List <RecordItem> rec = new List <RecordItem>();
                rec.Add(new RecordItem()
                {
                    rms_record_id = RecordID.ToString(), record_nm = currRecord.Site.site_no + " - " + currRecord.RecordType.type_ds
                });
                rlbViewRecords.DataSource = rec;
                rlbViewRecords.DataBind();
            }
            else
            {
                ltlAuditDateRange.Text    = String.Format("{0:MM/dd/yyyy} - {1:MM/dd/yyyy}", rdpBeginDt2.SelectedDate, rdpEndDt2.SelectedDate);
                rlbViewRecords.DataSource = rlbRecords.CheckedItems.Select(p => new { rms_record_id = p.Value, record_nm = p.Text });
                rlbViewRecords.DataBind();
            }

            rddlAuditType.DataSource = db.AuditTypes.Select(p => new { audit_type_id = p.audit_type_id, description = p.type + ": " + p.description }).ToList();
            rddlAuditType.DataBind();
            rddlAuditType.Items.Insert(0, new DropDownListItem {
                Value = "", Text = ""
            });

            rddlAuditResults.DataSource = db.AuditResults.Select(p => new { audit_results_id = p.audit_results_id, description = p.result + p.description }).ToList();
            rddlAuditResults.DataBind();
            rddlAuditResults.Items.Insert(0, new DropDownListItem {
                Value = "", Text = ""
            });

            if (currAudit != null)
            {
                ltlAuditBy.Text = currAudit.audit_by;

                rddlAuditResults.SelectedValue = currAudit.audit_results_id.ToString();
                rddlAuditType.SelectedValue    = currAudit.audit_type_id.ToString();

                rbCreateEditAudit.Text            = "Edit Audit Period";
                rbCreateEditAudit.CommandArgument = "Edit";
            }
            else
            {
                ltlAuditBy.Text = user.ID;

                rddlAuditType.SelectedIndex    = 0;
                rddlAuditResults.SelectedIndex = 0;

                rbCreateEditAudit.Text            = "Create Audit";
                rbCreateEditAudit.CommandArgument = "Add";
            }
        }
Ejemplo n.º 4
0
        protected void LoadRecordList()
        {
            if (!string.IsNullOrEmpty(rddlOffice.SelectedValue))
            {
                if (!string.IsNullOrEmpty(rddlFieldTrip.SelectedValue))
                {
                    rlbRecords.DataSource = db.Records
                                            .Where(p => p.Site.TripSites.Select(t => t.trip_id).Contains(Convert.ToInt32(rddlFieldTrip.SelectedValue)))
                                            .Select(p => new
                    {
                        rms_record_id = p.rms_record_id,
                        record_nm     = p.Site.site_no + " - " + p.RecordType.type_ds
                    }).ToList();
                }
                else
                {
                    rlbRecords.DataSource = db.Records
                                            .Where(p => p.RecordAltOffice.alt_office_id == Convert.ToInt32(rddlOffice.SelectedValue) || p.Site.office_id == Convert.ToInt32(rddlOffice.SelectedValue))
                                            .Select(p => new
                    {
                        rms_record_id = p.rms_record_id,
                        record_nm     = p.Site.site_no + " - " + p.RecordType.type_ds
                    }).ToList();
                }
            }
            else
            {
                rlbRecords.DataSource = db.Records
                                        .Where(p => p.Site.Office.wsc_id == WSCID)
                                        .Select(p => new
                {
                    rms_record_id = p.rms_record_id,
                    record_nm     = p.Site.site_no + " - " + p.RecordType.type_ds
                }).ToList();
            }

            rlbRecords.DataBind();

            if (RecordID > 0)
            {
                RadListBoxItem item1 = rlbRecords.Items.Where(p => p.Value == RecordID.ToString()).FirstOrDefault();

                if (item1 != null)
                {
                    item1.Checked = true;
                    rlbRecords.Items.Remove(item1);
                    rlbRecords.Items.Insert(0, item1);
                }
                else
                {
                    RadListBoxItem item2 = new RadListBoxItem()
                    {
                        Value = RecordID.ToString(), Text = currRecord.Site.site_no + " - " + currRecord.RecordType.type_ds
                    };
                    item2.Checked = true;
                    rlbRecords.Items.Insert(0, item2);
                }
                rlbRecords.SelectedIndex = 0;
            }

            if (currAudit != null)
            {
                int x = 0;
                foreach (var rec in currAudit.AuditRecords)
                {
                    RadListBoxItem item3 = rlbRecords.Items.Where(p => p.Value == rec.rms_record_id.ToString()).FirstOrDefault();

                    if (item3 != null)
                    {
                        item3.Checked = true;
                        rlbRecords.Items.Remove(item3);
                        rlbRecords.Items.Insert(x, item3);
                    }
                    else
                    {
                        var            record = db.Records.FirstOrDefault(p => p.rms_record_id == rec.rms_record_id);
                        RadListBoxItem item4  = new RadListBoxItem()
                        {
                            Value = rec.rms_record_id.ToString(), Text = record.Site.site_no + " - " + record.RecordType.type_ds
                        };
                        item4.Checked = true;
                        rlbRecords.Items.Insert(x, item4);
                    }
                    x += 1;
                }
            }
        }