예제 #1
0
        // 保存、创建、删除日历
        // return:
        //      -1  出错
        //      0   成功
        int SetCalendarContent(
            string strAction,
            string strName,
            string strRange,
            string strContent,
            string strComment,
            out string strError)
        {
            strError = "";

            EnableControls(false);

            stop.OnStop += new StopEventHandler(this.DoStop);
            stop.Initial("正在对日历 '" + strName + "' 进行 " + strAction + " 操作 ...");
            stop.BeginLoop();

            this.Update();
            Program.MainForm.Update();

            try
            {
                CalenderInfo info = new CalenderInfo();
                info.Name         = strName;
                info.Range        = strRange;
                info.Comment      = strComment;
                info.Content      = strContent;

                long lRet = Channel.SetCalendar(
                    stop,
                    strAction,
                    info,
                    out strError);
                if (lRet == -1)
                {
                    goto ERROR1;
                }
            }
            finally
            {
                stop.EndLoop();
                stop.OnStop -= new StopEventHandler(this.DoStop);
                stop.Initial("");

                EnableControls(true);
            }

            return(0);

ERROR1:
            return(-1);
        }
예제 #2
0
        int SaveCalendars(out string strError)
        {
            strError = "";

            EnableControls(false);

            stop.OnStop += new StopEventHandler(this.DoStop);
            stop.Initial("正在保存日历 ...");
            stop.BeginLoop();

            this.Update();
            Program.MainForm.Update();

            try
            {
                int nErrorCount = 0;
                List <ListViewItem> delete_items = new List <ListViewItem>();

                foreach (ListViewItem item in this.listView_calendar.Items)
                {
                    if (item.ImageIndex == ITEMTYPE_NORMAL)
                    {
                        continue;
                    }

                    CalenderInfo info = new CalenderInfo();
                    info.Name    = ListViewUtil.GetItemText(item, COLUMN_CALENDAR_NAME);
                    info.Range   = ListViewUtil.GetItemText(item, COLUMN_CALENDAR_RANGE);
                    info.Comment = ListViewUtil.GetItemText(item, COLUMN_CALENDAR_COMMENT);
                    info.Content = ListViewUtil.GetItemText(item, COLUMN_CALENDAR_CONTENT);

                    string strAction = "";
                    if (item.ImageIndex == ITEMTYPE_NEW)
                    {
                        strAction = "new";
                    }
                    else if (item.ImageIndex == ITEMTYPE_CHANGED)
                    {
                        strAction = "change";
                    }
                    else if (item.ImageIndex == ITEMTYPE_DELETED)
                    {
                        strAction = "delete";
                    }
                    else
                    {
                        strError = "未知的 item.ImageIndex [" + item.ImageIndex.ToString() + "]";
                        return(-1);
                    }

                    long lRet = Channel.SetCalendar(
                        stop,
                        strAction,
                        info,
                        out strError);
                    if (lRet == -1)
                    {
                        DialogResult result = MessageBox.Show(this,
                                                              "针对日历 " + info.Name + " 进行 " + strAction + " 操作出错:" + strError + "\r\n\r\n请问是否继续进行余下的保存操作?",
                                                              "ManagerForm",
                                                              MessageBoxButtons.YesNo,
                                                              MessageBoxIcon.Question,
                                                              MessageBoxDefaultButton.Button2);
                        if (result == System.Windows.Forms.DialogResult.No)
                        {
                            return(-1);
                        }
                        nErrorCount++;
                        continue;
                    }

                    if (item.ImageIndex == ITEMTYPE_DELETED)
                    {
                        delete_items.Add(item);
                    }
                    else
                    {
                        SetCalendarItemState(item, ITEMTYPE_NORMAL);
                    }
                }

                foreach (ListViewItem item in delete_items)
                {
                    this.listView_calendar.Items.Remove(item);
                }

                if (nErrorCount == 0)
                {
                    this.CalendarDefChanged = false;
                }
            }
            finally
            {
                stop.EndLoop();
                stop.OnStop -= new StopEventHandler(this.DoStop);
                stop.Initial("");

                EnableControls(true);
            }

            return(0);
        }
예제 #3
0
        int SaveCalendars(out string strError)
        {
            strError = "";

            EnableControls(false);

            stop.OnStop += new StopEventHandler(this.DoStop);
            stop.Initial("正在保存日历 ...");
            stop.BeginLoop();

            this.Update();
            this.MainForm.Update();

            try
            {
                int nErrorCount = 0;
                List<ListViewItem> delete_items = new List<ListViewItem>();

                foreach (ListViewItem item in this.listView_calendar.Items)
                {
                    if (item.ImageIndex == ITEMTYPE_NORMAL)
                        continue;

                    CalenderInfo info = new CalenderInfo();
                    info.Name = ListViewUtil.GetItemText(item, COLUMN_CALENDAR_NAME);
                    info.Range = ListViewUtil.GetItemText(item, COLUMN_CALENDAR_RANGE);
                    info.Comment = ListViewUtil.GetItemText(item, COLUMN_CALENDAR_COMMENT);
                    info.Content = ListViewUtil.GetItemText(item, COLUMN_CALENDAR_CONTENT);

                    string strAction = "";
                    if (item.ImageIndex == ITEMTYPE_NEW)
                        strAction = "new";
                    else if (item.ImageIndex == ITEMTYPE_CHANGED)
                        strAction = "change";
                    else if (item.ImageIndex == ITEMTYPE_DELETED)
                        strAction = "delete";
                    else
                    {
                        strError = "未知的 item.ImageIndex ["+item.ImageIndex.ToString()+"]";
                        return -1;
                    }

                    long lRet = Channel.SetCalendar(
                        stop,
                        strAction,
                        info,
                        out strError);
                    if (lRet == -1)
                    {
                        DialogResult result = MessageBox.Show(this,
    "针对日历 " + info.Name + " 进行 "+strAction+" 操作出错:"+strError+"\r\n\r\n请问是否继续进行余下的保存操作?",
    "ManagerForm",
    MessageBoxButtons.YesNo,
    MessageBoxIcon.Question,
    MessageBoxDefaultButton.Button2);
                        if (result == System.Windows.Forms.DialogResult.No)
                            return -1;
                        nErrorCount++;
                        continue;
                    }

                    if (item.ImageIndex == ITEMTYPE_DELETED)
                        delete_items.Add(item);
                    else
                        SetCalendarItemState(item, ITEMTYPE_NORMAL);
                }

                foreach (ListViewItem item in delete_items)
                {
                    this.listView_calendar.Items.Remove(item);
                }

                if (nErrorCount == 0)
                    this.CalendarDefChanged = false;
            }
            finally
            {
                stop.EndLoop();
                stop.OnStop -= new StopEventHandler(this.DoStop);
                stop.Initial("");

                EnableControls(true);
            }

            return 0;
        }
예제 #4
0
        // 保存、创建、删除日历
        // return:
        //      -1  出错
        //      0   成功
        int SetCalendarContent(
            string strAction,
            string strName,
            string strRange,
            string strContent,
            string strComment,
            out string strError)
        {
            strError = "";

            EnableControls(false);

            stop.OnStop += new StopEventHandler(this.DoStop);
            stop.Initial("正在对日历 '" + strName + "' 进行 " + strAction + " 操作 ...");
            stop.BeginLoop();

            this.Update();

            try
            {
                CalenderInfo info = new CalenderInfo();
                info.Name = strName;
                info.Range = strRange;
                info.Comment = strComment;
                info.Content = strContent;

                long lRet = Channel.SetCalendar(
                    stop,
                    strAction,
                    info,
                    out strError);
                if (lRet == -1)
                    goto ERROR1;

            }
            finally
            {
                stop.EndLoop();
                stop.OnStop -= new StopEventHandler(this.DoStop);
                stop.Initial("");

                EnableControls(true);

            }

            return 0;
        ERROR1:
            return -1;
        }