Exemple #1
0
 private void PopulateEntries()
 {
     var month = int.Parse(ddMonth.SelectedValue);
     var year = int.Parse(ddYear.SelectedValue);
     using (emsDBDataContext db = new emsDBDataContext())
     {
         var q = db.EntryDetails
                 .Where(d => d.Date.Month == month && d.Date.Year == year)
                 .OrderBy(d => d.CallNumber);
         rptStats.DataSource = q.ToList();
         rptStats.DataBind();
     }
 }
Exemple #2
0
        // submit the form!
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            // let's check the date. it should be valid through client-side validation, but let's make sure.
            DateTime parsedDate;
            if (DateTime.TryParseExact(txtDate.Text, "MM/dd/yyyy", null, System.Globalization.DateTimeStyles.None, out parsedDate))
            {
                using (emsDBDataContext db = new emsDBDataContext())
                {
                    // create the entry...
                    Entry entry = new Entry
                    {
                        Date = parsedDate,
                        CallNumber = txtCallNumber.Text,
                        T2 = TimeSpan.Parse(txtT2.Text),
                        T3 = TimeSpan.Parse(txtT3.Text),
                        T4 = TimeSpan.Parse(txtT4.Text),
                        CTAS = int.Parse(ddCTAS.SelectedValue),
                        CallType = int.Parse(ddCallType.SelectedValue),
                        VSA = int.Parse(ddVSA.SelectedValue),
                        SymptomRelief = int.Parse(ddSymptomRelief.SelectedValue),
                        IVAttempt = int.Parse(ddIVAttempt.SelectedValue),
                        DateEntered = DateTime.Now, // record the time that the record was put in
                        EnteredBy = EMStatsData.GetUserName() // record who entered the record
                    };

                    db.Entries.InsertOnSubmit(entry);

                    try
                    {
                        db.SubmitChanges();
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }

                    // display the message that the entry was successfully entered.
                    Alert1.Text = "Call number " + txtCallNumber.Text + " successfully added!";
                    Alert1.AlertType = Alert.AlertTypes.Success;
                    Alert1.Visible = true;

                    // let's reset the form!
                    txtDate.Text = txtCallNumber.Text = txtT2.Text = txtT3.Text = txtT4.Text = txtTDiff.Text = String.Empty;
                    ddCTAS.SelectedIndex = ddCallType.SelectedIndex = ddVSA.SelectedIndex = ddSymptomRelief.SelectedIndex = ddIVAttempt.SelectedIndex = 0;
                }
            }
            else // not a valid date
            {
                throw new Exception("This was not recognized as a valid date.");
            }
        }
Exemple #3
0
        // submit the form!
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            // let's check the date. it should be valid through client-side validation, but let's make sure.
            DateTime parsedDate;
            if (DateTime.TryParseExact(txtDate.Text, "MM/dd/yyyy", null, System.Globalization.DateTimeStyles.None, out parsedDate))
            {
                using (emsDBDataContext db = new emsDBDataContext())
                {
                    var entry = (from q in db.Entries
                                where q.ID == int.Parse(hdnID.Value)
                                select q).SingleOrDefault();

                    if (entry != null)
                    {
                        entry.Date = parsedDate;
                        entry.CallNumber = txtCallNumber.Text;
                        entry.T2 = TimeSpan.Parse(txtT2.Text);
                        entry.T3 = TimeSpan.Parse(txtT3.Text);
                        entry.T4 = TimeSpan.Parse(txtT4.Text);
                        entry.CTAS = int.Parse(ddCTAS.SelectedValue);
                        entry.CallType = int.Parse(ddCallType.SelectedValue);
                        entry.VSA = int.Parse(ddVSA.SelectedValue);
                        entry.SymptomRelief = int.Parse(ddSymptomRelief.SelectedValue);
                        entry.IVAttempt = int.Parse(ddIVAttempt.SelectedValue);
                        entry.DateEntered = DateTime.Now; // record the time that the record was put in
                        entry.EnteredBy = EMStatsData.GetUserName(); // record who entered the record
                        db.SubmitChanges();

                        // display the message that the entry was successfully entered.
                        Alert1.Text = "Call number " + txtCallNumber.Text + " successfully updated!";
                        Alert1.AlertType = Alert.AlertTypes.Success;
                        Alert1.Visible = true;
                    }
                    else
                    {
                        throw new Exception("This record was not found.");
                    }
                }
            }
            else // not a valid date
            {
                throw new Exception("This was not recognized as a valid date.");
            }
        }