예제 #1
0
        private void cmdDom_Click(object sender, EventArgs e)
        {
            frmWizard wizard = new frmWizard();

            string[] str1 = null;
            string[] str2 = null;

            wizard.ChangeType = 3;

            if (txtDom.Text.Trim().Length > 0)
            {
                if (txtDom.Text.Trim() == "*")
                {
                    wizard.DateOfMonth1 = 0;
                    wizard.DateOfMonth2 = 0;
                }
                else
                {
                    try
                    {
                        str1 = txtDom.Text.Trim().Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries);
                        if (str1.Length > 0)
                        {
                            if (str1.Length == 1)
                            {
                                if (str1[0].Trim() == "*")
                                {
                                    wizard.DateOfMonth1 = 0;
                                }
                                else
                                {
                                    wizard.DateOfMonth1 = Convert.ToInt32(str1[0]);
                                }

                                wizard.DateOfMonth2 = 0;
                            }
                            else if (str1.Length == 2)
                            {
                                if (str1[0].Trim() == "*")
                                {
                                    wizard.DateOfMonth1 = 0;
                                }
                                else
                                {
                                    wizard.DateOfMonth1 = Convert.ToInt32(str1[0]);
                                }

                                if (str1[1].Trim() == "*")
                                {
                                    wizard.DateOfMonth2 = 0;
                                }
                                else
                                {
                                    wizard.DateOfMonth2 = Convert.ToInt32(str1[1]);
                                }
                            }
                            else
                            {
                                wizard.DateOfMonth1 = 0;
                                wizard.DateOfMonth2 = 0;
                            }
                        }
                        else
                        {
                            wizard.DateOfMonth1 = 0;
                            wizard.DateOfMonth2 = 0;
                        }
                    }
                    catch (Exception ex)
                    {
                        wizard.DateOfMonth1 = 0;
                        wizard.DateOfMonth2 = 0;
                    }
                }
            }
            else
            {
                wizard.DateOfMonth1 = 0;
                wizard.DateOfMonth2 = 0;
            }


            if (wizard.ShowDialog() == DialogResult.OK)
            {
                if (wizard.DateOfMonth1 > 0 && wizard.DateOfMonth2 > 0)
                {
                    txtDom.Text = string.Format("{0}-{1}", new object[] { wizard.DateOfMonth1, wizard.DateOfMonth2 });
                }
                else if (wizard.DateOfMonth1 > 0)
                {
                    txtDom.Text = string.Format("{0}", new object[] { wizard.DateOfMonth1 });
                }
                else if (wizard.DateOfMonth2 > 0)
                {
                    txtDom.Text = string.Format("{0}", new object[] { wizard.DateOfMonth2 });
                }
                else
                {
                    txtDom.Text = "*";
                }
            }
        }
예제 #2
0
        private void cmdMonth_Click(object sender, EventArgs e)
        {
            frmWizard wizard = new frmWizard();

            string[] str1 = null;
            string[] str2 = null;

            wizard.ChangeType = 4;

            if (txtMonth.Text.Trim().Length > 0)
            {
                if (txtMonth.Text.Trim() == "*")
                {
                    wizard.Month1 = "*";
                    wizard.Month2 = "*";
                }
                else
                {
                    try
                    {
                        str1 = txtMonth.Text.Trim().Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries);
                        if (str1.Length > 0)
                        {
                            if (str1.Length == 1)
                            {
                                wizard.Month1 = str1[0].Trim();
                                wizard.Month2 = "*";
                            }
                            else if (str1.Length == 2)
                            {
                                wizard.Month1 = str1[0].Trim();
                                wizard.Month2 = str1[1].Trim();
                            }
                            else
                            {
                                wizard.Month1 = "*";
                                wizard.Month2 = "*";
                            }
                        }
                        else
                        {
                            wizard.Month1 = "*";
                            wizard.Month2 = "*";
                        }
                    }
                    catch (Exception ex)
                    {
                        wizard.Month1 = "*";
                        wizard.Month2 = "*";
                    }
                }
            }
            else
            {
                wizard.Month1 = "*";
                wizard.Month2 = "*";
            }

            if (wizard.ShowDialog() == DialogResult.OK)
            {
                string strTime1 = "";
                string strTime2 = "";

                strTime1 = wizard.Month1.Trim();
                strTime2 = wizard.Month2.Trim();

                if (strTime1 == "" && strTime2 == "")
                {
                    txtMonth.Text = "*";
                }
                else if (strTime1 == "" && strTime2.Length > 0)
                {
                    txtMonth.Text = strTime2;
                }
                else if (strTime2 == "" && strTime1.Length > 0)
                {
                    txtMonth.Text = strTime1;
                }
                else
                {
                    txtMonth.Text = strTime1 + "-" + strTime2;
                }
            }
        }
예제 #3
0
        private void cmdTimeRange_Click(object sender, EventArgs e)
        {
            frmWizard wizard = new frmWizard();

            string[] str1 = null;
            string[] str2 = null;

            wizard.ChangeType = 1;

            if (txtTimeRange.Text.Trim().Length > 0)
            {
                if (txtTimeRange.Text.Trim() == "*")
                {
                    wizard.Hour1   = -1;
                    wizard.Hour2   = -1;
                    wizard.Minute1 = -1;
                    wizard.Minute2 = -1;
                }
                else
                {
                    try
                    {
                        str1 = txtTimeRange.Text.Trim().Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries);
                        if (str1.Length > 0)
                        {
                            if (str1.Length == 1)
                            {
                                str2 = str1[0].Trim().Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);

                                if (str2.Length == 2)
                                {
                                    wizard.Hour1   = Convert.ToInt32(str2[0]);
                                    wizard.Minute1 = Convert.ToInt32(str2[1]);
                                }
                                wizard.Hour2   = -1;
                                wizard.Minute2 = -1;
                            }
                            else if (str1.Length == 2)
                            {
                                str2 = str1[0].Trim().Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
                                if (str2.Length == 2)
                                {
                                    wizard.Hour1   = Convert.ToInt32(str2[0]);
                                    wizard.Minute1 = Convert.ToInt32(str2[1]);
                                }

                                str2 = str1[1].Trim().Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
                                if (str2.Length == 2)
                                {
                                    wizard.Hour2   = Convert.ToInt32(str2[0]);
                                    wizard.Minute2 = Convert.ToInt32(str2[1]);
                                }
                            }
                            else
                            {
                                wizard.Hour1   = -1;
                                wizard.Minute1 = -1;
                                wizard.Hour2   = -1;
                                wizard.Minute2 = -1;
                            }
                        }
                        else
                        {
                            wizard.Hour1   = -1;
                            wizard.Hour2   = -1;
                            wizard.Minute1 = -1;
                            wizard.Minute2 = -1;
                        }
                    }
                    catch (Exception ex)
                    {
                        wizard.Hour1   = -1;
                        wizard.Hour2   = -1;
                        wizard.Minute1 = -1;
                        wizard.Minute2 = -1;
                    }
                }
            }
            else
            {
                wizard.Hour1   = -1;
                wizard.Hour2   = -1;
                wizard.Minute1 = -1;
                wizard.Minute2 = -1;
            }


            if (wizard.ShowDialog() == DialogResult.OK)
            {
                string strTime1 = "";
                string strTime2 = "";

                if (wizard.Hour1 >= 0 && wizard.Minute1 >= 0)
                {
                    strTime1 = string.Format("{0:00}:{1:00}", new object[] { wizard.Hour1, wizard.Minute1 });
                }
                else
                {
                    strTime1 = "*";
                }

                if (wizard.Hour2 >= 0 && wizard.Minute2 >= 0)
                {
                    strTime2 = string.Format("{0:00}:{1:00}", new object[] { wizard.Hour2, wizard.Minute2 });
                }
                else
                {
                    strTime2 = "*";
                }

                if (strTime2 == "*" && strTime1 == "*")
                {
                    txtTimeRange.Text = "*";
                }
                else if (strTime1 != "*" && strTime2 == "*")
                {
                    txtTimeRange.Text = strTime1;
                }
                else if (strTime2 != "*" && strTime1 == "*")
                {
                    txtTimeRange.Text = strTime2;
                }
                else
                {
                    txtTimeRange.Text = strTime1 + "-" + strTime2;
                }
            }
        }