Esempio n. 1
0
        private bool ErrorCheck()
        {
            //必須入力(Entry required)、入力なければエラー(If there is no input, an error)E102
            if (string.IsNullOrWhiteSpace(txtSalesDate.Text))
            {
                //E102
                bbl.ShowMessage("E102");
                txtSalesDate.Focus();
                return(false);
            }

            txtSalesDate.Text = bbl.FormatDate(txtSalesDate.Text);

            //日付として正しいこと(Be on the correct date)E103
            if (!bbl.CheckDate(txtSalesDate.Text))
            {
                //E103
                bbl.ShowMessage("E103");
                txtSalesDate.Focus();
                return(false);
            }
            //入力できる範囲内の日付であること
            if (!bbl.CheckInputPossibleDate(txtSalesDate.Text))
            {
                //E115
                bbl.ShowMessage("E115");
                txtSalesDate.Focus();
                return(false);
            }
            //過去日付でないこと
            //共通処理-日付チェック-会計チェック
            if (!bbl.CheckInputPossibleDateWithFisicalMonth(txtSalesDate.Text))
            {
                //E115
                bbl.ShowMessage("E115");
                txtSalesDate.Focus();
                return(false);
            }

            return(true);
        }
        /// <summary>
        /// Check Date
        /// </summary>
        private bool DateCheck()
        {
            bbl = new Base_BL();
            if (!string.IsNullOrWhiteSpace(this.Text))
            {
                if (bbl.IsInteger(this.Text.Replace("/", "").Replace("-", "")))
                {
                    string day = string.Empty, month = string.Empty, year = string.Empty;
                    if (this.Text.Contains("/"))
                    {
                        string[] date = this.Text.Split('/');
                        day   = date[date.Length - 1].PadLeft(2, '0');
                        month = date[date.Length - 2].PadLeft(2, '0');

                        if (date.Length > 2)
                        {
                            year = date[date.Length - 3];
                        }

                        this.Text = year + month + day;//  this.Text.Replace("/", "");
                    }
                    else if (this.Text.Contains("-"))
                    {
                        string[] date = this.Text.Split('-');
                        day   = date[date.Length - 1].PadLeft(2, '0');
                        month = date[date.Length - 2].PadLeft(2, '0');

                        if (date.Length > 2)
                        {
                            year = date[date.Length - 3];
                        }

                        this.Text = year + month + day;//  this.Text.Replace("-", "");
                    }

                    string text = this.Text;
                    text  = text.PadLeft(8, '0');
                    day   = text.Substring(text.Length - 2);
                    month = text.Substring(text.Length - 4).Substring(0, 2);
                    year  = Convert.ToInt32(text.Substring(0, text.Length - 4)).ToString();

                    if (month == "00")
                    {
                        month = string.Empty;
                    }
                    if (year == "0")
                    {
                        year = string.Empty;
                    }

                    if (string.IsNullOrWhiteSpace(month))
                    {
                        month = DateTime.Now.Month.ToString().PadLeft(2, '0');//if user doesn't input for month,set current month
                    }
                    if (string.IsNullOrWhiteSpace(year))
                    {
                        year = DateTime.Now.Year.ToString();//if user doesn't input for year,set current year
                    }
                    else
                    {
                        if (year.Length == 1)
                        {
                            year = "200" + year;
                        }
                        else if (year.Length == 2)
                        {
                            year = "20" + year;
                        }
                    }

                    //string strdate = year + "-" + month + "-" + day;  2019.6.11 chg
                    string strdate = year + "/" + month + "/" + day;
                    if (bbl.CheckDate(strdate))
                    {
                        IsCorrectDate = true;
                        this.Text     = strdate;
                    }
                    else
                    {
                        ShowErrorMessage("E103");
                        return(false);
                    }
                }
                else
                {
                    ShowErrorMessage("E103");
                    return(false);
                }
            }

            return(true);
        }