// 入力チェック public override void InputCheckUpdate() { string errMessage = ""; Control errCtl = null; try { switch (this.ProcKbn) { case eProcKbn.Search: case eProcKbn.Report: #region 検索時チェック #region 必須チェック // 対象年月 if (string.IsNullOrEmpty(this.datYm.Text.Trim())) { errMessage += "対象年月を入力(選択)して下さい" + Environment.NewLine; if (errCtl == null) { errCtl = this.datYm; } } #endregion #region 入力チェック // 仕入先 if (this.utlPurchase_F.txtID.Text.Trim() != "" && string.IsNullOrEmpty(this.utlPurchase_F.txtNm.Text.Trim())) { errMessage += "仕入先が適切に入力(選択)されていません。" + Environment.NewLine; if (errCtl == null) { errCtl = this.utlPurchase_F.txtID; } } if (this.utlPurchase_T.txtID.Text.Trim() != "" && string.IsNullOrEmpty(this.utlPurchase_T.txtNm.Text.Trim())) { errMessage += "仕入先が適切に入力(選択)されていません。" + Environment.NewLine; if (errCtl == null) { errCtl = this.utlPurchase_T.txtID; } } #endregion #region 範囲チェック // 仕入先 if ((ExCast.IsNumeric(this.utlPurchase_F.txtID.Text.Trim()) && ExCast.IsNumeric(this.utlPurchase_T.txtID.Text.Trim())) && (!string.IsNullOrEmpty(this.utlPurchase_F.txtID.Text.Trim()) && !string.IsNullOrEmpty(this.utlPurchase_T.txtID.Text.Trim()))) { if (ExCast.zCLng(this.utlPurchase_F.txtID.Text.Trim()) > ExCast.zCLng(this.utlPurchase_T.txtID.Text.Trim())) { errMessage += "仕入先の範囲指定が不正です。" + Environment.NewLine; if (errCtl == null) { errCtl = this.utlPurchase_F.txtID; } } } #endregion #region 日付チェック // 対象年月 if (string.IsNullOrEmpty(this.datYm.Text.Trim()) == false) { if (ExCast.IsDateYm(this.datYm.Text.Trim()) == false) { errMessage += "対象年月の形式が不正です。(yyyy/mm形式で入力(選択)して下さい)" + Environment.NewLine; if (errCtl == null) { errCtl = this.datYm; } } } #endregion #endregion break; case eProcKbn.Update: #region 更新チェック #region 必須チェック //if (this.datIssueYmd.SelectedDate == null) //{ // errMessage += "出力発行日が入力されていません。" + Environment.NewLine; // if (errCtl == null) errCtl = this.datIssueYmd; //} #endregion #region 選択チェック if (this.entityList == null) { errMessage += "表示データがありません。" + Environment.NewLine; if (errCtl == null) { errCtl = this.datYm; } } if (this.entityList.Count == 0) { errMessage += "表示データがありません。" + Environment.NewLine; if (errCtl == null) { errCtl = this.datYm; } } 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.datYm; } } #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.utlReport.rptKbn == DataReport.geReportKbn.None) { GetListData(); } else { if (this.ProcKbn == eProcKbn.Update) { ExMessageBox.ResultShow(this, null, "処理対象となる仕入先のすべての請求データの残高が更新されます。" + Environment.NewLine + "このまま登録を続行してもよろしいですか?"); return; } this.utlReport.utlParentFKey = this.utlFKey; switch (Common.gWinGroupType) { case Common.geWinGroupType.InpListReport: this.utlReport.pgId = DataPgEvidence.PGName.PaymentManagement.PaymentBalancePrint; break; default: break; } this.utlReport.sqlWhere = GetSQLWhere(); this.utlReport.sqlOrderBy = GetSQLOrderBy(); this.utlReport.ReportStart(); } } finally { Common.gblnBtnProcLock = false; Common.gblnBtnDesynchronizeLock = false; } }
public EntityCopying CopyCheck(string random, string tblName, string Id) { EntityCopying entity; #region 認証処理 string companyId = ""; string groupId = ""; string userId = ""; string ipAdress = ""; string sessionString = ""; try { companyId = ExCast.zCStr(HttpContext.Current.Session[ExSession.COMPANY_ID]); groupId = ExCast.zCStr(HttpContext.Current.Session[ExSession.GROUP_ID]); userId = ExCast.zCStr(HttpContext.Current.Session[ExSession.USER_ID]); ipAdress = ExCast.zCStr(HttpContext.Current.Session[ExSession.IP_ADRESS]); sessionString = ExCast.zCStr(HttpContext.Current.Session[ExSession.SESSION_RANDOM_STR]); string _message = ExSession.SessionUserUniqueCheck(random, ExCast.zCStr(HttpContext.Current.Session[ExSession.SESSION_RANDOM_STR]), ExCast.zCInt(HttpContext.Current.Session[ExSession.USER_ID])); if (_message != "") { entity = new EntityCopying(); entity.MESSAGE = _message; return(entity); } } catch (Exception ex) { CommonUtl.ExLogger.Error(CLASS_NM + ".CopyCheck(認証処理)", ex); entity = new EntityCopying(); entity.MESSAGE = CLASS_NM + ".CopyCheck : 認証処理に失敗しました。" + Environment.NewLine + ex.Message.ToString();; return(entity); } #endregion #region Field ExMySQLData db = ExSession.GetSessionDb(ExCast.zCInt(userId), sessionString); DataPgLock.geLovkFlg lockFlg; entity = new EntityCopying(); entity.is_exists_data = false; entity.is_lock_success = false; entity.ret = false; string get_col1Value = ""; string get_col2Value = ""; string get_col3Value = ""; string get_col4Value = ""; string get_col5Value = ""; string lock_check_pg_id = ""; string lock_check_id = ""; #endregion try { // 複写時存在チェック switch (tblName) { #region マスタ系 case "SYS_M_COMPANY_GROUP": lock_check_id = Id; lock_check_pg_id = DataPgEvidence.PGName.Mst.CompanyGroup; entity.is_exists_data = DataExists.IsExistData(db, companyId, "", tblName, "ID", Id, CommonUtl.geStrOrNumKbn.String); break; case "M_CUSTOMER": lock_check_id = Id; lock_check_pg_id = DataPgEvidence.PGName.Mst.Customer; entity.is_exists_data = DataExists.IsExistData(db, companyId, "", tblName, "ID", Id, CommonUtl.geStrOrNumKbn.String); break; case "M_PERSON": lock_check_id = Id; lock_check_pg_id = DataPgEvidence.PGName.Mst.Person; entity.is_exists_data = DataExists.IsExistData(db, companyId, "", tblName, "ID", Id, CommonUtl.geStrOrNumKbn.Number); break; case "M_COMMODITY": lock_check_id = Id; lock_check_pg_id = DataPgEvidence.PGName.Mst.Commodity; entity.is_exists_data = DataExists.IsExistData(db, companyId, "", tblName, "ID", Id, CommonUtl.geStrOrNumKbn.String); break; #endregion #region 伝票入力系 #region 売上入力系 case "T_ESTIMATE_H": lock_check_id = groupId + "-" + Id; lock_check_pg_id = DataPgEvidence.PGName.Estimate.EstimateInp; entity.is_exists_data = DataExists.IsExistData(db, companyId, groupId, tblName, "NO", Id, CommonUtl.geStrOrNumKbn.Number); if (entity.is_exists_data) { // 受注計上済チェック if (DataExists.IsExistData(db, companyId, groupId, "T_ORDER_H", "ESTIMATENO", Id, CommonUtl.geStrOrNumKbn.Number)) { entity.MESSAGE = "複写先ID : " + Id + " は受注計上済の為、複写できません。"; return(entity); } // 売上計上済チェック if (DataExists.IsExistData(db, companyId, groupId, "T_SALES_H", "ESTIMATENO", Id, CommonUtl.geStrOrNumKbn.Number)) { entity.MESSAGE = "複写先ID : " + Id + " は売上計上済の為、複写できません。"; return(entity); } } break; case "T_ORDER_H": lock_check_id = groupId + "-" + Id; lock_check_pg_id = DataPgEvidence.PGName.Order.OrderInp; entity.is_exists_data = DataExists.IsExistData(db, companyId, groupId, tblName, "NO", Id, CommonUtl.geStrOrNumKbn.Number); if (entity.is_exists_data) { // 売上計上済チェック if (DataExists.IsExistData(db, companyId, groupId, "T_SALES_H", "ORDER_NO", Id, CommonUtl.geStrOrNumKbn.Number)) { entity.MESSAGE = "複写先ID : " + Id + " は売上計上済の為、複写できません。"; return(entity); } } break; case "T_SALES_H": lock_check_id = groupId + "-" + Id; lock_check_pg_id = DataPgEvidence.PGName.Sales.SalesInp; entity.is_exists_data = DataExists.IsExistData(db, companyId, groupId, tblName, "NO", Id, CommonUtl.geStrOrNumKbn.Number); if (entity.is_exists_data) { DataExists.GetData(db, companyId, groupId, tblName, "NO", Id, CommonUtl.geStrOrNumKbn.Number, "TBL.INVOICE_ID", "TBL.INVOICE_NO", "TBL.RECEIPT_NO", "TBL.BUSINESS_DIVISION_ID", "date_format(TBL.SALES_YMD , " + ExEscape.SQL_YMD + ") AS SALES_YMD", "INVOICE_ID", "INVOICE_NO", "RECEIPT_NO", "BUSINESS_DIVISION_ID", "SALES_YMD", ref get_col1Value, ref get_col2Value, ref get_col3Value, ref get_col4Value, ref get_col5Value ); // 掛売上 if (ExCast.zCInt(get_col4Value) == 1) { // 請求締切済チェック if (DataClose.IsInvoiceClose(companyId, db, ExCast.zNumZeroNothingFormat(get_col1Value), ExCast.zDateNullToDefault(get_col5Value))) { entity.is_lock_success = false; entity.ret = false; entity.MESSAGE = "複写先ID : " + Id + " は請求締切済の為、複写できません。"; return(entity); } } // 請求済チェック // 都度請求分も請求番号が設定されている為、不許可とする if (ExCast.zCLng(get_col2Value) != 0) { entity.MESSAGE = "複写先ID : " + Id + " は請求済の為、複写できません。"; return(entity); } // 入金済チェック if (ExCast.zCLng(get_col2Value) != 0) { if (DataExists.IsExistData(db, companyId, groupId, "T_RECEIPT_H", "INVOICE_NO", ExCast.zCLng(get_col2Value).ToString(), CommonUtl.geStrOrNumKbn.Number)) { entity.MESSAGE = "複写先ID : " + Id + " は入金計上済の為、複写できません。"; return(entity); } } } break; case "T_RECEIPT_H": lock_check_id = groupId + "-" + Id; lock_check_pg_id = DataPgEvidence.PGName.Receipt.ReceiptInp; entity.is_exists_data = DataExists.IsExistData(db, companyId, groupId, tblName, "NO", Id, CommonUtl.geStrOrNumKbn.Number); break; #endregion #region 在庫入力系 case "T_IN_OUT_DELIVERY_H": lock_check_id = groupId + "-" + Id; lock_check_pg_id = DataPgEvidence.PGName.InOutDeliver.InOutDeliverInp; entity.is_exists_data = DataExists.IsExistData(db, companyId, groupId, tblName, "NO", Id, CommonUtl.geStrOrNumKbn.Number); if (entity.is_exists_data) { // 売上計上分チェック if (DataExists.IsExistDataDouble(db, companyId, groupId, "T_IN_OUT_DELIVERY_H", "NO", Id, "IN_OUT_DELIVERY_PROC_KBN", "2", CommonUtl.geStrOrNumKbn.Number)) { entity.MESSAGE = "複写先ID : " + Id + " は売上計上分の為、複写できません。"; return(entity); } // 仕入計上分チェック if (DataExists.IsExistDataDouble(db, companyId, groupId, "T_IN_OUT_DELIVERY_H", "NO", Id, "IN_OUT_DELIVERY_PROC_KBN", "3", CommonUtl.geStrOrNumKbn.Number)) { entity.MESSAGE = "複写先ID : " + Id + " は仕入計上分の為、複写できません。"; return(entity); } } break; #endregion #endregion default: entity.is_exists_data = false; break; } // 排他制御 string strErr = DataPgLock.SetLockPg(companyId, userId, lock_check_pg_id, lock_check_id, ipAdress, db, out lockFlg); if (strErr != "") { entity.MESSAGE = CLASS_NM + ".CopyCheck : 排他制御(ロック情報取得)に失敗しました。" + Environment.NewLine + strErr; entity.is_lock_success = false; entity.ret = false; } else { if (lockFlg == DataPgLock.geLovkFlg.Lock) { entity.is_lock_success = false; entity.ret = false; entity.MESSAGE = "複写先ID : " + Id + " は他ユーザーにて現在更新中の為、複写できません。"; } else { entity.is_lock_success = true; entity.ret = true; } } } catch (Exception ex) { CommonUtl.ExLogger.Error(CLASS_NM + ".CopyCheck", ex); entity = new EntityCopying(); entity.MESSAGE = CLASS_NM + ".CopyCheck : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message.ToString();; } return(entity); }
// 条件句SQL設定 private string GetSQLWhere() { string strWhrer = ""; string strWhrerString1 = ""; string strWhrerString2 = ""; #region 対象年月 if (this.datYm.Text.Trim() != "") { //strWhrer += " AND T.INVOICE_YYYYMMDD = " + ExEscape.zRepStr(this.datYm.Text.Trim()) + Environment.NewLine; strWhrerString1 += "[対象年月 " + this.datYm.Text.Trim(); } else { strWhrerString1 += "[対象年月 未指定"; } #endregion #region 商品 if (this.utlCommodity_F.txtID.Text.Trim() != "") { strWhrer += " AND T.ID >= " + ExCast.zCLng(this.utlCommodity_F.txtID.Text.Trim()) + Environment.NewLine; strWhrerString1 += "] [商品 " + this.utlCommodity_F.txtID.Text.Trim() + "~"; } else { strWhrerString1 += "] [商品 未指定~"; } if (this.utlCommodity_T.txtID.Text.Trim() != "") { strWhrer += " AND T.ID <= " + ExCast.zCLng(this.utlCommodity_T.txtID.Text.Trim()) + Environment.NewLine; strWhrerString1 += this.utlCommodity_T.txtID.Text.Trim(); } else { strWhrerString1 += "商品"; } #endregion #region 商品在庫 string _buf = ""; if (this.chkSalesCredit0_Yes.IsChecked == true) { strWhrer += " AND (IFNULL(BEFORE_IN.SUM_NUMBER, 0) - IFNULL(BEFORE_OUT.SUM_NUMBER, 0) + IFNULL(THIS_PURCHASE_IN.SUM_NUMBER, 0) - IFNULL(THIS_SALES_OUT.SUM_NUMBER, 0) + IFNULL(THIS_ANOTHER_IN.SUM_NUMBER, 0) - IFNULL(THIS_ANOTHER_OUT.SUM_NUMBER, 0)) = 0"; _buf += "] [商品在庫 在庫数0"; } if (this.chkSalesCredit0_No.IsChecked == true) { strWhrer += " AND (IFNULL(BEFORE_IN.SUM_NUMBER, 0) - IFNULL(BEFORE_OUT.SUM_NUMBER, 0) + IFNULL(THIS_PURCHASE_IN.SUM_NUMBER, 0) - IFNULL(THIS_SALES_OUT.SUM_NUMBER, 0) + IFNULL(THIS_ANOTHER_IN.SUM_NUMBER, 0) - IFNULL(THIS_ANOTHER_OUT.SUM_NUMBER, 0)) <> 0"; if (_buf == "") { _buf += "] [商品在庫 在庫数0以外"; } else { _buf += " 在庫数0以外"; } } if (_buf == "") { _buf += "] [商品在庫 指定無し]"; } else { _buf += "]"; } strWhrerString1 += _buf; _buf = ""; #endregion #region 期間内取引 if (this.chkBussinesNo.IsChecked == true) { strWhrer += " AND (IFNULL(THIS_PURCHASE_IN.COMPANY_ID, 'No') = 'No' AND IFNULL(THIS_SALES_OUT.COMPANY_ID, 'No') = 'No' AND IFNULL(THIS_ANOTHER_IN.COMPANY_ID, 'No') = 'No' AND IFNULL(THIS_ANOTHER_OUT.COMPANY_ID, 'No') = 'No') "; _buf += " [期間内取引 無し"; } if (this.chkBussinesYes.IsChecked == true) { strWhrer += " AND (IFNULL(THIS_PURCHASE_IN.COMPANY_ID, 'No') <> 'No' OR IFNULL(THIS_SALES_OUT.COMPANY_ID, 'No') <> 'No' OR IFNULL(THIS_ANOTHER_IN.COMPANY_ID, 'No') <> 'No' OR IFNULL(THIS_ANOTHER_OUT.COMPANY_ID, 'No') <> 'No') "; if (_buf == "") { _buf += " [期間内取引 有り"; } else { _buf += " 有り"; } } if (_buf == "") { _buf += " [期間内取引 指定無し]"; } else { _buf += "]"; } strWhrerString1 += _buf; #endregion _buf = ""; if (Common.gWinGroupType == Common.geWinGroupType.InpListReport) { if (datYm.SelectedDate != null) { strWhrer += "<proc ym>" + ((DateTime)this.datYm.SelectedDate).ToString("yyyy/MM"); } strWhrer += "<print kbn>1"; } strWhrer = strWhrer.Replace(",", "<<@escape_comma@>>"); strWhrer = strWhrer.Replace("'", "<<@escape_single_quotation@>>"); return(strWhrer + "WhereString =>" + strWhrerString1 + ";" + strWhrerString2); }
/// <summary> /// 最大ID取得 /// </summary> /// <param name="companyId">会社ID</param> /// <param name="groupId">グループID</param> /// <param name="db"></param> /// <param name="kbn">伝票区分</param> /// <param name="accountPeriod">会計年</param> /// <param name="no">伝票番号</param> /// <param name="id">伝票ID</param> /// <param name="ipAdress"></param> /// <param name="userId"></param> public static void GetMaxMasterId(string companyId, string groupId, ExMySQLData db, geMasterMaxIdKbn kbn, out string id) { StringBuilder sb; DataTable dt; bool exist = false; try { sb = new StringBuilder(); sb.Length = 0; // 存在確認 sb.Append("SELECT MT.ID AS MAX_ID " + Environment.NewLine); switch (kbn) { case geMasterMaxIdKbn.CompanyGroup: sb.Append(" FROM SYS_M_COMPANY_GROUP AS MT" + Environment.NewLine); break; case geMasterMaxIdKbn.Person: sb.Append(" FROM M_PERSON AS MT" + Environment.NewLine); break; case geMasterMaxIdKbn.Customer: sb.Append(" FROM M_CUSTOMER AS MT" + Environment.NewLine); break; case geMasterMaxIdKbn.Commodity: sb.Append(" FROM M_COMMODITY AS MT" + Environment.NewLine); break; case geMasterMaxIdKbn.Supplier: sb.Append(" FROM M_SUPPLIER AS MT" + Environment.NewLine); break; case geMasterMaxIdKbn.Purchase: sb.Append(" FROM M_PURCHASE AS MT" + Environment.NewLine); break; default: break; } sb.Append(" WHERE MT.DELETE_FLG = 0 " + Environment.NewLine); sb.Append(" AND MT.COMPANY_ID = " + companyId + Environment.NewLine); switch (kbn) { case geMasterMaxIdKbn.Supplier: sb.Append(" AND MT.CUSTOMER_ID = " + ExEscape.zRepStr(groupId) + Environment.NewLine); break; default: if (groupId != "") { sb.Append(" AND MT.GROUP_ID = " + groupId + Environment.NewLine); } break; } switch (kbn) { case geMasterMaxIdKbn.Customer: case geMasterMaxIdKbn.Commodity: case geMasterMaxIdKbn.Supplier: case geMasterMaxIdKbn.Purchase: sb.Append(" AND CAST(MT.ID AS SIGNED) > 0 " + Environment.NewLine); sb.Append(" ORDER BY CAST(MT.ID AS SIGNED) DESC " + Environment.NewLine); sb.Append(" LIMIT 0, 1 " + Environment.NewLine); break; default: sb.Append(" ORDER BY MT.ID DESC " + Environment.NewLine); sb.Append(" LIMIT 0, 1 " + Environment.NewLine); break; } dt = db.GetDataTable(sb.ToString()); if (dt.DefaultView.Count > 0) { id = (ExCast.zCLng(dt.DefaultView[0]["MAX_ID"]) + 1).ToString(); } else { id = "1"; } } catch (Exception ex) { CommonUtl.ExLogger.Error(CLASS_NM + ".GetMaxMasterId", ex); id = ""; throw; } }