예제 #1
0
 private void dtpTime_ValueChanged(object sender, EventArgs e)
 {
     if (!_bClearForm)
     {
         string grade = "4";
         if (chkLunar.Checked)
         {
             try
             {
                 ChineseCalendarInfo cCalendar = ChineseCalendarInfo.FromLunarDate(dtpTime.Value, false);
                 tooltipTime.SetToolTip(dtpTime, "对应太阳历:" + cCalendar.SolarDate.ToShortDateString());
                 grade = BusAdminDaily.CalculateGrade(cCalendar.SolarDate.Add(new TimeSpan(dtpTime.Value.Hour, dtpTime.Value.Minute, dtpTime.Value.Second)));
             }
             catch (Exception ex)
             {
                 MessageHandle.MessageError("错误:" + ex.Message + "!", "错误信息");
                 dtpTime.Focus();
             }
         }
         else
         {
             grade = BusAdminDaily.CalculateGrade(dtpTime.Value);
         }
         cboLevel.SelectedValue = grade;
         if (grade == "4")
         {
             MessageHandle.MessageWarnning("事务时间已过期!", "警告信息");
             dtpTime.Focus();
         }
     }
 }
예제 #2
0
 /// <summary>
 /// 检验数据输入
 /// </summary>
 private bool IsValid()
 {
     if (rtbContent.Text == "")
     {
         MessageHandle.MessageError("事务内容不能为空!", "错误信息");
         rtbContent.Focus();
         return(false);
     }
     if (txtMusicPath.Text == "")
     {
         MessageHandle.MessageError("提示音乐不能为空!", "错误信息");
         txtMusicPath.Focus();
         return(false);
     }
     if (cboLevel.SelectedValue.ToString() == "4")
     {
         if (MessageBox.Show("事务时间已过期,继续添加请点击确定!", "警告信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.Cancel)
         {
             dtpTime.Focus();
             return(false);
         }
     }
     if (chkLunar.Checked)
     {
         try
         {
             ChineseCalendarInfo.FromLunarDate(dtpTime.Value, false);
         }
         catch (Exception ex)
         {
             MessageHandle.MessageError("错误:" + ex.Message + "!", "错误信息");
             dtpTime.Focus();
             return(false);
         }
     }
     return(true);
 }
예제 #3
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();
        }