Beispiel #1
0
 private void btnDel_All_Click(object sender, EventArgs e)
 {
     if (dgvAll.SelectedRows.Count > 0)
     {
         DataGridViewSelectedRowCollection selectedRows = dgvAll.SelectedRows;
         if (selectedRows[0].Cells["colRemindFlag_ALL"].Value.ToString() == "未处理" && MessageHandle.MessageAsk("注意:该日程还没执行!\n确定要删除该日程事务?", "确定删除") == DialogResult.OK)
         {
             BusAdminDaily.DeleteDailyById(selectedRows[0].Cells[0].Value.ToString());
             if (_dailyEntity != null && _dailyEntity.ID == selectedRows[0].Cells[0].Value.ToString())
             {
                 _dailyEntity = null;
                 ClearForm();
             }
             dgvAll.Rows.Remove(selectedRows[0]);
             MessageHandle.MessageInfo("恭喜,删除成功!", "提示信息");
         }
         else if (selectedRows[0].Cells["colRemindFlag_ALL"].Value.ToString() == "已处理" && MessageHandle.MessageAsk("确定要删除该日程事务?", "确定删除") == DialogResult.OK)
         {
             BusAdminDaily.DeleteDailyById(selectedRows[0].Cells[0].Value.ToString());
             if (_dailyEntity != null && _dailyEntity.ID == selectedRows[0].Cells[0].Value.ToString())
             {
                 _dailyEntity = null;
                 ClearForm();
             }
             dgvAll.Rows.Remove(selectedRows[0]);
             MessageHandle.MessageInfo("恭喜,删除成功!", "提示信息");
         }
     }
 }
Beispiel #2
0
 private void btnCancelAll_Click(object sender, EventArgs e)
 {
     if (dgvAll.SelectedRows.Count > 0)
     {
         DataGridViewSelectedRowCollection selectedRows = dgvAll.SelectedRows;
         if (selectedRows[0].Cells["colRemindFlag_ALL"].Value.ToString() == "未处理" && MessageHandle.MessageAsk("确定要取消该日程事务?", "确定取消") == DialogResult.OK)
         {
             if (BusAdminDaily.UpdateDaliyState(selectedRows[0].Cells[0].Value.ToString(), "0"))
             {
                 selectedRows[0].Cells["colRemindFlag_ALL"].Value = "已处理";
                 MessageHandle.MessageInfo("恭喜,取消成功!", "提示信息");
             }
         }
     }
 }
Beispiel #3
0
 private void btnDeleteAll_All_Click(object sender, EventArgs e)
 {
     if (dgvAll.Rows.Count > 0)
     {
         bool bHasToDo = false;
         if (dgvAll.Rows[0].Cells[5].Value.ToString() == "未处理")
         {
             bHasToDo = true;
         }
         if (bHasToDo && MessageHandle.MessageAsk("注意:有日程事务还没执行!\n确定要删除所有日程事务?", "确定删除") == DialogResult.OK)
         {
             BusAdminDaily.DeleteDailyOfAll();
             if (_dailyEntity != null)
             {
                 foreach (DataGridViewRow dataRow in dgvAll.Rows)
                 {
                     if (_dailyEntity.ID == dataRow.Cells[0].Value.ToString())
                     {
                         ClearForm();
                         _dailyEntity = null;
                         break;
                     }
                 }
             }
             _dsAll.Tables[0].Rows.Clear();
             MessageHandle.MessageInfo("恭喜,删除成功!", "提示信息");
         }
         else if (!bHasToDo && MessageHandle.MessageAsk("确定要删除所有日程事务?", "确定删除") == DialogResult.OK)
         {
             BusAdminDaily.DeleteDidDailyOfAll();
             if (_dailyEntity != null)
             {
                 foreach (DataGridViewRow dataRow in dgvAll.Rows)
                 {
                     if (_dailyEntity.ID == dataRow.Cells[0].Value.ToString())
                     {
                         ClearForm();
                         _dailyEntity = null;
                         break;
                     }
                 }
             }
             _dsAll.Tables[0].Rows.Clear();
             MessageHandle.MessageInfo("恭喜,删除成功!", "提示信息");
         }
     }
 }
Beispiel #4
0
        private void FrmMain_Load(object sender, EventArgs e)
        {
            InitUI();
            //判断是否第一次运行,如果是第一次运行转换到配置选项卡
            RegistryKey regKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\景仁海\");

            if (regKey != null)
            {
                bool IsFirstRun = Convert.ToBoolean(regKey.GetValue("firstRun"));
                if (IsFirstRun)
                {
                    MessageHandle.MessageInfo("初次使用系统,请设置运行参数!", "系统提示");
                    tbcContainer.SelectedTab = tabPageConfig;
                }
                regKey.Close();
            }
        }
Beispiel #5
0
 private void btnAddDaily_Click(object sender, EventArgs e)
 {
     if (operType == 1)
     {
         if (MessageHandle.MessageAsk("增加将会丢失修改数据,确定要执行增加操作?", "确定增加") == DialogResult.OK)
         {
             ClearForm();
             cboLevel.Select();
         }
     }
     else
     {
         if (IsValid())
         {
             _dailyEntity                     = new DailyEntity();
             _dailyEntity.D_CONTENT           = rtbContent.Text;
             _dailyEntity.D_REMIND_MUSIC_PATH = txtMusicPath.Text;
             string grade;
             if (chkLunar.Checked)
             {
                 _dailyEntity.D_LUNAR_CALENDAR = dtpTime.Value.ToString();
                 ChineseCalendarInfo cCalendar = ChineseCalendarInfo.FromLunarDate(dtpTime.Value.Date, false);
                 DateTime            solar     = cCalendar.SolarDate.Add(new TimeSpan(dtpTime.Value.Hour, dtpTime.Value.Minute, dtpTime.Value.Second));
                 _dailyEntity.D_SOLAR_CALENDAR = solar.ToString();
                 grade = BusAdminDaily.CalculateGrade(solar);
                 _dailyEntity.D_LEVEL = grade;
             }
             else
             {
                 _dailyEntity.D_SOLAR_CALENDAR = dtpTime.Value.ToString();
                 grade = BusAdminDaily.CalculateGrade(dtpTime.Value);
                 _dailyEntity.D_LEVEL = grade;
             }
             if (BusAdminDaily.AddDaily(_dailyEntity))
             {
                 ClearForm();
                 _dailyEntity = null;
                 BindAll();
                 if (MessageHandle.MessageInfo("恭喜,增加成功!", "提示信息") == DialogResult.OK)
                 {
                     BusAdminDaily.InitTodayUnDoDaily();
                 }
             }
         }
     }
 }
Beispiel #6
0
 private void btnDelDidToday_Click(object sender, EventArgs e)
 {
     if (dgvDidToday.SelectedRows.Count > 0 && MessageHandle.MessageAsk("确定要删除该日程事务?", "确定删除") == DialogResult.OK)
     {
         DataGridViewSelectedRowCollection selectedRows = dgvDidToday.SelectedRows;
         if (BusAdminDaily.DeleteDailyById(selectedRows[0].Cells[0].Value.ToString()))
         {
             if (_dailyEntity != null && _dailyEntity.ID == selectedRows[0].Cells[0].Value.ToString())
             {
                 _dailyEntity = null;
                 ClearForm();
             }
             dgvDidToday.Rows.Remove(selectedRows[0]);
             MessageHandle.MessageInfo("恭喜,删除成功!", "提示信息");
         }
     }
 }
Beispiel #7
0
 private void btnCancelToday_Click(object sender, EventArgs e)
 {
     if (dgvToday.SelectedRows.Count > 0 && MessageHandle.MessageAsk("确定要取消该日程事务?", "确定取消") == DialogResult.OK)
     {
         DataGridViewSelectedRowCollection selectedRows = dgvToday.SelectedRows;
         if (BusAdminDaily.UpdateDaliyState(selectedRows[0].Cells[0].Value.ToString(), "0"))
         {
             selectedRows[0].Cells["colRemindFlag_Today"].Value = "已处理";
             DataRow dr = ((DataRowView)selectedRows[0].DataBoundItem).Row;
             _dsDidToday.Tables[0].Rows.Add(dr.ItemArray);
             dgvDidToday.CurrentCell = dgvDidToday.Rows[dgvDidToday.Rows.Count - 1].Cells[1];
             if (_dailyEntity != null && _dailyEntity.ID == selectedRows[0].Cells[0].Value.ToString())
             {
                 _dailyEntity.D_REMIND_FLAG = "0";
             }
             dgvToday.Rows.Remove(selectedRows[0]);
             MessageHandle.MessageInfo("恭喜,取消成功!", "提示信息");
         }
     }
 }
Beispiel #8
0
 private void btnClearDidToday_Click(object sender, EventArgs e)
 {
     if (dgvDidToday.SelectedRows.Count > 0 && MessageHandle.MessageAsk("确定要删除当日所有已处理日程事务?", "确定删除") == DialogResult.OK)
     {
         if (BusAdminDaily.DeleteDailyOfToday())
         {
             if (_dailyEntity != null)
             {
                 foreach (DataGridViewRow dataRow in dgvDidToday.Rows)
                 {
                     if (_dailyEntity.ID == dataRow.Cells[0].Value.ToString())
                     {
                         ClearForm();
                         _dailyEntity = null;
                         break;
                     }
                 }
             }
             _dsDidToday.Tables[0].Rows.Clear();
             MessageHandle.MessageInfo("恭喜,清空成功!", "提示信息");
         }
     }
 }
Beispiel #9
0
 private void btnDeleteDaily_Click(object sender, EventArgs e)
 {
     if (_dailyEntity.D_REMIND_FLAG == "1" && MessageHandle.MessageAsk("注意:该日程事务还没处理!\n确定要删除该日程事务?", "确定删除") == DialogResult.OK)
     {
         BusAdminDaily.DeleteDailyById(_dailyEntity.ID);
         ClearForm();
         _dailyEntity = null;
         MessageHandle.MessageInfo("恭喜,删除成功!", "提示信息");
         if (mFromWhere == 1)
         {
             tbcContainer.SelectedTab = tabPageToday;
             mFromWhere = 0;
         }
         else
         {
             BindAll();
             dgvAll.Select();
         }
     }
     else if (_dailyEntity.D_REMIND_FLAG == "0" && MessageHandle.MessageAsk("你确定要删除该日程事务?", "确定删除") == DialogResult.OK)
     {
         BusAdminDaily.DeleteDailyById(_dailyEntity.ID);
         ClearForm();
         _dailyEntity = null;
         MessageHandle.MessageInfo("恭喜,删除成功!", "提示信息");
         if (mFromWhere == 1)
         {
             tbcContainer.SelectedTab = tabPageToday;
             mFromWhere = 0;
         }
         else
         {
             BindAll();
             dgvAll.Select();
         }
     }
 }
Beispiel #10
0
 private void btnClearAll_Click(object sender, EventArgs e)
 {
     if (dgvAll.Rows.Count > 0)
     {
         if (MessageHandle.MessageAsk("确定要删除所有已处理日程事务?", "确定删除") == DialogResult.OK)
         {
             BusAdminDaily.DeleteDidDailyOfAll();
             if (_dailyEntity != null)
             {
                 foreach (DataGridViewRow dataRow in dgvAll.Rows)
                 {
                     if (_dailyEntity.ID == dataRow.Cells[0].Value.ToString())
                     {
                         ClearForm();
                         _dailyEntity = null;
                         break;
                     }
                 }
             }
             _dsAll.Tables[0].DefaultView.RowFilter = "D_REMIND_FLAG='未处理'";
             MessageHandle.MessageInfo("恭喜,清空成功!", "提示信息");
         }
     }
 }
Beispiel #11
0
        private void btnModifyDefault_Click(object sender, EventArgs e)
        {
            string      fileName = Application.StartupPath + "\\Config.xml";
            XmlDocument xml      = new XmlDocument();

            try
            {
                xml.Load(fileName);
            }
            catch (XmlException ex)
            {
                MessageHandle.MessageError(ex.Message, "错误信息");
                return;
            }
            //修改到配置文件
            bool    bModifyDefault = true;
            string  errMessage     = "";
            XmlNode node           = xml.SelectSingleNode("Root/MusicPath");

            if (node != null)
            {
                node.InnerText = txtDefaultMusicPath.Text;
            }
            else
            {
                errMessage    += "配置文件节点:Root/MusicPath不存在。\n";
                bModifyDefault = false;
            }
            node = xml.SelectSingleNode("Root/Times");
            if (node != null)
            {
                node.InnerText = nudTimes.Value.ToString();
            }
            else
            {
                errMessage    += "配置文件节点:Root/Times不存在。\n";
                bModifyDefault = false;
            }
            node = xml.SelectSingleNode("Root/Minutes");
            if (node != null)
            {
                node.InnerText = nudMinute.Value.ToString();
            }
            else
            {
                errMessage    += "配置文件节点:Root/Minutes不存在。\n";
                bModifyDefault = false;
            }
            node = xml.SelectSingleNode("Root/RunBackground");
            if (node != null)
            {
                node.InnerText = chkRunBackground.Checked.ToString();
            }
            else
            {
                errMessage    += "配置文件节点:Root/RunBackground不存在。\n";
                bModifyDefault = false;
            }
            xml.Save(fileName);
            //修改到注册表
            if (bModifyDefault)
            {
                if (chkRunOnStart.Checked)
                {
                    RegistryKey dailyRun = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true);
                    dailyRun.SetValue("daily", Application.StartupPath + "\\daily.exe");
                    dailyRun.Close();
                }
                else
                {
                    RegistryKey dailyRun    = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true);
                    string[]    subkeyNames = dailyRun.GetValueNames();
                    foreach (string key in subkeyNames)
                    {
                        if (key.ToLower() == "daily")
                        {
                            dailyRun.DeleteValue("daily");
                            break;
                        }
                    }
                    dailyRun.Close();
                }
                try
                {
                    RegistryKey regKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\景仁海\", true);
                    regKey.SetValue("firstRun", false);
                    regKey.Close();
                }
                catch
                { }
                GlobalVariable.DEFAULT_MUSIC_PATH = txtDefaultMusicPath.Text;
                GlobalVariable.TIMES          = (int)nudTimes.Value;
                GlobalVariable.MINUTES        = (int)nudMinute.Value;
                GlobalVariable.RUN_BACKGROUND = chkRunBackground.Checked;
                GlobalVariable.RUN_ON_START   = chkRunOnStart.Checked;
                lbMinute.Visible = false;
                lbTimes.Visible  = false;
                MessageHandle.MessageInfo("修改默认设置成功!", "提示信息");
            }
            else
            {
                MessageHandle.MessageError(errMessage, "错误信息");
            }
            LoadDefault();
        }
Beispiel #12
0
 private void btnModifyDaily_Click(object sender, EventArgs e)
 {
     if (IsValid())
     {
         _dailyEntity.D_CONTENT           = rtbContent.Text;
         _dailyEntity.D_LEVEL             = cboLevel.SelectedValue.ToString();
         _dailyEntity.D_REMIND_MUSIC_PATH = txtMusicPath.Text;
         string grade;
         if (chkLunar.Checked)
         {
             _dailyEntity.D_LUNAR_CALENDAR = dtpTime.Value.ToString();
             ChineseCalendarInfo cCalendar = ChineseCalendarInfo.FromLunarDate(dtpTime.Value.Date, false);
             DateTime            solar     = cCalendar.SolarDate.Add(new TimeSpan(dtpTime.Value.Hour, dtpTime.Value.Minute, dtpTime.Value.Second));
             _dailyEntity.D_SOLAR_CALENDAR = solar.ToString();
             grade = BusAdminDaily.CalculateGrade(solar);
             _dailyEntity.D_LEVEL = grade;
         }
         else
         {
             _dailyEntity.D_LUNAR_CALENDAR = "";
             _dailyEntity.D_SOLAR_CALENDAR = dtpTime.Value.ToString();
             grade = BusAdminDaily.CalculateGrade(dtpTime.Value);
             _dailyEntity.D_LEVEL = grade;
         }
         if (BusAdminDaily.ModifyDaily(_dailyEntity))
         {
             if (MessageHandle.MessageInfo("恭喜,修改成功!", "提示信息") == DialogResult.OK)
             {
                 BusAdminDaily.UpdateDailyStateBySystem();
             }
             if (mFromWhere == 1)
             {
                 tbcContainer.SelectedTab = tabPageToday;
                 mFromWhere = 0;
                 foreach (DataGridViewRow dgvRow in dgvToday.SelectedRows)
                 {
                     dgvRow.Selected = false;
                 }
                 foreach (DataGridViewRow dgvRow in dgvToday.Rows)
                 {
                     if (dgvRow.Cells[0].Value.ToString() == _dailyEntity.ID)
                     {
                         dgvRow.Selected = true;
                         break;
                     }
                 }
             }
             else
             {
                 BindAll();
                 dgvAll.Select();
                 foreach (DataGridViewRow dgvRow in dgvAll.SelectedRows)
                 {
                     dgvRow.Selected = false;
                 }
                 foreach (DataGridViewRow dgvRow in dgvAll.Rows)
                 {
                     if (dgvRow.Cells[0].Value.ToString() == _dailyEntity.ID)
                     {
                         dgvRow.Selected = true;
                         break;
                     }
                 }
             }
             ClearForm();
             _dailyEntity = null;
         }
     }
 }