private void bunifuFlatButton3_Click_1(object sender, EventArgs e) { eventCategory ec = new eventCategory(); ec.categoryname = categorynamebox.Text; ec.eventid = Int32.Parse(comboBox3.SelectedValue.ToString()); db.eventCategories.InsertOnSubmit(ec); db.SubmitChanges(); MessageBox.Show("Category added.\n You can add more category."); }
public void GenerateViewItem(DataRowView item, eventCategory eCat = eventCategory.CurrentEvent) { DataRow rown = item.Row; //обязательные условия для заполнения ячейки if ((rown.IsNull("BeginTime") == false) && (rown.IsNull("EndTime") == false)) { DateTime BeginTime = Convert.ToDateTime(Convert.ToString(item["BeginTime"])); DateTime EndTime = Convert.ToDateTime(Convert.ToString(item["EndTime"])); DateTime ActionDate = new DateTime(); if (eCat == eventCategory.CurrentEvent) ActionDate = Convert.ToDateTime(Convert.ToString(item["ActionDate"])); int pos = 0; if ((FacilityID == DatabaseConstant.Facilities.Bassein) || (FacilityID == DatabaseConstant.Facilities.Manege)) { if (rown.IsNull("TrackID") == false) { pos = Convert.ToInt32(item["TrackID"]); } } else { if (eCat == eventCategory.CurrentEvent) pos = (ActionDate.DayOfWeek == DayOfWeek.Sunday) ? 6 : (int)ActionDate.DayOfWeek - 1; else if (eCat == eventCategory.CalendarEvent) pos = Convert.ToInt32(item["ActionDate"]) - 1; } int col = GetColumnPos(pos); int row = GetRowPos(BeginTime, EndTime); string eventDescription = BeginTime.ToShortTimeString() + " --" + EndTime.ToShortTimeString() + " " + item["EventTitle"].ToString().Trim(); int currEventID = Convert.ToInt32(item["CurrEventID"]); DrawCurrentEvent(col, row, eventDescription, currEventID); } }
void PrepareSelected() { currDate = dt1.Value; currDay = (int)weekDayComboBox.ComboBox.SelectedValue; int _fid = (int)facilitiesComboBox.ComboBox.SelectedValue; BindingSource bs = new BindingSource(); string _filter = String.Empty; eCategory = dgv1.GetEventCategory(planTypesComboBox.SelectedIndex); //получим данные switch (eCategory) { case eventCategory.CurrentEvent: { this.generalExportTableAdapter.FillGeneralExport(sportDataSet.GeneralExportTable, _fid); bs = generalExportTableBindingSource; } break; case eventCategory.CalendarEvent: { this.calendarExportTableAdapter.FillCalendarExport(sportDataSet.CalendarExportTable, _fid); bs = calendarExportTableBindingSource; } // bs = sheduleReportBindingSource; break; default: break; } //отфильтруем switch ((DatabaseConstant.Facilities)_fid) { case DatabaseConstant.Facilities.Bassein: { _filter = (eCategory == eventCategory.CurrentEvent) ? String.Format("[ActionDate] = Convert('{0}', System.DateTime)", currDate) : String.Format("[ActionDate] = {0}", currDay); } break; case DatabaseConstant.Facilities.Manege: { _filter = (eCategory == eventCategory.CurrentEvent) ? String.Format("[ActionDate] = Convert('{0}', System.DateTime)", currDate) : String.Format("[ActionDate] = {0}", currDay); } break; default: { DateTime monday = currDate.AddDays(-(double)currDate.DayOfWeek + ((currDate.DayOfWeek == DayOfWeek.Sunday) ? -6 : 1)); DateTime sunday = currDate.AddDays(-(double)currDate.DayOfWeek + ((currDate.DayOfWeek == DayOfWeek.Sunday) ? 0 : 7)); _filter = (eCategory == eventCategory.CurrentEvent) ? String.Format("[ActionDate] >= Convert('{0}', System.DateTime) AND [ActionDate] <= Convert('{1}', System.DateTime)", monday, sunday) : String.Empty; } break; } bs.Filter = _filter; this.eventlistBindingSource.Filter = String.Format("[InList] = 1 AND [FacilityID] = {0}", _fid); //выведем FillEventsToGrid(bs); ulog.Message("Получено " + bs.Count + " записей.", UserLogMessageLevel.Information); //перерисуем картинку RepaintDataGrid(); }