Ejemplo n.º 1
0
        /// <summary>
        /// 支払締チェック
        /// </summary>
        /// <param name="companyId"></param>
        /// <param name="db"></param>
        /// <param name="customerId"></param>
        /// <param name="ipAdress"></param>
        /// <param name="userId"></param>
        public static bool IsPaymentClose(string companyId,
                                          ExMySQLData db,
                                          string purchaseId,
                                          string ymd)
        {
            StringBuilder sb = new StringBuilder();
            DataTable     dt;

            if (ymd.Length != 10)
            {
                throw new Exception();
            }
            if (!ExCast.IsDate(ymd))
            {
                throw new Exception();
            }

            try
            {
                sb.Length = 0;
                sb.Append("SELECT T.NO " + Environment.NewLine);
                sb.Append("  FROM T_PAYMENT AS T" + Environment.NewLine);
                sb.Append(" WHERE T.COMPANY_ID = " + companyId + Environment.NewLine);
                sb.Append("   AND T.DELETE_FLG = 0 " + Environment.NewLine);
                sb.Append("   AND T.PAYMENT_KBN = 0 " + Environment.NewLine);       // 支払区分:締処理
                sb.Append("   AND T.PAYMENT_YYYYMMDD >= " + ExEscape.zRepStr(ymd) + Environment.NewLine);
                if (purchaseId != "")
                {
                    sb.Append("   AND T.PURCHASE_ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(purchaseId)) + Environment.NewLine);
                }
                sb.Append(" LIMIT 0, 1");

                dt = db.GetDataTable(sb.ToString());
                if (dt.DefaultView.Count > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".IsPaymentClose", ex);
                throw;
            }
        }
        // 入力チェック
        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;
            }
        }
        // 入力チェック
        public override void InputCheckUpdate()
        {
            string  errMessage = "";
            Control errCtl     = null;

            try
            {
                switch (this.ProcKbn)
                {
                case eProcKbn.Search:
                case eProcKbn.Report:

                    #region 検索時チェック

                    #region 必須チェック

                    #endregion

                    #region 入力チェック

                    // 商品
                    if (this.utlCommodity_F.txtID.Text.Trim() != "" && string.IsNullOrEmpty(this.utlCommodity_F.txtNm.Text.Trim()))
                    {
                        errMessage += "商品が適切に入力(選択)されていません。" + Environment.NewLine;
                        if (errCtl == null)
                        {
                            errCtl = this.utlCommodity_F.txtID;
                        }
                    }
                    if (this.utlCommodity_T.txtID.Text.Trim() != "" && string.IsNullOrEmpty(this.utlCommodity_T.txtNm.Text.Trim()))
                    {
                        errMessage += "商品が適切に入力(選択)されていません。" + Environment.NewLine;
                        if (errCtl == null)
                        {
                            errCtl = this.utlCommodity_T.txtID;
                        }
                    }

                    #endregion

                    #region 範囲チェック

                    // 商品
                    if ((ExCast.IsNumeric(this.utlCommodity_F.txtID.Text.Trim()) && ExCast.IsNumeric(this.utlCommodity_T.txtID.Text.Trim())) &&
                        (!string.IsNullOrEmpty(this.utlCommodity_F.txtID.Text.Trim()) && !string.IsNullOrEmpty(this.utlCommodity_T.txtID.Text.Trim())))
                    {
                        if (ExCast.zCLng(this.utlCommodity_F.txtID.Text.Trim()) > ExCast.zCLng(this.utlCommodity_T.txtID.Text.Trim()))
                        {
                            errMessage += "商品の範囲指定が不正です。" + Environment.NewLine;
                            if (errCtl == null)
                            {
                                errCtl = this.utlCommodity_F.txtID;
                            }
                        }
                    }

                    #endregion

                    #region 日付チェック

                    #endregion

                    #endregion

                    break;

                case eProcKbn.Update:

                    #region 更新チェック

                    #region 必須チェック

                    //if (this.datIssueYmd.SelectedDate == null)
                    //{
                    //    errMessage += "出力発行日が入力されていません。" + Environment.NewLine;
                    //    if (errCtl == null) errCtl = this.datIssueYmd;
                    //}

                    // 棚卸日
                    if (string.IsNullOrEmpty(this.datYmd.Text.Trim()))
                    {
                        errMessage += "棚卸日を入力(選択)して下さい" + Environment.NewLine;
                        if (errCtl == null)
                        {
                            errCtl = this.datYmd;
                        }
                    }

                    #endregion

                    #region 日付チェック

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

                    #endregion

                    #region 選択チェック

                    if (this.entityList == null)
                    {
                        errMessage += "表示データがありません。" + Environment.NewLine;
                        if (errCtl == null)
                        {
                            errCtl = this.datYmd;
                        }
                    }
                    if (this.entityList.Count == 0)
                    {
                        errMessage += "表示データがありません。" + Environment.NewLine;
                        if (errCtl == null)
                        {
                            errCtl = this.datYmd;
                        }
                    }

                    bool _exec_flg = false;
                    for (int i = 0; i <= this.entityList.Count - 1; i++)
                    {
                        if (this.entityList[i]._exec_flg == true)
                        {
                            _exec_flg = true;
                        }
                    }
                    if (_exec_flg == false)
                    {
                        errMessage += "登録対象データを選択して下さい。" + Environment.NewLine;
                        if (errCtl == null)
                        {
                            errCtl = this.datYmd;
                        }
                    }

                    if (_exec_flg == true)
                    {
                        _exec_flg = false;
                        for (int i = 0; i <= this.entityList.Count - 1; i++)
                        {
                            if (this.entityList[i]._exec_flg == true && this.entityList[i]._diff_number != 0)
                            {
                                _exec_flg = true;
                            }
                        }
                        if (_exec_flg == false)
                        {
                            errMessage += "差異0以外のデータがありません。" + Environment.NewLine;
                            if (errCtl == null)
                            {
                                errCtl = this.datYmd;
                            }
                        }
                    }

                    #endregion

                    #endregion

                    break;
                }

                #region エラー or 警告時処理

                bool flg = true;

                if (!string.IsNullOrEmpty(errMessage))
                {
                    ExMessageBox.Show(errMessage, Dlg.MessageBox.MessageBoxIcon.Error);
                    flg = false;
                }
                this.txtDummy.IsTabStop = false;

                if (flg == false)
                {
                    if (errCtl != null)
                    {
                        ExBackgroundWorker.DoWork_Focus(errCtl, 10);
                    }
                    return;
                }

                #endregion

                if (this.ProcKbn == eProcKbn.Search)
                {
                    GetListData();
                }
                else
                {
                    if (this.ProcKbn == eProcKbn.Update)
                    {
                        //ExMessageBox.ResultShow(this, null, "処理対象となる仕入先のすべての請求データの残高が更新されます。" + Environment.NewLine + "このまま登録を続行してもよろしいですか?");

                        #region 更新処理

                        UpdateData(Common.geUpdateType.Update);

                        #endregion

                        return;
                    }

                    this.utlReport.utlParentFKey = this.utlFKey;

                    //switch (Common.gWinGroupType)
                    //{
                    //    case Common.geWinGroupType.InpListReport:
                    //        this.utlReport.pgId = DataPgEvidence.PGName.SalesManagement.InvoiceBalancePrint;
                    //        break;
                    //    default:
                    //        break;
                    //}

                    //this.utlReport.sqlWhere = GetSQLWhere();
                    //this.utlReport.sqlOrderBy = GetSQLOrderBy();
                    //this.utlReport.ReportStart();
                }
            }
            finally
            {
                Common.gblnBtnProcLock          = false;
                Common.gblnBtnDesynchronizeLock = false;
            }
        }