示例#1
0
文件: MainForm.cs 项目: nakijun/adasg
        private void SaveDataSet()
        {
            Cursor.Current = Cursors.WaitCursor;

            DateTime date = monthCalendar1.SelectionStart;

            try
            {
                adaScheduleDataSet1.EnforceConstraints = false;

                Activity_ReminderTableAdapter arAdapter = new Activity_ReminderTableAdapter();
                arAdapter.Update(adaScheduleDataSet1.Activity_Reminder.Select("", "", DataViewRowState.Deleted));

                ScheduleTableAdapter scheduleAdapter = new ScheduleTableAdapter();
                scheduleAdapter.Update(adaScheduleDataSet1);

                ActivityTableAdapter activityAdapter = new ActivityTableAdapter();
                activityAdapter.Update(adaScheduleDataSet1);

                ReminderTableAdapter reminderAdapter = new ReminderTableAdapter();
                reminderAdapter.Update(adaScheduleDataSet1);

                arAdapter.Update(adaScheduleDataSet1);

                adaScheduleDataSet1.EnforceConstraints = true;
                adaScheduleDataSet1.AcceptChanges();
            }
            catch (Exception ex)
            {
                ReportError(ex);
            }

            Cursor.Current = Cursors.Default;
        }
        private bool UpdateCurrentActivity()
        {
            bool result = true;

            Cursor.Current = Cursors.WaitCursor;

            try
            {
                ActivityTableAdapter activityAdapter = new ActivityTableAdapter();
                int ret = activityAdapter.Update(adaScheduleDataSet1.Activity);
            }
            catch (Exception ex)
            {
                ReportError(ex);
                result = false;
            }

            Cursor.Current = Cursors.Default;
            return(result);
        }
        private bool AddWorkSystemInstance(ADAMobileDataSet.ActivityRow activityRow)
        {
            bool result = true;

            Cursor.Current = Cursors.WaitCursor;

            try
            {
                //ADAMobileDataSet.UserDataTable userTable = adaScheduleDataSet1.User;

                //if (userTable.Count > 0 && _userName != null
                //    && _userName.Length > 0 && userTable.Rows[0]["Name"] != _userName)
                //{
                //    userTable.Rows[0]["Name"] = _userName;
                //    UserTableAdapter userAdapter = new UserTableAdapter();
                //    int number = userAdapter.Update(adaScheduleDataSet1.User);
                //}
                adaScheduleDataSet1.EnforceConstraints = false;

                ScheduleTableAdapter scheduleAdapter = new ScheduleTableAdapter();
                scheduleAdapter.Init();
                int ret = scheduleAdapter.Update(adaScheduleDataSet1.Schedule);

                ActivityTableAdapter activityAdapter = new ActivityTableAdapter();
                activityAdapter.Init();
                ret = activityAdapter.Update(adaScheduleDataSet1.Activity);

                adaScheduleDataSet1.EnforceConstraints = true;
            }
            catch (Exception ex)
            {
                ReportError(ex);
                result = false;
            }

            Cursor.Current = Cursors.Default;
            return(result);
        }
示例#4
0
文件: MainForm.cs 项目: nakijun/adasg
        private void SaveDataSet()
        {
            Cursor.Current = Cursors.WaitCursor;

            try
            {
                adaWorkSystemDataSet1.EnforceConstraints = false;

                ScheduleTableAdapter scheduleAdapter = new ScheduleTableAdapter();
                scheduleAdapter.Update(adaWorkSystemDataSet1);

                ActivityTableAdapter activityAdapter = new ActivityTableAdapter();
                activityAdapter.Update(adaWorkSystemDataSet1);

                adaWorkSystemDataSet1.EnforceConstraints = true;
                adaWorkSystemDataSet1.AcceptChanges();
            }
            catch (Exception ex)
            {
                ReportError(ex);
            }

            Cursor.Current = Cursors.Default;
        }
示例#5
0
文件: MainForm.cs 项目: nakijun/adasg
        private void copyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SelectDateForm selectDateForm = new SelectDateForm();

            if (selectDateForm.ShowDialog(this) == DialogResult.OK)
            {
                for (DateTime copyToDate = selectDateForm.SelectionRange.Start;
                     copyToDate.CompareTo(selectDateForm.SelectionRange.End) <= 0;
                     copyToDate = copyToDate.AddDays(1))
                {
                    Cursor.Current = Cursors.WaitCursor;
                    ADAScheduleDataSet dataSet = new ADAScheduleDataSet();

                    try
                    {
                        LoadDataSet(dataSet, copyToDate, false);

                        DataRow[] scheduleRows = dataSet.Schedule.Select("Type <= " + 1);

                        foreach (ADAScheduleDataSet.ScheduleRow scheduleRow in scheduleRows)
                        {
                            scheduleRow.Delete();
                        }

                        ScheduleTableAdapter scheduleAdapter = new ScheduleTableAdapter();
                        ActivityTableAdapter activityAdapter = new ActivityTableAdapter();

                        activityAdapter.Update(dataSet);
                        scheduleAdapter.Update(dataSet);

                        scheduleRows = adaScheduleDataSet1.Schedule.Select("Type <= " + 1);

                        foreach (ADAScheduleDataSet.ScheduleRow scheduleRow in scheduleRows)
                        {
                            ADAScheduleDataSet.ScheduleRow newScheduleRow;
                            newScheduleRow          = dataSet.Schedule.NewScheduleRow();
                            newScheduleRow.Date     = copyToDate;
                            newScheduleRow.UserId   = scheduleRow.UserId;
                            newScheduleRow.Type     = scheduleRow.Type;
                            newScheduleRow.IsActive = true;
                            dataSet.Schedule.AddScheduleRow(newScheduleRow);

                            scheduleAdapter.Update(dataSet);

                            foreach (ADAScheduleDataSet.ActivityRow activityRow in scheduleRow.GetActivityRowsByFK_Activity_Schedule())
                            {
                                ADAScheduleDataSet.ActivityRow newActivityRow;

                                newActivityRow            = dataSet.Activity.NewActivityRow();
                                newActivityRow.ScheduleId = newScheduleRow.ScheduleId;

                                if (!activityRow.IsStartTimeNull())
                                {
                                    TimeSpan timeSpan = copyToDate.Subtract(activityRow.StartTime.Date);
                                    newActivityRow.StartTime = activityRow.StartTime.AddDays(timeSpan.Days);
                                }

                                if (!activityRow.IsEndTimeNull())
                                {
                                    TimeSpan timeSpan = copyToDate.Subtract(activityRow.EndTime.Date);
                                    newActivityRow.EndTime = activityRow.EndTime.AddDays(timeSpan.Days);
                                }

                                if (!activityRow.IsSymbolIdNull())
                                {
                                    newActivityRow.SymbolId = activityRow.SymbolId;
                                }

                                if (!activityRow.IsNameNull())
                                {
                                    newActivityRow.Name = activityRow.Name;
                                }

                                if (!activityRow.IsSequenceNull())
                                {
                                    newActivityRow.Sequence = activityRow.Sequence;
                                }

                                dataSet.Activity.AddActivityRow(newActivityRow);
                                activityAdapter.Update(dataSet);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        ReportError(ex);
                    }
                }

                Cursor.Current = Cursors.Default;

                monthCalendar1.SetDate(selectDateForm.SelectionRange.Start);
                LoadDataSet();
            }
        }