예제 #1
0
        public static void InitDate(DataInitWhere.geDateKbn DateKbn, ref ExDatePicker dpFrom, ref ExDatePicker dpTo)
        {
            DateTime dtNow    = DateTime.Now;
            string   strNow   = DateTime.Now.ToString("yyyy/MM") + "/01";
            DateTime datStart = ExCast.zConvertToDate(strNow);

            dpFrom.SelectedDate = null;
            dpTo.SelectedDate   = null;

            switch (DateKbn)
            {
            case DataInitWhere.geDateKbn.Month:
                dpFrom.SelectedDate = datStart;
                dpFrom.Text         = datStart.ToString("yyyy/MM/dd");
                dpTo.SelectedDate   = datStart.AddMonths(1).AddDays(-1);
                dpTo.Text           = datStart.AddMonths(1).AddDays(-1).ToString("yyyy/MM/dd");
                break;

            case DataInitWhere.geDateKbn.Today:
                dpFrom.SelectedDate = dtNow;
                dpFrom.Text         = dtNow.ToString("yyyy/MM/dd");
                dpTo.SelectedDate   = dtNow;
                dpTo.Text           = dtNow.ToString("yyyy/MM/dd");
                break;
            }
        }
        private void utlSummingUp_LostFocus(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(utlSummingUp.txtID.Text.Trim()))
            {
                return;
            }

            string yyyymm       = "";
            string now_yyyymmdd = DateTime.Now.ToString("yyyy/MM/dd");

            if (this.datPaymentYmd.SelectedDate == null)
            {
                this.datPaymentYmd.SelectedDate = ExCast.zConvertToDate(now_yyyymmdd);
            }
            yyyymm = ExCast.zConvertToDate(this.datPaymentYmd.SelectedDate).ToString("yyyy/MM");

            int _id = ExCast.zCInt(utlSummingUp.txtID.Text.Trim());

            switch (_id)
            {
            case 5:
                _entityPrm._payment_yyyymmdd    = "";
                this.datPaymentYmd.SelectedDate = null;
                _entityPrm._payment_yyyymmdd    = yyyymm + "/05";
                this.datPaymentYmd.DisplayDate  = ExCast.zConvertToDate(yyyymm + "/05");
                break;

            case 15:
                _entityPrm._payment_yyyymmdd    = "";
                this.datPaymentYmd.SelectedDate = null;
                _entityPrm._payment_yyyymmdd    = yyyymm + "/15";
                this.datPaymentYmd.DisplayDate  = ExCast.zConvertToDate(yyyymm + "/15");
                break;

            case 20:
                _entityPrm._payment_yyyymmdd    = "";
                this.datPaymentYmd.SelectedDate = null;
                _entityPrm._payment_yyyymmdd    = yyyymm + "/20";
                this.datPaymentYmd.DisplayDate  = ExCast.zConvertToDate(yyyymm + "/20");
                break;

            case 25:
                _entityPrm._payment_yyyymmdd    = "";
                this.datPaymentYmd.SelectedDate = null;
                _entityPrm._payment_yyyymmdd    = yyyymm + "/25";
                this.datPaymentYmd.DisplayDate  = ExCast.zConvertToDate(yyyymm + "/25");
                break;

            case 31:
                _entityPrm._payment_yyyymmdd    = "";
                this.datPaymentYmd.SelectedDate = null;
                DateTime dt = ExCast.zConvertToDate(yyyymm + "/01");
                this.datPaymentYmd.SelectedDate = dt.AddMonths(1).AddDays(-1);
                this.datPaymentYmd.DisplayDate  = (DateTime)this.datPaymentYmd.SelectedDate;
                break;

            default:
                break;
            }
        }
        // 条件句SQL設定
        private string GetSQLWhere()
        {
            string strWhrer        = "";
            string strWhrerString1 = "";
            string strWhrerString2 = "";

            // 請求区分
            strWhrer += "   AND T.INVOICE_KBN = 0 " + Environment.NewLine;

            // 対象年月
            string proc_ym = this.datYm.Text.Trim();

            DateTime this_ym_from = ExCast.zConvertToDate(proc_ym + "/01");
            DateTime this_ym_to   = this_ym_from.AddMonths(1).AddDays(-1);

            strWhrerString1 += "[対象年月 " + this_ym_from.ToString("yyyy/MM");
            strWhrer        += "   AND T.INVOICE_YYYYMMDD >= " + ExEscape.zRepStr(this_ym_from.ToString("yyyy/MM/dd")) + Environment.NewLine;
            strWhrer        += "   AND T.INVOICE_YYYYMMDD <= " + ExEscape.zRepStr(this_ym_to.ToString("yyyy/MM/dd")) + Environment.NewLine;

            // 請求先
            if (this.utlInvoice_F.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.INVOICE_ID >= " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(this.utlInvoice_F.txtID.Text.Trim())) + Environment.NewLine;
                strWhrerString1 += "] [請求先 " + this.utlInvoice_F.txtID.Text.Trim() + "~";
            }
            else
            {
                strWhrerString1 += "] [請求先 未指定~";
            }
            if (this.utlInvoice_T.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.INVOICE_ID <= " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(this.utlInvoice_T.txtID.Text.Trim())) + Environment.NewLine;
                strWhrerString1 += this.utlInvoice_T.txtID.Text.Trim() + "]";
            }
            else
            {
                strWhrerString1 += "未指定]";
            }

            return(strWhrer + "WhereString =>" + strWhrerString1 + ";" + strWhrerString2);
        }
        // 入力チェック
        public override void InputCheckUpdate()
        {
            #region Field

            string  errMessage     = "";
            string  warnMessage    = "";
            int     _selectIndex   = 0;
            int     _selectColumn  = 0;
            bool    IsDetailExists = false;
            Control errCtl         = null;
            bool    _flg           = false;

            #endregion

            try
            {
                #region チェック処理

                switch (this.proceeKbn)
                {
                case eProccessKbn.None:
                    return;

                case eProccessKbn.Delete:

                    #region 削除チェック

                    if (this._entity == null)
                    {
                        ExMessageBox.Show("削除対象データがありません。");
                        return;
                    }

                    if (this._entity.Count == 0)
                    {
                        ExMessageBox.Show("削除対象データがありません。");
                        return;
                    }

                    _flg = false;
                    for (int i = 0; i <= _entity.Count - 1; i++)
                    {
                        if (_entity[i]._exec_flg == true)
                        {
                            _flg = true;
                        }
                    }
                    if (_flg == false)
                    {
                        ExMessageBox.Show("削除対象データが選択されていません。");
                        return;
                    }

                    _flg = false;
                    for (int i = 0; i <= _entity.Count - 1; i++)
                    {
                        if (_entity[i]._exec_flg == true && _entity[i]._no != "未")
                        {
                            _flg = true;
                        }
                    }
                    if (_flg == false)
                    {
                        ExMessageBox.Show("削除対象データは締切がされていません。");
                        return;
                    }

                    UpdateData(Common.geUpdateType.Delete);
                    return;

                    #endregion

                case eProccessKbn.Total:

                    #region 必須チェック

                    // 支払締日
                    if (string.IsNullOrEmpty(this._entityPrm._payment_yyyymmdd))
                    {
                        errMessage += "支払締日が入力されていません。" + Environment.NewLine;
                        if (errCtl == null)
                        {
                            errCtl = this.datPaymentYmd;
                        }
                    }

                    #endregion

                    #region 入力チェック

                    // 締区分
                    if ((!string.IsNullOrEmpty(this._entityPrm._summing_up_group_id)) && string.IsNullOrEmpty(this._entityPrm._summing_up_group_nm))
                    {
                        errMessage += "締区分が適切に入力(選択)されていません。" + Environment.NewLine;
                        if (errCtl == null)
                        {
                            errCtl = this.utlSummingUp.txtID;
                        }
                    }

                    // 仕入先
                    if ((!string.IsNullOrEmpty(this._entityPrm._purchase_id)) && string.IsNullOrEmpty(this._entityPrm._purchase_nm))
                    {
                        errMessage += "仕入先が適切に入力(選択)されていません。" + Environment.NewLine;
                        if (errCtl == null)
                        {
                            errCtl = this.utlPurchase.txtID;
                        }
                    }

                    #endregion

                    #region 日付チェック

                    // 支払締日
                    if (string.IsNullOrEmpty(_entityPrm._payment_yyyymmdd) == false)
                    {
                        if (ExCast.IsDate(_entityPrm._payment_yyyymmdd) == false)
                        {
                            errMessage += "支払締日の形式が不正です。(yyyy/mm/dd形式で入力(選択)して下さい)" + Environment.NewLine;
                            if (errCtl == null)
                            {
                                errCtl = this.datPaymentYmd;
                            }
                        }
                    }

                    // 支払予定日
                    if (string.IsNullOrEmpty(_entityPrm._payment_plan_yyyymmdd) == false)
                    {
                        if (ExCast.IsDate(_entityPrm._payment_plan_yyyymmdd) == false)
                        {
                            errMessage += "支払予定日の形式が不正です。(yyyy/mm/dd形式で入力(選択)して下さい)" + Environment.NewLine;
                            if (errCtl == null)
                            {
                                errCtl = this.datPaymentPlanDay;
                            }
                        }
                    }

                    #endregion

                    #region 日付変換

                    // 支払締日
                    if (string.IsNullOrEmpty(_entityPrm._payment_yyyymmdd) == false)
                    {
                        _entityPrm._payment_yyyymmdd = ExCast.zConvertToDate(_entityPrm._payment_yyyymmdd).ToString("yyyy/MM/dd");
                    }

                    // 支払予定日
                    if (string.IsNullOrEmpty(_entityPrm._payment_plan_yyyymmdd) == false)
                    {
                        _entityPrm._payment_plan_yyyymmdd = ExCast.zConvertToDate(_entityPrm._payment_plan_yyyymmdd).ToString("yyyy/MM/dd");
                    }

                    #endregion

                    #region 正数チェック

                    //if (ExCast.zCLng(this.txtSummingUpDay.Text.Trim()) < 0)
                    //{
                    //    errMessage += "締日には正の整数を入力して下さい。" + Environment.NewLine;
                    //}

                    #endregion

                    #region 範囲チェック

                    //if (this.datPaymentYmd.SelectedDate != null && !string.IsNullOrEmpty(this.txtSummingUpDay.Text.Trim()))
                    //{
                    //    string _ym = this.datPaymentYmd.SelectedDate.ToString();
                    //    _ym = _ym.Substring(0, 7);
                    //    _ym = _ym.Replace("/", "");

                    //    string yyyymm = "";
                    //    string _now = DateTime.Now.ToString("yyyyMMdd");
                    //    int _now_day = ExCast.zCInt(_now.Substring(5, 2));

                    //    if (ExCast.zCInt(_ym) != 0)
                    //    {
                    //        string _invoice_yyyymm = _ym + ExCast.zCInt(this.txtSummingUpDay.Text.Trim()).ToString("00");
                    //        if (ExCast.zCInt(_now) < ExCast.zCInt(_invoice_yyyymm))
                    //        {
                    //            errMessage += "支払締日に明日以降は指定できません。" + Environment.NewLine;
                    //        }
                    //    }
                    //}


                    //if (!(ExCast.zCLng(this.txtSummingUpDay.Text.Trim()) <= 31 && ExCast.zCLng(this.txtSummingUpDay.Text.Trim()) >= 1))
                    //{
                    //    errMessage += "締日には1日から31日を入力して下さい。" + Environment.NewLine;
                    //}

                    #endregion

                    break;

                case eProccessKbn.Close:

                    #region データ存在チェック

                    if (this._entity == null)
                    {
                        errMessage += "締切対象データが存在しません。" + Environment.NewLine;
                        if (errCtl == null)
                        {
                            errCtl = this.utlSummingUp.txtID;
                        }
                    }

                    if (this._entity.Count == 0)
                    {
                        errMessage += "締切対象データが存在しません。" + Environment.NewLine;
                        if (errCtl == null)
                        {
                            errCtl = this.utlSummingUp.txtID;
                        }
                    }

                    _flg = false;
                    for (int i = 0; i <= _entity.Count - 1; i++)
                    {
                        if (_entity[i]._exec_flg == true)
                        {
                            _flg = true;
                        }
                    }
                    if (_flg == false)
                    {
                        errMessage += "締切対象データが選択されていません。" + Environment.NewLine;
                        if (errCtl == null)
                        {
                            errCtl = this.utlSummingUp.txtID;
                        }
                    }

                    #endregion

                    break;
                }

                #endregion

                #region エラー or 警告時処理

                bool flg = true;

                if (!string.IsNullOrEmpty(errMessage))
                {
                    ExMessageBox.Show(errMessage, Dlg.MessageBox.MessageBoxIcon.Error);
                    flg = false;
                }
                else
                {
                    //if (!string.IsNullOrEmpty(warnMessage))
                    //{
                    //    warnMessage += "このまま登録を続行してもよろしいですか?" + Environment.NewLine;
                    //    if (ExMessageBox.ResultShow(warnMessage) == MessageBoxResult.Cancel)
                    //    {
                    //        flg = false;
                    //    }
                    //}
                }

                this.txtDummy.IsTabStop = false;

                if (flg == false)
                {
                    if (errCtl != null)
                    {
                        switch (errCtl.Name)
                        {
                        case "dg":
                            errCtl.Focus();
                            this.dg.SelectedIndex = _selectIndex;
                            dg.CurrentColumn      = dg.Columns[_selectColumn];
                            break;

                        default:
                            ExBackgroundWorker.DoWork_Focus(errCtl, 10);
                            break;
                        }
                    }
                    return;
                }

                #endregion

                #region 各処理

                switch (this.proceeKbn)
                {
                case eProccessKbn.Total:
                    GetData();
                    break;

                case eProccessKbn.Close:
                    UpdateData(Common.geUpdateType.Insert);
                    break;

                case eProccessKbn.None:
                    break;
                }

                #endregion
            }
            finally
            {
                Common.gblnBtnProcLock          = false;
                Common.gblnBtnDesynchronizeLock = false;
            }
        }