public string UpdateCondition(string random, List <EntityCondition> entity) { #region 認証処理 string companyId = ""; string groupId = ""; string userId = ""; string ipAdress = ""; string sessionString = ""; string personId = ""; 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]); personId = ExCast.zCStr(HttpContext.Current.Session[ExSession.PERSON_ID]); string _message = ExSession.SessionUserUniqueCheck(random, ExCast.zCStr(HttpContext.Current.Session[ExSession.SESSION_RANDOM_STR]), ExCast.zCInt(HttpContext.Current.Session[ExSession.USER_ID])); if (_message != "") { return(_message); } } catch (Exception ex) { CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateCondition(認証処理)", ex); return(CLASS_NM + ".UpdateCondition : 認証処理に失敗しました。" + Environment.NewLine + ex.Message.ToString()); } #endregion #region Field StringBuilder sb = new StringBuilder(); DataTable dt; ExMySQLData db = null; string _Id = ""; #endregion #region Databese Open try { db = new ExMySQLData(ExCast.zCStr(HttpContext.Current.Session[ExSession.DB_CONNECTION_STR])); db.DbOpen(); } catch (Exception ex) { CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateCondition(DbOpen)", ex); return(CLASS_NM + ".UpdateCondition(DbOpen) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message); } #endregion #region BeginTransaction try { db.ExBeginTransaction(); } catch (Exception ex) { CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateCondition(BeginTransaction)", ex); return(CLASS_NM + ".UpdateCondition(BeginTransaction) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message); } #endregion #region Delete try { #region データ存在チェック sb = new StringBuilder(); #region SQL sb.Length = 0; sb.Append("SELECT MT.* " + Environment.NewLine); sb.Append(" FROM M_CONDITION AS MT" + Environment.NewLine); sb.Append(" WHERE MT.COMPANY_ID = " + companyId + Environment.NewLine); sb.Append(" AND MT.CONDITION_DIVISION_ID = 1 " + Environment.NewLine); sb.Append(" AND MT.DELETE_FLG = 0 " + Environment.NewLine); #endregion db = ExSession.GetSessionDb(ExCast.zCInt(HttpContext.Current.Session[ExSession.USER_ID]), ExCast.zCStr(HttpContext.Current.Session[ExSession.SESSION_RANDOM_STR])); dt = db.GetDataTable(sb.ToString()); string ret_msg = ""; if (dt.DefaultView.Count > 0) { for (int i = 0; i <= dt.DefaultView.Count - 1; i++) { long lngId = ExCast.zCLng(dt.DefaultView[i]["ID"]); bool exists_flg = false; for (int i_ = 0; i_ <= entity.Count - 1; i_++) { if (ExCast.zCLng(entity[i_].id) == lngId) { exists_flg = true; } } string strId = string.Format("{0:00}", ExCast.zCDbl(lngId)); if (exists_flg == false) { bool _ret = false; switch (strId) { case "05": ret_msg += "締区分ID : " + strId + " は削除できません。" + Environment.NewLine; break; case "10": ret_msg += "締区分ID : " + strId + " は削除できません。" + Environment.NewLine; break; case "15": ret_msg += "締区分ID : " + strId + " は削除できません。" + Environment.NewLine; break; case "25": ret_msg += "締区分ID : " + strId + " は削除できません。" + Environment.NewLine; break; case "31": ret_msg += "締区分ID : " + strId + " は削除できません。" + Environment.NewLine; break; default: _ret = DataExists.IsExistData(db, companyId, "", "M_CUSTOMER", "SUMMING_UP_GROUP_ID", strId, CommonUtl.geStrOrNumKbn.String); if (_ret == true) { ret_msg += "締区分ID : " + strId + " は得意先マスタで使用されている為、削除できません。" + Environment.NewLine; } break; } } } if (!string.IsNullOrEmpty(ret_msg)) { return(ret_msg); } } #endregion #region Delete SQL sb.Length = 0; sb.Append("DELETE FROM M_CONDITION " + Environment.NewLine); sb.Append(" WHERE COMPANY_ID = " + companyId + Environment.NewLine); #endregion db.ExecuteSQL(sb.ToString(), false); } catch (Exception ex) { db.ExRollbackTransaction(); CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateCondition(Delete)", ex); return(CLASS_NM + ".UpdateCondition(Delete) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message); } #endregion #region Insert try { for (int i = 0; i <= entity.Count - 1; i++) { // 空行は無視する if (!string.IsNullOrEmpty(entity[i].id)) { #region Insert SQL sb.Length = 0; sb.Append("INSERT INTO M_CONDITION " + Environment.NewLine); sb.Append(" ( COMPANY_ID" + Environment.NewLine); sb.Append(" , CONDITION_DIVISION_ID" + Environment.NewLine); sb.Append(" , ID" + Environment.NewLine); sb.Append(" , NAME" + Environment.NewLine); sb.Append(" , MEMO" + Environment.NewLine); sb.Append(" , DISPLAY_FLG" + Environment.NewLine); sb.Append(" , UPDATE_FLG" + Environment.NewLine); sb.Append(" , DELETE_FLG" + Environment.NewLine); sb.Append(" , CREATE_PG_ID" + Environment.NewLine); sb.Append(" , CREATE_ADRESS" + Environment.NewLine); sb.Append(" , CREATE_USER_ID" + Environment.NewLine); sb.Append(" , CREATE_PERSON_ID" + Environment.NewLine); sb.Append(" , CREATE_DATE" + Environment.NewLine); sb.Append(" , CREATE_TIME" + Environment.NewLine); sb.Append(" , UPDATE_PG_ID" + Environment.NewLine); sb.Append(" , UPDATE_ADRESS" + Environment.NewLine); sb.Append(" , UPDATE_USER_ID" + Environment.NewLine); sb.Append(" , UPDATE_PERSON_ID" + Environment.NewLine); sb.Append(" , UPDATE_DATE" + Environment.NewLine); sb.Append(" , UPDATE_TIME" + Environment.NewLine); sb.Append(")" + Environment.NewLine); sb.Append("SELECT " + companyId + Environment.NewLine); // COMPANY_ID sb.Append(" ,1" + Environment.NewLine); // CONDITION_DIVISION_ID sb.Append(" ," + ExEscape.zRepStr(ExCast.zNumZeroFormat("{0:00}", entity[i].id)) + Environment.NewLine); // ID sb.Append(" ," + ExEscape.zRepStr(entity[i].name) + Environment.NewLine); // NAME sb.Append(" ," + ExEscape.zRepStr(entity[i].memo) + Environment.NewLine); // MEMO sb.Append(" ," + entity[i].display_division_id + Environment.NewLine); // DISPLAY_FLG sb.Append(CommonUtl.GetInsSQLCommonColums(CommonUtl.UpdKbn.Ins, PG_NM, "M_Condition", ExCast.zCInt(personId), _Id, ipAdress, userId)); #endregion db.ExecuteSQL(sb.ToString(), false); } } } catch (Exception ex) { db.ExRollbackTransaction(); CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateCondition(Insert)", ex); return(CLASS_NM + ".UpdateCondition(Insert) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message); } #endregion #region CommitTransaction try { db.ExCommitTransaction(); } catch (Exception ex) { CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateCondition(CommitTransaction)", ex); return(CLASS_NM + ".UpdateCondition(CommitTransaction) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message); } #endregion #region Database Close try { db.DbClose(); } catch (Exception ex) { db.ExRollbackTransaction(); CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateCondition(DbClose)", ex); return(CLASS_NM + ".UpdateCondition(DbClose) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message); } finally { db = null; } #endregion #region Add Evidence try { svcPgEvidence.gAddEvidence(ExCast.zCInt(HttpContext.Current.Session[ExSession.EVIDENCE_SAVE_FLG]), companyId, userId, ipAdress, sessionString, PG_NM, DataPgEvidence.geOperationType.DeleteAndInsert, ""); } catch (Exception ex) { CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateCondition(Add Evidence)", ex); return(CLASS_NM + ".UpdateCondition(Add Evidence) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message); } #endregion return(""); }
public string UpdateSalesCreditBalance(string random, int type, List <EntitySalesCreditBalance> entity) { #region 認証処理 string companyId = ""; string groupId = ""; string userId = ""; string ipAdress = ""; string sessionString = ""; string personId = ""; 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]); personId = ExCast.zCStr(HttpContext.Current.Session[ExSession.PERSON_ID]); string _message = ExSession.SessionUserUniqueCheck(random, ExCast.zCStr(HttpContext.Current.Session[ExSession.SESSION_RANDOM_STR]), ExCast.zCInt(HttpContext.Current.Session[ExSession.USER_ID])); if (_message != "") { return(_message); } } catch (Exception ex) { CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateSalesCreditBalance(認証処理)", ex); return(CLASS_NM + ".UpdateSalesCreditBalance : 認証処理に失敗しました。" + Environment.NewLine + ex.Message.ToString()); } #endregion #region Field StringBuilder sb = new StringBuilder(); DataTable dt; ExMySQLData db = null; string _Id = ""; int _classKbn = 0; #endregion #region Databese Open try { db = new ExMySQLData(ExCast.zCStr(HttpContext.Current.Session[ExSession.DB_CONNECTION_STR])); db.DbOpen(); } catch (Exception ex) { CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateSalesCreditBalance(DbOpen)", ex); return(CLASS_NM + ".UpdateSalesCreditBalance(DbOpen) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message); } #endregion #region BeginTransaction try { db.ExBeginTransaction(); } catch (Exception ex) { CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateSalesCreditBalance(BeginTransaction)", ex); return(CLASS_NM + ".UpdateSalesCreditBalance(BeginTransaction) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message); } #endregion #region Update if (type == 0) { try { for (int i = 0; i <= entity.Count - 1; i++) { if (entity[i].exec_flg == true) { double upd_balance = entity[i].before_sales_credit_balacne_upd - entity[i].before_sales_credit_balacne; #region Update Sales Credit Balance try { sb.Length = 0; sb.Append("UPDATE M_SALES_CREDIT_BALANCE " + Environment.NewLine); sb.Append(CommonUtl.GetUpdSQLCommonColums(PG_NM, ExCast.zCInt(personId), ipAdress, userId, 0)); sb.Append(" ,SALES_CREDIT_INIT_PRICE = SALES_CREDIT_INIT_PRICE + " + upd_balance + Environment.NewLine); sb.Append(" ,SALES_CREDIT_PRICE = SALES_CREDIT_PRICE + " + upd_balance + Environment.NewLine); sb.Append(" WHERE DELETE_FLG = 0 " + Environment.NewLine); sb.Append(" AND COMPANY_ID = " + companyId + Environment.NewLine); sb.Append(" AND GROUP_ID = " + groupId + Environment.NewLine); sb.Append(" AND ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(entity[i].invoice_id)) + Environment.NewLine); db.ExecuteSQL(sb.ToString(), false); } catch (Exception ex) { db.ExRollbackTransaction(); CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateSalesCreditBalance(Update Sales Credit Balance)", ex); return(CLASS_NM + ".UpdateSalesCreditBalance(Update Sales Credit Balance) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message); } #endregion #region Update Sales Credit Balance (Costumer) try { sb.Length = 0; sb.Append("UPDATE M_CUSTOMER " + Environment.NewLine); sb.Append(CommonUtl.GetUpdSQLCommonColums(PG_NM, ExCast.zCInt(personId), ipAdress, userId, 0)); sb.Append(" ,SALES_CREDIT_PRICE = SALES_CREDIT_PRICE + " + upd_balance + Environment.NewLine); sb.Append(" WHERE DELETE_FLG = 0 " + Environment.NewLine); sb.Append(" AND COMPANY_ID = " + companyId + Environment.NewLine); sb.Append(" AND ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(entity[i].invoice_id)) + Environment.NewLine); db.ExecuteSQL(sb.ToString(), false); } catch (Exception ex) { db.ExRollbackTransaction(); CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateSalesCreditBalance(Update Sales Credit Balance (Costumer))", ex); return(CLASS_NM + ".UpdateSalesCreditBalance(Update Sales Credit Balance (Costumer)) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message); } #endregion } } } catch (Exception ex) { db.ExRollbackTransaction(); CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateSalesCreditBalance(Insert)", ex); return(CLASS_NM + ".UpdateSalesCreditBalance(Insert) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message); } } #endregion #region PG排他制御 //try //{ // DataPgLock.DelLockPg(companyId, userId, PG_NM, "", ipAdress, false, db); //} //catch (Exception ex) //{ // db.ExRollbackTransaction(); // CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateSalesCreditBalance(DelLockPg)", ex); // return CLASS_NM + ".UpdateSalesCreditBalance(DelLockPg) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message; //} #endregion #region CommitTransaction try { db.ExCommitTransaction(); } catch (Exception ex) { CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateSalesCreditBalance(CommitTransaction)", ex); return(CLASS_NM + ".UpdateSalesCreditBalance(CommitTransaction) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message); } #endregion #region Database Close try { db.DbClose(); } catch (Exception ex) { db.ExRollbackTransaction(); CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateSalesCreditBalance(DbClose)", ex); return(CLASS_NM + ".UpdateSalesCreditBalance(DbClose) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message); } finally { db = null; } #endregion #region Add Evidence try { svcPgEvidence.gAddEvidence(ExCast.zCInt(HttpContext.Current.Session[ExSession.EVIDENCE_SAVE_FLG]), companyId, userId, ipAdress, sessionString, PG_NM, DataPgEvidence.geOperationType.DeleteAndInsert, ""); } catch (Exception ex) { CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateSalesCreditBalance(Add Evidence)", ex); return(CLASS_NM + ".UpdateSalesCreditBalance(Add Evidence) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message); } #endregion return(""); }
public string UpdateReportSetting(string random, int type, string Id, EntityReportSetting entity) { #region 認証処理 string companyId = ""; string groupId = ""; string userId = ""; string ipAdress = ""; string sessionString = ""; string personId = ""; 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]); personId = ExCast.zCStr(HttpContext.Current.Session[ExSession.PERSON_ID]); string _message = ExSession.SessionUserUniqueCheck(random, ExCast.zCStr(HttpContext.Current.Session[ExSession.SESSION_RANDOM_STR]), ExCast.zCInt(HttpContext.Current.Session[ExSession.USER_ID])); if (_message != "") { return(_message); } } catch (Exception ex) { CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateReportSetting(認証処理)", ex); return(CLASS_NM + ".UpdateReportSetting : 認証処理に失敗しました。" + Environment.NewLine + ex.Message.ToString()); } #endregion #region Field StringBuilder sb = new StringBuilder(); DataTable dt; ExMySQLData db = null; string _Id = Id; #endregion #region Databese Open try { db = new ExMySQLData(ExCast.zCStr(HttpContext.Current.Session[ExSession.DB_CONNECTION_STR])); db.DbOpen(); } catch (Exception ex) { CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateReportSetting(DbOpen)", ex); return(CLASS_NM + ".UpdateReportSetting(DbOpen) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message); } #endregion #region BeginTransaction try { db.ExBeginTransaction(); } catch (Exception ex) { CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateReportSetting(BeginTransaction)", ex); return(CLASS_NM + ".UpdateReportSetting(BeginTransaction) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message); } #endregion #region Insert if (type <= 1) { try { #region Delete SQL sb.Length = 0; sb.Append("DELETE FROM M_REPORT_SETTING " + Environment.NewLine); sb.Append(" WHERE USER_ID = " + userId + Environment.NewLine); sb.Append(" AND PG_ID = " + ExEscape.zRepStr(Id) + Environment.NewLine); #endregion db.ExecuteSQL(sb.ToString(), false); #region Insert SQL sb.Length = 0; sb.Append("INSERT INTO M_REPORT_SETTING " + Environment.NewLine); sb.Append(" ( USER_ID" + Environment.NewLine); sb.Append(" , PG_ID" + Environment.NewLine); sb.Append(" , SIZE" + Environment.NewLine); sb.Append(" , ORIENTATION" + Environment.NewLine); sb.Append(" , LEFT_MARGIN" + Environment.NewLine); sb.Append(" , RIGHT_MARGIN" + Environment.NewLine); sb.Append(" , TOP_MARGIN" + Environment.NewLine); sb.Append(" , BOTTOM_MARGIN" + Environment.NewLine); sb.Append(" , GROUP_ID_FROM" + Environment.NewLine); sb.Append(" , GROUP_ID_TO" + Environment.NewLine); sb.Append(" , GROUP_TOTAL" + Environment.NewLine); sb.Append(" , TOTAL_KBN" + Environment.NewLine); sb.Append(" , UPDATE_FLG" + Environment.NewLine); sb.Append(" , DELETE_FLG" + Environment.NewLine); sb.Append(" , CREATE_PG_ID" + Environment.NewLine); sb.Append(" , CREATE_ADRESS" + Environment.NewLine); sb.Append(" , CREATE_USER_ID" + Environment.NewLine); sb.Append(" , CREATE_PERSON_ID" + Environment.NewLine); sb.Append(" , CREATE_DATE" + Environment.NewLine); sb.Append(" , CREATE_TIME" + Environment.NewLine); sb.Append(" , UPDATE_PG_ID" + Environment.NewLine); sb.Append(" , UPDATE_ADRESS" + Environment.NewLine); sb.Append(" , UPDATE_USER_ID" + Environment.NewLine); sb.Append(" , UPDATE_PERSON_ID" + Environment.NewLine); sb.Append(" , UPDATE_DATE" + Environment.NewLine); sb.Append(" , UPDATE_TIME" + Environment.NewLine); sb.Append(")" + Environment.NewLine); sb.Append("SELECT " + userId + Environment.NewLine); // USER_ID sb.Append(" ," + ExEscape.zRepStr(_Id) + Environment.NewLine); // PG_ID sb.Append(" ," + entity.size + Environment.NewLine); // SIZE sb.Append(" ," + entity.orientation + Environment.NewLine); // ORIENTATION sb.Append(" ," + entity.left_margin + Environment.NewLine); // LEFT_MARGIN sb.Append(" ," + entity.right_margin + Environment.NewLine); // RIGHT_MARGIN sb.Append(" ," + entity.top_margin + Environment.NewLine); // TOP_MARGIN sb.Append(" ," + entity.bottom_margin + Environment.NewLine); // BOTTOM_MARGIN sb.Append(" ," + entity.group_id_from + Environment.NewLine); // GROUP_ID_FROM sb.Append(" ," + entity.group_id_to + Environment.NewLine); // GROUP_ID_TO sb.Append(" ," + entity.group_total + Environment.NewLine); // GROUP_TOTAL sb.Append(" ," + entity.total_kbn + Environment.NewLine); // TOTAL_KBN sb.Append(CommonUtl.GetInsSQLCommonColums(CommonUtl.UpdKbn.Ins, PG_NM, "M_REPORT_SETTING", ExCast.zCInt(personId), _Id, ipAdress, userId)); #endregion db.ExecuteSQL(sb.ToString(), false); } catch (Exception ex) { db.ExRollbackTransaction(); CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateReportSetting(Insert)", ex); return(CLASS_NM + ".UpdateReportSetting(Insert) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message); } } #endregion #region Update if (type == 0) { //try //{ // #region SQL // string _invoice_id = entity.invoice_id; // if (ExCast.IsNumeric(_invoice_id)) _invoice_id = ExCast.zCDbl(_invoice_id).ToString(); // sb.Length = 0; // sb.Append("UPDATE M_REPORT_SETTING " + Environment.NewLine); // sb.Append(CommonUtl.GetUpdSQLCommonColums(PG_NM, // ExCast.zCInt(personId), // ipAdress, // userId, // 0)); // sb.Append(" ,NAME = " + ExEscape.zRepStr(entity.name) + Environment.NewLine); // sb.Append(" ,KANA = " + ExEscape.zRepStr(entity.kana) + Environment.NewLine); // sb.Append(" ,ABOUT_NAME = " + ExEscape.zRepStr(entity.about_name) + Environment.NewLine); // sb.Append(" ,ZIP_CODE = " + ExCast.zNullToZero(entity.zip_code_from + entity.zip_code_to) + Environment.NewLine); // sb.Append(" ,PREFECTURE_ID = " + entity.prefecture_id + Environment.NewLine); // sb.Append(" ,CITY_ID = " + entity.city_id + Environment.NewLine); // sb.Append(" ,TOWN_ID = " + entity.town_id + Environment.NewLine); // sb.Append(" ,ADRESS_CITY = " + ExEscape.zRepStr(entity.adress_city) + Environment.NewLine); // sb.Append(" ,ADRESS_TOWN = " + ExEscape.zRepStr(entity.adress_town) + Environment.NewLine); // sb.Append(" ,ADRESS1 = " + ExEscape.zRepStr(entity.adress1) + Environment.NewLine); // sb.Append(" ,ADRESS2 = " + ExEscape.zRepStr(entity.adress2) + Environment.NewLine); // sb.Append(" ,STATION_NAME = " + ExEscape.zRepStr(entity.station_name) + Environment.NewLine); // sb.Append(" ,POST_NAME = " + ExEscape.zRepStr(entity.post_name) + Environment.NewLine); // sb.Append(" ,PERSON_NAME = " + ExEscape.zRepStr(entity.person_name) + Environment.NewLine); // sb.Append(" ,TITLE_ID = " + entity.title_id + Environment.NewLine); // sb.Append(" ,TITLE_NAME = " + ExEscape.zRepStr(entity.title_name) + Environment.NewLine); // sb.Append(" ,TEL = " + ExEscape.zRepStr(entity.tel) + Environment.NewLine); // sb.Append(" ,FAX = " + ExEscape.zRepStr(entity.fax) + Environment.NewLine); // sb.Append(" ,MAIL_ADRESS = " + ExEscape.zRepStr(entity.mail_adress) + Environment.NewLine); // sb.Append(" ,MOBILE_TEL = " + ExEscape.zRepStr(entity.mobile_tel) + Environment.NewLine); // sb.Append(" ,MOBILE_ADRESS = " + ExEscape.zRepStr(entity.mobile_adress) + Environment.NewLine); // sb.Append(" ,URL = " + ExEscape.zRepStr(entity.url) + Environment.NewLine); // sb.Append(" ,INVOICE_ID = " + ExEscape.zRepStr(_invoice_id) + Environment.NewLine); // sb.Append(" ,BUSINESS_DIVISION_ID = " + entity.business_division_id + Environment.NewLine); // sb.Append(" ,UNIT_KIND_ID = " + entity.unit_kind_id + Environment.NewLine); // sb.Append(" ,CREDIT_RATE = " + entity.credit_rate + Environment.NewLine); // sb.Append(" ,TAX_CHANGE_ID = " + entity.tax_change_id + Environment.NewLine); // sb.Append(" ,SUMMING_UP_GROUP_ID = " + ExEscape.zRepStr(entity.summing_up_group_id) + Environment.NewLine); // sb.Append(" ,PRICE_FRACTION_PROC_ID = " + entity.price_fraction_proc_id + Environment.NewLine); // sb.Append(" ,TAX_FRACTION_PROC_ID = " + entity.tax_fraction_proc_id + Environment.NewLine); // sb.Append(" ,CREDIT_LIMIT_PRICE = " + entity.credit_limit_price + Environment.NewLine); // sb.Append(" ,SALES_CREDIT_PRICE = " + entity.sales_credit_price + Environment.NewLine); // sb.Append(" ,RECEIPT_DIVISION_ID = " + ExEscape.zRepStr(entity.receipt_division_id) + Environment.NewLine); // sb.Append(" ,COLLECT_CYCLE_ID = " + entity.collect_cycle_id + Environment.NewLine); // sb.Append(" ,COLLECT_DAY = " + entity.collect_day + Environment.NewLine); // sb.Append(" ,BILL_SITE = " + entity.bill_site + Environment.NewLine); // sb.Append(" ,GROUP1_ID = " + ExEscape.zRepStr(entity.group1_id) + Environment.NewLine); // sb.Append(" ,GROUP2_ID = " + ExEscape.zRepStr(entity.group2_id) + Environment.NewLine); // sb.Append(" ,GROUP3_ID = " + ExEscape.zRepStr(entity.group3_id) + Environment.NewLine); // sb.Append(" ,MEMO = " + ExEscape.zRepStr(entity.memo) + Environment.NewLine); // sb.Append(" ,DISPLAY_FLG = " + entity.display_division_id + Environment.NewLine); // sb.Append(" WHERE COMPANY_ID = " + companyId + Environment.NewLine); // COMPANY_ID // sb.Append(" AND ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(Id)) + Environment.NewLine); // ID // #endregion // db.ExecuteSQL(sb.ToString(), false); //} //catch (Exception ex) //{ // db.ExRollbackTransaction(); // CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateReportSetting(Update)", ex); // return CLASS_NM + ".UpdateReportSetting(Insert) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message; //} } #endregion #region Delete //if (type == 2) //{ // #region Exist Data // try // { // bool _ret = false; // _ret = DataExists.IsExistData(db, companyId, "", "M_REPORT_SETTING", "INVOICE_ID", ExCast.zNumZeroNothingFormat(Id), "ID", ExCast.zNumZeroNothingFormat(Id), CommonUtl.geStrOrNumKbn.String); // if (_ret == true) // { // return "得意先ID : " + Id + " は得意先マスタの請求IDにが使用されている為、削除できません。"; // } // _ret = DataExists.IsExistData(db, companyId, "", "T_ORDER_H", "ReportSetting_ID", ExCast.zNumZeroNothingFormat(Id), CommonUtl.geStrOrNumKbn.String); // if (_ret == true) // { // return "得意先ID : " + Id + " は受注データの得意先に使用されている為、削除できません。"; // } // } // catch (Exception ex) // { // db.ExRollbackTransaction(); // CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateReportSetting(Exist Data)", ex); // return CLASS_NM + ".UpdateReportSetting(Exist Data) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message; // } // #endregion // #region Update // try // { // sb.Length = 0; // sb.Append("UPDATE M_REPORT_SETTING " + Environment.NewLine); // sb.Append(CommonUtl.GetUpdSQLCommonColums(PG_NM, // ExCast.zCInt(personId), // ipAdress, // userId, // 1)); // sb.Append(" WHERE COMPANY_ID = " + companyId + Environment.NewLine); // COMPANY_ID // sb.Append(" AND ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(Id)) + Environment.NewLine); // ID // db.ExecuteSQL(sb.ToString(), false); // } // catch (Exception ex) // { // db.ExRollbackTransaction(); // CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateReportSetting(Delete)", ex); // return CLASS_NM + ".UpdateReportSetting(Delete) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message; // } // #endregion //} #endregion #region PG排他制御 //if (type == 0 || type == 2) //{ // try // { // DataPgLock.DelLockPg(companyId, userId, PG_NM, "", ipAdress, false, db); // } // catch (Exception ex) // { // db.ExRollbackTransaction(); // CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateReportSetting(DelLockPg)", ex); // return CLASS_NM + ".UpdateReportSetting(DelLockPg) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message; // } //} #endregion #region CommitTransaction try { db.ExCommitTransaction(); } catch (Exception ex) { CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateReportSetting(CommitTransaction)", ex); return(CLASS_NM + ".UpdateReportSetting(CommitTransaction) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message); } #endregion #region Database Close try { db.DbClose(); } catch (Exception ex) { db.ExRollbackTransaction(); CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateReportSetting(DbClose)", ex); return(CLASS_NM + ".UpdateReportSetting(DbClose) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message); } finally { db = null; } #endregion #region Add Evidence try { switch (type) { case 0: svcPgEvidence.gAddEvidence(ExCast.zCInt(HttpContext.Current.Session[ExSession.EVIDENCE_SAVE_FLG]), companyId, userId, ipAdress, sessionString, PG_NM, DataPgEvidence.geOperationType.Update, "ID:" + _Id.ToString()); break; case 1: svcPgEvidence.gAddEvidence(ExCast.zCInt(HttpContext.Current.Session[ExSession.EVIDENCE_SAVE_FLG]), companyId, userId, ipAdress, sessionString, PG_NM, DataPgEvidence.geOperationType.Insert, "ID:" + _Id.ToString()); break; case 2: svcPgEvidence.gAddEvidence(ExCast.zCInt(HttpContext.Current.Session[ExSession.EVIDENCE_SAVE_FLG]), companyId, userId, ipAdress, sessionString, PG_NM, DataPgEvidence.geOperationType.Delete, "ID:" + Id.ToString()); break; default: break; } } catch (Exception ex) { CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateReportSetting(Add Evidence)", ex); return(CLASS_NM + ".UpdateReportSetting(Add Evidence) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message); } #endregion #region Return return(""); //if (type == 1 && (Id == "0" || Id == "")) //{ // return "Auto Insert success : " + "ID : " + _Id.ToString() + "で登録しました。"; //} //else //{ // return ""; //} #endregion }
public string UpdateDuties(string random, int type, long no, EntityDuties entity) { #region 認証処理 string companyId = ""; string groupId = ""; string userId = ""; string ipAdress = ""; string sessionString = ""; string personId = ""; 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]); personId = ExCast.zCStr(HttpContext.Current.Session[ExSession.PERSON_ID]); string _message = ExSession.SessionUserUniqueCheck(random, ExCast.zCStr(HttpContext.Current.Session[ExSession.SESSION_RANDOM_STR]), ExCast.zCInt(HttpContext.Current.Session[ExSession.USER_ID])); if (_message != "") { return(_message); } } catch (Exception ex) { CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateDuties(認証処理)", ex); return(CLASS_NM + ".UpdateDuties : 認証処理に失敗しました。" + Environment.NewLine + ex.Message.ToString()); } #endregion #region Field StringBuilder sb = new StringBuilder(); DataTable dt; ExMySQLData db = null; string _no = ""; DateTime now = DateTime.Now; string date = now.ToString("yyyy/MM/dd"); string time = now.ToString("HH:mm:ss"); #endregion #region Databese Open try { db = new ExMySQLData(ExCast.zCStr(HttpContext.Current.Session[ExSession.DB_CONNECTION_STR])); db.DbOpen(); } catch (Exception ex) { CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateDuties(DbOpen)", ex); return(CLASS_NM + ".UpdateDuties(DbOpen) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message); } #endregion #region BeginTransaction try { db.ExBeginTransaction(); if (CommonUtl.gSysDbKbn == 0) { db.ExBeginTransaction(); } } catch (Exception ex) { CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateDuties(BeginTransaction)", ex); return(CLASS_NM + ".UpdateDuties(BeginTransaction) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message); } #endregion #region Get Max ID if (type == 1) { try { DataMaxId.GetMaxId(db, "T_DUTIES_COMMUNICATION", "NO", out _no); if (_no == "") { return("業務連絡NOの取得に失敗しました。"); } } catch (Exception ex) { db.ExRollbackTransaction(); CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateDuties(GetMaxId)", ex); return(CLASS_NM + ".UpdateDuties(GetMaxId) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message); } } else { _no = no.ToString(); } #endregion #region Upload File Set if (type <= 1) { if (!string.IsNullOrEmpty(entity.upload_file_path1)) { if (System.IO.Directory.Exists(CommonUtl.gstrFileUpLoadDutiesDir + entity.upload_file_path1) && !System.IO.Directory.Exists(CommonUtl.gstrFileUpLoadDutiesDir + _no + "-" + date.Replace("/", "") + time.Replace(":", ""))) { System.IO.Directory.Move(CommonUtl.gstrFileUpLoadDutiesDir + entity.upload_file_path1, CommonUtl.gstrFileUpLoadDutiesDir + _no + "-" + date.Replace("/", "") + time.Replace(":", "")); entity.upload_file_path1 = CommonUtl.gstrFileUpLoadDutiesDir + _no + "-" + date.Replace("/", "") + time.Replace(":", "") + "\\" + entity.upload_file_name1; } } } #endregion #region Insert if (type == 1) { try { #region Insert SQL sb.Length = 0; sb.Append("INSERT INTO T_DUTIES_COMMUNICATION " + Environment.NewLine); sb.Append(" ( COMPANY_ID" + Environment.NewLine); sb.Append(" , NO" + Environment.NewLine); sb.Append(" , GROUP_ID" + Environment.NewLine); sb.Append(" , DATE" + Environment.NewLine); sb.Append(" , TIME" + Environment.NewLine); sb.Append(" , PERSON_ID" + Environment.NewLine); sb.Append(" , DUTIES_LEVEL_ID" + Environment.NewLine); sb.Append(" , DUTIES_STATE_ID" + Environment.NewLine); sb.Append(" , TITLE" + Environment.NewLine); sb.Append(" , CONTENT" + Environment.NewLine); sb.Append(" , UPLOAD_FILE_PATH1" + Environment.NewLine); sb.Append(" , UPLOAD_FILE_PATH2" + Environment.NewLine); sb.Append(" , UPLOAD_FILE_PATH3" + Environment.NewLine); sb.Append(" , UPLOAD_FILE_PATH4" + Environment.NewLine); sb.Append(" , UPLOAD_FILE_PATH5" + Environment.NewLine); sb.Append(" , MEMO" + Environment.NewLine); sb.Append(" , UPDATE_FLG" + Environment.NewLine); sb.Append(" , DELETE_FLG" + Environment.NewLine); sb.Append(" , CREATE_PG_ID" + Environment.NewLine); sb.Append(" , CREATE_ADRESS" + Environment.NewLine); sb.Append(" , CREATE_USER_ID" + Environment.NewLine); sb.Append(" , CREATE_PERSON_ID" + Environment.NewLine); sb.Append(" , CREATE_DATE" + Environment.NewLine); sb.Append(" , CREATE_TIME" + Environment.NewLine); sb.Append(" , UPDATE_PG_ID" + Environment.NewLine); sb.Append(" , UPDATE_ADRESS" + Environment.NewLine); sb.Append(" , UPDATE_USER_ID" + Environment.NewLine); sb.Append(" , UPDATE_PERSON_ID" + Environment.NewLine); sb.Append(" , UPDATE_DATE" + Environment.NewLine); sb.Append(" , UPDATE_TIME" + Environment.NewLine); sb.Append(")" + Environment.NewLine); sb.Append("SELECT " + companyId + Environment.NewLine); // COMPANY_ID sb.Append(" ," + _no + Environment.NewLine); // NO sb.Append(" ," + entity.gropu_id + Environment.NewLine); // GROUP_ID sb.Append(" ," + ExEscape.zRepStr(date) + Environment.NewLine); // DATE sb.Append(" ," + ExEscape.zRepStr(time) + Environment.NewLine); // TIME sb.Append(" ," + entity.person_id + Environment.NewLine); // PERSON_ID sb.Append(" ," + entity.duties_level_id + Environment.NewLine); // DUTIES_LEVEL_ID sb.Append(" ," + entity.duties_state_id + Environment.NewLine); // DUTIES_STATE_ID sb.Append(" ," + ExEscape.zRepStr(entity.title) + Environment.NewLine); // TITLE sb.Append(" ," + ExEscape.zRepStr(entity.content) + Environment.NewLine); // CONTENT sb.Append(" ," + ExEscape.zRepStr(entity.upload_file_path1) + Environment.NewLine); // UPLOAD_FILE_PATH1 sb.Append(" ," + ExEscape.zRepStr(entity.upload_file_path2) + Environment.NewLine); // UPLOAD_FILE_PATH2 sb.Append(" ," + ExEscape.zRepStr(entity.upload_file_path3) + Environment.NewLine); // UPLOAD_FILE_PATH3 sb.Append(" ," + ExEscape.zRepStr(entity.upload_file_path4) + Environment.NewLine); // UPLOAD_FILE_PATH4 sb.Append(" ," + ExEscape.zRepStr(entity.upload_file_path5) + Environment.NewLine); // UPLOAD_FILE_PATH5 sb.Append(" ," + ExEscape.zRepStr(entity.memo) + Environment.NewLine); // MEMO sb.Append(CommonUtl.GetInsSQLCommonColums(CommonUtl.UpdKbn.Ins, PG_NM, "T_DUTIES_COMMUNICATION", ExCast.zCInt(personId), _no, ipAdress, userId)); #endregion db.ExecuteSQL(sb.ToString(), false); if (CommonUtl.gSysDbKbn == 0) { db.ExecuteSQL(sb.ToString(), false); } } catch (Exception ex) { db.ExRollbackTransaction(); CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateDuties(Insert)", ex); return(CLASS_NM + ".UpdateDuties(Insert) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message); } } #endregion #region Update if (type == 0) { #region Update try { #region SQL sb.Length = 0; sb.Append("UPDATE T_DUTIES_COMMUNICATION " + Environment.NewLine); sb.Append(CommonUtl.GetUpdSQLCommonColums(PG_NM, ExCast.zCInt(personId), ipAdress, userId, 0)); sb.Append(" ,GROUP_ID = " + entity.gropu_id + Environment.NewLine); sb.Append(" ,DATE = " + ExEscape.zRepStr(date) + Environment.NewLine); sb.Append(" ,TIME = " + ExEscape.zRepStr(time) + Environment.NewLine); sb.Append(" ,PERSON_ID = " + entity.person_id + Environment.NewLine); sb.Append(" ,DUTIES_LEVEL_ID = " + entity.duties_level_id + Environment.NewLine); sb.Append(" ,DUTIES_STATE_ID = " + entity.duties_state_id + Environment.NewLine); sb.Append(" ,TITLE = " + ExEscape.zRepStr(entity.title) + Environment.NewLine); sb.Append(" ,CONTENT = " + ExEscape.zRepStr(entity.content) + Environment.NewLine); sb.Append(" ,UPLOAD_FILE_PATH1 = " + ExEscape.zRepStr(entity.upload_file_path1) + Environment.NewLine); sb.Append(" ,UPLOAD_FILE_PATH2 = " + ExEscape.zRepStr(entity.upload_file_path2) + Environment.NewLine); sb.Append(" ,UPLOAD_FILE_PATH3 = " + ExEscape.zRepStr(entity.upload_file_path3) + Environment.NewLine); sb.Append(" ,UPLOAD_FILE_PATH4 = " + ExEscape.zRepStr(entity.upload_file_path4) + Environment.NewLine); sb.Append(" ,UPLOAD_FILE_PATH5 = " + ExEscape.zRepStr(entity.upload_file_path5) + Environment.NewLine); sb.Append(" ,MEMO = " + ExEscape.zRepStr(entity.memo) + Environment.NewLine); sb.Append(" WHERE NO = " + _no + Environment.NewLine); #endregion db.ExecuteSQL(sb.ToString(), false); if (CommonUtl.gSysDbKbn == 0) { db.ExecuteSQL(sb.ToString(), false); } } catch (Exception ex) { db.ExRollbackTransaction(); CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateDuties(Update Head)", ex); return(CLASS_NM + ".UpdateDuties(Update Head) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message); } #endregion } #endregion #region Delete if (type == 2) { } #endregion #region PG排他制御 if (type == 0 || type == 2) { try { DataPgLock.DelLockPg(companyId, userId, PG_NM, "", ipAdress, false, db); } catch (Exception ex) { db.ExRollbackTransaction(); CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateDuties(DelLockPg)", ex); return(CLASS_NM + ".UpdateDuties(DelLockPg) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message); } } #endregion #region CommitTransaction try { db.ExCommitTransaction(); } catch (Exception ex) { CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateDuties(CommitTransaction)", ex); return(CLASS_NM + ".UpdateDuties(CommitTransaction) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message); } #endregion #region Database Close try { db.DbClose(); } catch (Exception ex) { CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateDuties(DbClose)", ex); return(CLASS_NM + ".UpdateDuties(DbClose) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message); } finally { db = null; } #endregion #region Add Evidence try { switch (type) { case 0: svcPgEvidence.gAddEvidence(ExCast.zCInt(HttpContext.Current.Session[ExSession.EVIDENCE_SAVE_FLG]), companyId, userId, ipAdress, sessionString, PG_NM, DataPgEvidence.geOperationType.Update, "NO:" + _no); break; case 1: svcPgEvidence.gAddEvidence(ExCast.zCInt(HttpContext.Current.Session[ExSession.EVIDENCE_SAVE_FLG]), companyId, userId, ipAdress, sessionString, PG_NM, DataPgEvidence.geOperationType.Insert, "NO:" + _no); break; case 2: svcPgEvidence.gAddEvidence(ExCast.zCInt(HttpContext.Current.Session[ExSession.EVIDENCE_SAVE_FLG]), companyId, userId, ipAdress, sessionString, PG_NM, DataPgEvidence.geOperationType.Delete, "NO:" + _no); break; default: break; } } catch (Exception ex) { CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateDuties(Add Evidence)", ex); return(CLASS_NM + ".UpdateDuties(Add Evidence) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message); } #endregion #region Return if (type == 1) { return("Auto Insert success : " + "NO : " + _no + "で登録しました。"); } else { return(""); } #endregion }