private void OnMoveFirst(object sender, EventArgs e)
        {
            if (bindingSource != null)
            {
                bindingSource.MoveFirst();
            }

            OnRefreshItems();
        }
예제 #2
0
파일: Caso.cs 프로젝트: eduardo-salazar/sag
        public Caso(Usuario u)
        {
            InitializeComponent();

            this.u = u;
            cta = new CADINDataSetTableAdapters.CasoTableAdapter();
            ata = new CADINDataSetTableAdapters.ActividadesTableAdapter();
            ata2 = new CADINDataSetTableAdapters.Actividades2TableAdapter();
            eta = new CADINDataSetTableAdapters.EmpresaTableAdapter();

            s1 = new BindingSource();
            s2 = new BindingSource();

            cdt = cta.GetData();
            adt = ata.GetData();

            s1.DataSource = cdt;
            s2.DataSource = adt;
            if (s1.Position != -1)
            {
                txcod_Caso.DataBindings.Add("Text", s1, "cod_caso");
                txCod_empr.DataBindings.Add("Text", s1, "cod_empr");
                txNomb_solic.DataBindings.Add("Text", s1, "pers_solic");
                txCargo.DataBindings.Add("Text", s1, "carg_pers_solic");
                ipFech_soli.DataBindings.Add("Text", s1, "fech_solic");
                txDesc_prob.DataBindings.Add("Text", s1, "desc_soli");

                txDesc_solu.DataBindings.Add("Text", s1, "desc_solu");
                if (s1.Position != -1)
                    sliderNiv_solu.DataBindings.Add("Value", s1, "nive_solu");
                if (s1.Position != -1)
                    ckbCaso_cerr.DataBindings.Add("Checked", s1, "caso_cerrado");

                txObservaciones.DataBindings.Add("Text", s1, "observaciones");
                txCod_resp.DataBindings.Add("Text", s1, "cod_func_asig");
                txResp_Caso.DataBindings.Add("Text", s1, "nomb_func_asig");
                ipFech_solu.DataBindings.Add("Text", s1, "fech_solf");
                dataGridViewX1.DataSource = s2;

                if (u.Admin) {
                    chkbAdm.Visible = true;
                    if (s1.Position != -1)
                     chkbAdm.DataBindings.Add("Checked", s1, "caso_cerrado");
                }
                s1.MoveFirst();
                cargarNE1();
                llenarActividades();
                Cancelar();
            }
            else {
                MessageBox.Show("No hay registros guardados");
                Nuevo();
                }
        }
예제 #3
0
 /// <devdoc>
 ///     Navigates to first item in BindingSource's list when the MoveFirstItem is clicked.
 /// </devdoc>
 private void OnMoveFirst(object sender, EventArgs e)
 {
     if (Validate())
     {
         if (bindingSource != null)
         {
             bindingSource.MoveFirst();
             RefreshItemsInternal();
         }
     }
 }
예제 #4
0
        public NhapDiem(string ChucNang, string MaLop, BangDiem_ThongTin BD)
        {
            InitializeComponent();
            this.ChucNang = ChucNang;
            try
            {
                cbHocKy.DataSource = cls_HocKy.DanhSachHocKy();
                cbHocKy.DisplayMember = "TenHocKy";
                cbHocKy.ValueMember = "MaHocKy";

                cbMonHoc.DataSource = cls_MonHoc.DanhSachMonHoc();
                cbMonHoc.DisplayMember = "TenMonHoc";
                cbMonHoc.ValueMember = "MaMonHoc";
            }
            catch
            {
                MessageBox.Show("Lỗi kết nối, bạn hãy kiểm tra lại.", "Thông báo lỗi.", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            if (ChucNang.Equals("F1"))
            {
                try
                {
                    SinhVien_ThongTin SV = new SinhVien_ThongTin();
                    SV.Lop = MaLop;
                    source = new BindingSource();
                    foreach (DataRow Hang in cls_SinhVien.DanhSachSinhVienCuaLop(SV).Rows)
                    source.Add(Hang);

                    //LẤY RA GIÁ TRỊ ĐẦU TIÊN.
                    source.MoveFirst();
                    ShowRecord();
                    XemDiemTheoKySinhVien();
                }
                catch
                {
                    MessageBox.Show("Lỗi kết nối, bạn hãy kiểm tra lại.", "Thông báo lỗi.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            if (ChucNang.Equals("ChinhSua"))
            {
                BangDiemSTT = BD.Stt;
                txtMaSinhVien.Text = BD.MaSinhVien;
                cbHocKy.SelectedValue = BD.MaHocKy;
                cbMonHoc.SelectedValue = BD.MaMonHoc;
                txtDiemQuaTrinh.Text = BD.DiemQuaTrinh.ToString();
                txtDiemThi.Text = BD.DiemThi.ToString();
                ChinhSua = "1";
                XacNhanXoa = "1";
                btXacNhan_QLD.Enabled = false;
                btChinhSua_QLD.Text = "Lưu lại.";
                txtDiemQuaTrinh.Focus();
            }
            txtDiemQuaTrinh.Focus();
        }
예제 #5
0
        public void ExportToExcel(BindingSource bs, string fName, string fTitle)
        {
            ProgressBar pb = ((Shedules)Application.OpenForms["Shedules"]).executeProgress;

            DateTime actionDate = new DateTime();
            string eventTitle = String.Empty;
            string headerTitle = String.Empty;
            string groupTitle = String.Empty;
            string headerPhone = String.Empty;
            string contractNum = String.Empty;
            DateTime contractTerm = new DateTime();
            string contractTermStr = String.Empty;
            DatabaseConstant.Bassein_tracks trackID = DatabaseConstant.Bassein_tracks.Default;

            int currEventID;
            DateTime beginTime;
            DateTime endTime;

            Point cursor;
            //смещение времени от начала дня
            TimeSpan timeOffset = new TimeSpan(7, 45, 0);

            try
            {//-------------------------------главный цикл---------------------------------
                bs.MoveFirst();
                ulog.RestartProcessExecInfo(pb);

                foreach (DataRowView item in bs)
                {
                    //счётчик для прогрессбара
                    ulog.ViewProcessExecInfo(pb, Convert.ToInt32((100.0 / bs.Count) * ulog.progressCounter));

                    //текущая дата
                    actionDate = Convert.ToDateTime(Convert.ToString(item["ActionDate"]));
                    int dayOffset = GetOffset(actionDate) * pageSize;
                    currEventID = Convert.ToInt32(item["CurrEventID"]);

                    //получаем время проведения мероприятия
                    beginTime = Convert.ToDateTime(Convert.ToString(item["BeginTime"]));
                    endTime = Convert.ToDateTime(Convert.ToString(item["EndTime"]));

                    DataRow rown = item.Row; //получаем текущие текстовые поля

                    if (rown.IsNull("EventTitle") == false)
                        eventTitle = Convert.ToString(item["EventTitle"]);
                    else
                        eventTitle = string.Empty;

                    if (eventTitle.Contains("354-92-42"))
                        continue;

                    if (rown.IsNull("GroupTitle") == false)
                        groupTitle = Convert.ToString(item["GroupTitle"]);
                    else
                        groupTitle = String.Empty;

                    if (rown.IsNull("HeaderTitle") == false)
                        headerTitle = Convert.ToString(item["HeaderTitle"]);
                    else
                        headerTitle = String.Empty;

                    if (rown.IsNull("HeaderPhone") == false)
                        headerPhone = Convert.ToString(item["HeaderPhone"]);
                    else
                        headerPhone = String.Empty;

                    if (rown.IsNull("ContractNum") == false)
                        contractNum = Convert.ToString(item["ContractNum"]);
                    else
                        contractNum = String.Empty;

                    if (rown.IsNull("ContractTerm") == false)
                    {
                        contractTerm = Convert.ToDateTime(Convert.ToString(item["ContractTerm"]));
                        contractTermStr = contractTerm.ToShortDateString();
                    }
                    else
                        contractTermStr = String.Empty;

                    if (rown.IsNull("TrackID") == false)
                        trackID = (DatabaseConstant.Bassein_tracks)(Convert.ToInt32(item["TrackID"]));
                    else
                        trackID = DatabaseConstant.Bassein_tracks.Default;

                    //описание мероприятия (частичное)
                    string eventDesc = String.Join(" ", groupTitle, headerTitle, headerPhone, contractNum, contractTermStr);
                    //время проведения
                    string eventPeriod = beginTime.ToShortTimeString() + " - " + endTime.ToShortTimeString();
                    //определим, сколько ячеек по вертикали нужно объединить
                    TimeSpan timeDiff = endTime - beginTime;
                    int cellscnt = timeDiff.Hours * 4 + (timeDiff.Minutes / 15);

                    //указатель на позицию вывода
                    cursor = this.GetCursor(trackID);

                    //найдём строку вывода
                    int startline = cursor.Y + (beginTime - timeOffset).Hour * 4 + ((beginTime - timeOffset).Minute / 15) + dayOffset;

                    //объединим ячейки мероприятий
                    MergeCells(startline, cursor.X, startline + cellscnt - 1, cursor.X + using_tracks);

                    //выводим по полученным индексам "Мероприятие + фио тренера + группа"
                    string celltext = objSheet.Cells[startline, cursor.X].Text;
                    if (celltext.Contains(Convert.ToString(item["EventTitle"])))
                    {
                        AdjustCells(startline, cursor.X, (celltext + " " + eventDesc).Trim(), FontName: "Calibri", FontSize: 8);
                    }
                    else
                    {
                        //Выполним вывод в ячейку мероприятий
                        AdjustCells(startline, cursor.X, (celltext + " " + eventTitle + " " + eventDesc).Trim(), FontName: "Calibri", FontSize: 8);
                    }
                }

                beginDate = Properties.Settings.Default.exportFirstDate;
                endDate = Properties.Settings.Default.exportSecondDate;

                for (DateTime dt = beginDate; dt <= endDate; dt = dt.AddDays(1))
                {
                    int dayOffset = GetOffset(dt) * pageSize;

                    //группируем пустые строки
                    for (int tnum = 1; tnum < 7; ++tnum)
                        GroupingEmptyCells(8 + dayOffset, tnum + 1, timeOffset, false, 57, true);

                    string dayOfWeek = objSheet.Cells[6 + dayOffset, 1].Value;
                    if (!dayOfWeek.Contains(actionDate.ToShortDateString()))
                    {
                        AdjustCells(6 + dayOffset, 1, dayOfWeek + " " + dt.ToShortDateString(), FontName: "Calibri",
                            FontSize: 11, FontBold: true, FontItalic: true, Halgmnt: Excel.XlHAlign.xlHAlignCenter, Valgmnt: Excel.XlVAlign.xlVAlignCenter);
                    }
                }

            } //-------------------------------главный цикл---------------------------------
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            //сохраним результаты
            objApp.DisplayAlerts = false;
            objApp.Application.ActiveWorkbook.SaveAs(Filename: fName, AccessMode: Excel.XlSaveAsAccessMode.xlNoChange);
            objApp.Application.ActiveWorkbook.Close(false);
            objApp.Quit();
        }
예제 #6
0
파일: Plans.cs 프로젝트: hprog/exchange
        private void EventProcessing(int colIndex, int rowIndex, BindingSource actualEvents, BindingSource actualActions)
        {
            try
            {
                //запомнить положение скроллбара
                int saveRow = 0;
                if (dgv1.Rows.Count > 0)
                    saveRow = dgv1.FirstDisplayedCell.RowIndex;

                int currEvent = 0;

                //проверка пересечения мероприятий
                string cellTag = Convert.ToString(dgv1[colIndex, rowIndex].Tag);

                if (Int32.TryParse(cellTag, out currEvent))
                {

                    if ((dgv1.collapseEvents.Keys.Contains(currEvent)) && (dgv1[colIndex, rowIndex].Style.BackColor == event_error_bg))
                    {
                        string filter = String.Format("[{0}] IN ({1}, {2})", currEventField, currEvent, dgv1.collapseEvents[currEvent]);
                        CollapseSelect cs = new CollapseSelect(filter, eCategory);

                        if (cs.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        {
                            currEvent = cs.ReturnEventID();
                        }
                        else
                            return;
                    }

                    actualEvents.Position = actualEvents.Find(currEventField, currEvent);

                    DataRowView curr = (DataRowView)actualEvents.Current;
                    DateTime ebegin = Convert.ToDateTime(Convert.ToString(curr["BeginTime"]));
                    DateTime eend = Convert.ToDateTime(Convert.ToString(curr["EndTime"]));
                    //if (this.EditCurrentEvent(actualEvents, this.eventlistBindingSource, ebegin, eend))
                    //выбираем кейсом eCategory и создаем IEditable;

                    IEditable editEventForm = null;
                    IEditable editActionForm = null;

                    switch (eCategory)
                    {
                        case eventCategory.CurrentEvent:
                            {
                                editEventForm = new EditEventItem(actualEvents, this.eventlistBindingSource, ebegin, eend);
                                editActionForm = new EditActionItem(actualActions, actualEvents, facility_tracksBindingSource,
            groupsBindingSource, group_headersBindingSource);
                            }
                            break;
                        case eventCategory.CalendarEvent:
                            {
                                editEventForm = new EditCalendarEventItem(actualEvents, this.eventlistBindingSource);
                                editActionForm = new EditCalendarActionItem(actualActions, actualEvents, facility_tracksBindingSource,
            groupsBindingSource, group_headersBindingSource);
                            }
                            break;
                        default:
                            editEventForm = null;
                            editActionForm = null;
                            break;
                    }

                    if (this.GenericEditEvent(editEventForm, actualEvents))
                    {
                        SaveChanges();
                        actualActions.MoveFirst();
                        //если есть записи
                        bool isNew = (actualActions.Current == null) ? true : false;

                //        if (this.EditCurrentAction(this.actionsBindingSource, eventsBindingSource, facility_tracksBindingSource,
                //groupsBindingSource, group_headersBindingSource, isNew))
                            if (this.GenericEditAction(editActionForm, this.actionsBindingSource, group_headersBindingSource, isNew))
                            SaveChanges();

                        PrepareSelected();
                        //восстановить положение скроллбара
                        if (saveRow != 0 && saveRow < dgv1.Rows.Count)
                            dgv1.FirstDisplayedScrollingRowIndex = saveRow;
                    }
                }
                else if (cellTag.Equals("new"))
                {
                    DateTime newEventDate = GetCurrentDate(colIndex, dt1.Value);
                    DateTime begin;
                    DateTime end;
                    string btime = String.Format("{0} {1}", currDate.ToShortDateString(), dgv1.Rows[rowIndex].HeaderCell.Value);
                    begin = Convert.ToDateTime(btime);
                    end = begin.AddMinutes(90);

                    Properties.Settings.Default.lastEditEventBeginTime = begin.ToShortTimeString();
                    Properties.Settings.Default.lastEditEventEndTime = end.ToShortTimeString();

                    //if (this.EditCurrentEvent(actualEvents, this.eventlistBindingSource, newEventDate, new DateTime(), true, false))
                    //выбираем кейсом eCategory и создаем IEditable;

                    IEditable editEventForm = null;
                    IEditable editActionForm = null;

                    switch (eCategory)
                    {
                        case eventCategory.CurrentEvent:
                            {
                                editEventForm = new EditEventItem(actualEvents, this.eventlistBindingSource, newEventDate, new DateTime(), false);
                                editActionForm = new EditActionItem(actualActions, actualEvents, facility_tracksBindingSource,
            groupsBindingSource, group_headersBindingSource);
                            }
                            break;
                        case eventCategory.CalendarEvent:
                            {
                                editEventForm = new EditCalendarEventItem(actualEvents, this.eventlistBindingSource);
                                editActionForm = new EditCalendarActionItem(actualActions, actualEvents, facility_tracksBindingSource,
            groupsBindingSource, group_headersBindingSource);
                            }
                            break;
                        default:
                            editEventForm = null;
                            editActionForm = null;
                            break;
                    }

                    if (this.GenericEditEvent(editEventForm, actualEvents,true))
                    {
                        SaveChanges();
                        actualActions.MoveFirst();

                 //       if (this.EditCurrentAction(this.actionsBindingSource, eventsBindingSource, facility_tracksBindingSource,
                 //groupsBindingSource, group_headersBindingSource, true))
                        if (this.GenericEditAction(editActionForm, actualActions, group_headersBindingSource, true))
                            SaveChanges();

                        PrepareSelected();

                        if (saveRow != 0 && saveRow < dgv1.Rows.Count)
                            dgv1.FirstDisplayedScrollingRowIndex = saveRow;
                    }
                }
            }
            catch (Exception ex) { ulog.Message(ex.Message, UserLogMessageLevel.Error); }
        }
예제 #7
0
        public void ExportToExcel(BindingSource bs, string fName, string fTitle)
        {
            ProgressBar pb = ((Shedules)Application.OpenForms["Shedules"]).executeProgress;
            ulog.RestartProcessExecInfo(pb);

            DateTime actionDate = new DateTime();
            string eventTitle = String.Empty;
            string headerTitle = String.Empty;
            string trackTitle = String.Empty;
            string groupTitle = String.Empty;
            string headerPhone = String.Empty;
            string contractNum = String.Empty;
            string contractTerm = String.Empty;
            int currEventID;
            DateTime beginTime;
            DateTime endTime;

            Point cursor;
            //смещение времени от начала дня
            TimeSpan timeOffset = new TimeSpan(8, 0, 0);

            bs.Sort = "[ActionDate] ASC";
            bs.MoveFirst();

            //page header
            AdjustCells(5, 1, "Работы  " + fTitle + "  МАУ «ЦСП  «Заря»", FontName: "Calibri", FontSize: 14, Halgmnt: Excel.XlHAlign.xlHAlignCenter);

            string exportPeriod = String.Empty;

            //счётчик для прогрессбара

            try
            {
                foreach (DataRowView item in bs)
                {
                    ulog.ViewProcessExecInfo(pb, Convert.ToInt32((100.0 / bs.Count) * ulog.progressCounter));

                    //текущая дата
                    actionDate = Convert.ToDateTime(Convert.ToString(item["ActionDate"]));
                    if (exportPeriod == String.Empty)
                        exportPeriod = actionDate.ToShortDateString();
                    //указатель на позицию начала текущего дня
                    cursor = this.GetCursor(actionDate);

                    //вставить дату рядом с днём недели
                    string dayOfWeek = objSheet.Cells[cursor.Y - 1, cursor.X].Value;
                    if (!dayOfWeek.Contains(actionDate.ToShortDateString()))
                    {
                        AdjustCells(cursor.Y - 1, cursor.X, dayOfWeek + " " + actionDate.ToShortDateString(), FontName: "Calibri",
                            FontSize: 11, FontBold: true, Halgmnt: Excel.XlHAlign.xlHAlignCenter, Valgmnt: Excel.XlVAlign.xlVAlignCenter);
                    }

                    currEventID = Convert.ToInt32(item["CurrEventID"]);

                    //получаем время проведения мероприятия
                    beginTime = Convert.ToDateTime(Convert.ToString(item["BeginTime"]));
                    endTime = Convert.ToDateTime(Convert.ToString(item["EndTime"]));

                    DataRow rown = item.Row; //получаем текущие текстовые поля

                    if (rown.IsNull("EventTitle") == false)
                        eventTitle = Convert.ToString(item["EventTitle"]);

                    if (eventTitle.Contains("354-92-42"))
                        continue;

                    if (rown.IsNull("TrackTitle") == false)
                        trackTitle = Convert.ToString(item["TrackTitle"]);
                    if (rown.IsNull("GroupTitle") == false)
                        groupTitle = Convert.ToString(item["GroupTitle"]);
                    if (rown.IsNull("HeaderTitle") == false)
                        headerTitle = Convert.ToString(item["HeaderTitle"]);
                    if (rown.IsNull("HeaderPhone") == false)
                        headerPhone = Convert.ToString(item["HeaderPhone"]);
                    if (rown.IsNull("ContractNum") == false)
                        contractNum = Convert.ToString(item["ContractNum"]);
                    if (rown.IsNull("ContractTerm") == false)
                        contractTerm = Convert.ToString(item["ContractTerm"]);
                    //описание мероприятия (частичное)
                    string eventDesc = String.Join(" ", trackTitle, groupTitle, headerTitle, headerPhone, contractNum, contractTerm);
                    //время проведения
                    string eventPeriod = beginTime.ToShortTimeString() + " - " + endTime.ToShortTimeString();
                    //определим, сколько ячеек по вертикали нужно объединить
                    TimeSpan timeDiff = endTime - beginTime;
                    int cellscnt = timeDiff.Hours * 4 + (timeDiff.Minutes / 15);

                    //найдём строку вывода
                    int startline = cursor.Y + (beginTime - timeOffset).Hour * 4 + ((beginTime - timeOffset).Minute / 15);
                    //int startline = cursor.Y + (beginTime.Hour - timeOffset.Hours) * 4 + (beginTime.Minute / 15);
                    //объединим ячейки мероприятий
                    MergeCells(startline, cursor.X, startline + cellscnt - 1, cursor.X);
                    //объединим ячейки времени
                    MergeCells(startline, cursor.X - 1, startline + cellscnt - 1, cursor.X - 1);

                    //выводим по полученным индексам "Мероприятие + фио тренера + группа"
                    string celltext = objSheet.Cells[startline, cursor.X].Text;
                    if (celltext.Contains(Convert.ToString(item["EventTitle"])))
                    {
                        AdjustCells(startline, cursor.X, (celltext + " " + eventDesc).Trim(), FontName: "Calibri", FontSize: 8);
                    }
                    else
                    {
                        //Выполним вывод в ячейку мероприятий
                        AdjustCells(startline, cursor.X, (celltext + " " + eventTitle + " " + eventDesc).Trim(), FontName: "Calibri", FontSize: 8);
                    }

                    //Выполним вывод в ячейку временного интервала
                    AdjustCells(startline, cursor.X - 1, eventPeriod, FontSize: 8,
                        Halgmnt: Excel.XlHAlign.xlHAlignCenter, Valgmnt: Excel.XlVAlign.xlVAlignCenter);
                }

                //Период на который строится расписание
                exportPeriod += " - " + actionDate.ToShortDateString();
                AdjustCells(6, 1, exportPeriod, FontName: "Calibri", FontSize: 14, Halgmnt: Excel.XlHAlign.xlHAlignCenter);

                //группируем пустые строки
                GroupingEmptyCells(8, 2, timeOffset);
                GroupingEmptyCells(8, 6, timeOffset);
                GroupingEmptyCells(8, 10, timeOffset);

                GroupingEmptyCells(74, 2, timeOffset);
                GroupingEmptyCells(74, 4, timeOffset);
                GroupingEmptyCells(74, 8, timeOffset);
                GroupingEmptyCells(74, 12, timeOffset);

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            //сохраним результаты
            objApp.DisplayAlerts = false;
            objApp.Application.ActiveWorkbook.SaveAs(Filename: fName, AccessMode: Excel.XlSaveAsAccessMode.xlNoChange);
            objApp.Application.ActiveWorkbook.Close(false);
            objApp.Quit();
        }
 public void initializationInvestProject()
 {
     BindingSource bindingSource = new BindingSource();
     InvestProjectDAO dao = new InvestProjectDAO();
     bindingSource.Clear();
     bindingSource.DataSource = dao.getAll();
     dataGridInvestProject.DataSource = bindingSource;
     bindingSource.CurrentItemChanged += BindingSource_CurrentItemChanged;
     
     if ((ScrollIndex >=0) && (dataGridInvestProject.Rows.Count > 0))
     {
         dataGridInvestProject.FirstDisplayedScrollingRowIndex = ScrollIndex;
     }
     if (BookMarkInvestProject != 0)
     {
         dataGridInvestProject.Rows[BookMarkInvestProject].Selected = true;
         bindingSource.Position = BookMarkInvestProject;
     }
     else
     {
         if (bindingSource.Count > 0)
         {
             bindingSource.MoveNext();
             bindingSource.MoveFirst();
         }
         //dataGridInvestProject.Rows[1].Selected = true;
     }
 }
예제 #9
0
        public void ExportToExcel(BindingSource bs, string fName, string fTitle)
        {
            xOffset = new Dictionary<int,int>();
            xOffset[100] = 3;
            xOffset[101] = 4;
            xOffset[102] = 5;
            xOffset[103] = 6;
            xOffset[105] = 7;
            xOffset[106] = 8;
            xOffset[107] = 9;
            xOffset[108] = 10;
            xOffset[109] = 11;
            xOffset[110] = 12;
            xOffset[111] = 13;
            xOffset[112] = 14;
            xOffset[113] = 15;
            xOffset[114] = 16;

            try
            {
                P = (Shedules)Application.OpenForms["Shedules"];
                P.executeProgress.Value = 0;
            }
            catch
            { }

            DataRowView reportDataRowView;

            if (bs.Count > 0)
            {
                try
                {
                    //Переходим к первой записи
                    bs.MoveFirst();
                    reportDataRowView = (DataRowView)bs.Current;

                    //определяем текущий месяц
                    DateTime currDate = Convert.ToDateTime(Convert.ToString(reportDataRowView["ActionDate"]).Trim());

                    //Форматируем страницу
                    objSheet.Columns.ColumnWidth = 17;  //ширина столбцов
                    objSheet.Rows.RowHeight = 40;       //высота строк

                    //первая строка
                    objSheet.Cells[1, 1] = months[currDate.Month-1] + " " + currDate.Year.ToString() + " г.";
                    objSheet.Cells[1, 1].WrapText = true;
                    objSheet.Cells[1, 1].Font.Size = 18;
                    objSheet.Cells[1, 1].Font.Name = "Times New Roman";
                    objSheet.Cells[1, 1].Font.Bold = true;
                    MergeCells(1, 1, 1, 2);

                    //вторая строка
                    objSheet.Cells[2, 1] = "Число";
                    objSheet.Cells[2, 1].HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                    objSheet.Cells[2, 1].VerticalAlignment = Excel.XlVAlign.xlVAlignCenter;

                    objSheet.Cells[2, 2] = "День недели";
                    objSheet.Cells[2, 2].HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                    objSheet.Cells[2, 2].VerticalAlignment = Excel.XlVAlign.xlVAlignCenter;

                    for(int i = 0; i < 14; ++i)
                    {
                        objSheet.Cells[2, 3 + i] = facilities[i];
                        objSheet.Cells[2, 3 + i].HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                        objSheet.Cells[2, 3 + i].VerticalAlignment   = Excel.XlVAlign.xlVAlignCenter;
                        objSheet.Cells[2, 3 + i].WrapText = true;

                    }

                    DateTime d = new DateTime(currDate.Year, currDate.Month, 1);
                    DateTime a = new DateTime(currDate.Year, currDate.Month + 1, 1);

                    int ndays = (a - d).Days;

                    for (int i = 1; i <= ndays; ++i)
                    {
                        objSheet.Cells[2 + i, 1].HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                        objSheet.Cells[2 + i, 1].VerticalAlignment = Excel.XlVAlign.xlVAlignCenter;
                        objSheet.Cells[2 + i, 1] = i.ToString();
                        objSheet.Cells[2 + i, 2] = days[(int)new DateTime(currDate.Year, currDate.Month, i).DayOfWeek];
                        objSheet.Cells[2 + i, 2].HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                        objSheet.Cells[2 + i, 2].VerticalAlignment = Excel.XlVAlign.xlVAlignCenter;
                    }

                    int cnt = 1;

                    foreach (DataRowView item in bs)
                    {
                        try
                        {
                            P.executeProgress.Value = Convert.ToInt32((100.0 / bs.Count) * (cnt++));
                        }
                        catch { }

                        DataRow rown = item.Row;

                        string writestr = "";

                        //обязательные поля
                        int dm = Convert.ToInt32(item["DM"]);
                        int facility = Convert.ToInt32(item["FacilityID"]);
                        string eventDay = Convert.ToString(item["EventDay"]);

                        DateTime bt;
                        DateTime et;
                        string eventTitle;
                        string headerTitle;
                        int peoples;

                        if (rown.IsNull("EventTitle") == false)
                        {
                            eventTitle = Convert.ToString(item["EventTitle"]);
                            writestr += " " + eventTitle;
                        }

                        if (rown.IsNull("BeginTime") == false)
                        {
                            bt = Convert.ToDateTime(Convert.ToString(item["BeginTime"]).Trim());
                            writestr += " " + bt.ToShortTimeString();
                        }

                        if (rown.IsNull("EndTime") == false)
                        {
                            et = Convert.ToDateTime(Convert.ToString(item["EndTime"]).Trim());
                            writestr += " - " + et.ToShortTimeString();
                        }

                        if (rown.IsNull("HeaderTitle") == false)
                        {
                            headerTitle = Convert.ToString(item["HeaderTitle"]);
                            writestr += " " + headerTitle;
                        }

                        if (rown.IsNull("Peoples") == false)
                        {
                            peoples = Convert.ToInt32(item["Peoples"]);
                            writestr += " " + peoples + " чел.";
                        }

                        objSheet.Cells[2 + dm, xOffset[facility]].Font.Size = 9;
                        objSheet.Cells[2 + dm, xOffset[facility]].WrapText = true;
                        objSheet.Cells[2 + dm, xOffset[facility]] = writestr;

                    }

                    SetBorder(2, 1, 2 + ndays, 16);

                    //сохраняем в файл
                    objApp.DisplayAlerts = false;
                    objApp.Application.ActiveWorkbook.SaveAs(Filename: fName, AccessMode: Excel.XlSaveAsAccessMode.xlNoChange);
                    objApp.Application.ActiveWorkbook.Close(false);
                    objApp.Quit();
                }
                catch(Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else
            {
                MessageBox.Show("В указанном периоде отсутствуют записи для экпорта!");
            }
        }