예제 #1
0
        protected void ButtonAddTimesheet_Click(object sender, EventArgs e)
        {
            try
            {
                var newTimeEntry = new TheGateWebSite.Model.TimeEntry()
                {
                    date = DateTime.Parse(TextBoxDate.Text),
                    hours = decimal.Parse(TextBoxTime.Text),
                    category = ddlCategory.SelectedValue,
                    employeeID = employee.employeeID
                };

                theGateContext.TimeEntries.Add(newTimeEntry);
                theGateContext.SaveChanges();
                TextBoxDate.Text = string.Empty;
                TextBoxTime.Text = string.Empty;
                ddlCategory.SelectedIndex = 0;
                LoadTimesheets();
            }
            catch (Exception ex)
            {
                PanelAddAlertError.Visible = true;
                LabelAddAlert.Text = "Error adding new time entry: " + ex.Message;
            }
        }
예제 #2
0
 private void WriteTimeEntriesInfo(TimeEntry te)
 {
     StringBuilder stringBuilder = new StringBuilder();
     AddComma(te.timeID.ToString(), stringBuilder);
     AddComma(te.date.ToShortDateString(), stringBuilder);
     AddComma(te.hours.ToString(), stringBuilder);
     AddComma(te.category, stringBuilder);
     AddComma(te.Employee.Contact.firstName + " " + te.Employee.Contact.lastName, stringBuilder);
     HttpContext.Current.Response.Write(stringBuilder.ToString());
     HttpContext.Current.Response.Write(Environment.NewLine);
 }