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

            // 棚卸日
            string proc_ym = this.datYmd.Text.Trim();

            // 商品
            if (this.utlCommodity_F.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.ID >= " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(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 <= " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(this.utlCommodity_T.txtID.Text.Trim())) + Environment.NewLine;
                strWhrerString1 += this.utlCommodity_T.txtID.Text.Trim();
            }
            else
            {
                strWhrerString1 += "未指定";
            }

            return(strWhrer + "WhereString =>" + strWhrerString1 + ";" + strWhrerString2);
        }
Пример #2
0
        /// <summary>
        /// 共通追加SQL(WHO COLUMS)取得
        /// </summary>
        /// <param name="intKbn"></param>
        /// <param name="pgid"></param>
        /// <param name="tblName"></param>
        /// <param name="person_id"></param>
        /// <param name="denNo"></param>
        /// <param name="ipAdress"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public static string GetInsSQLCommonColums(UpdKbn intKbn, string pgid, string tblName, int person_id, string denNo, string ipAdress, string userId)
        {
            // 日時取得
            DateTime now  = DateTime.Now;
            string   date = now.ToString("yyyy/MM/dd");
            string   time = now.ToString("HH:mm:ss");

            StringBuilder sb = new StringBuilder();

            if (intKbn == UpdKbn.Ins)
            {
                // insert
                sb.Append("       ,0" + Environment.NewLine);                                                                           // UPDATE_FLG
                sb.Append("       ,0" + Environment.NewLine);                                                                           // DELETE_FLG
                sb.Append("       ," + ExEscape.zRepStr(pgid) + Environment.NewLine);                                                   // CREATE_PG_ID
                sb.Append("       ," + ExEscape.zRepStr(ipAdress) + Environment.NewLine);                                               // CREATE_ADRESS
                sb.Append("       ," + ExEscape.zRepStr(userId) + Environment.NewLine);                                                 // CREATE_USER_ID
                sb.Append("       ," + ExEscape.zRepStr(person_id.ToString()) + Environment.NewLine);                                   // CREATE_PERSON_ID
                sb.Append("       ," + ExEscape.zRepStr(date) + Environment.NewLine);                                                   // CREATE_DATE
                sb.Append("       ," + ExEscape.zRepStr(time) + Environment.NewLine);                                                   // CREATE_TIME
                sb.Append("       ," + ExEscape.zRepStr(pgid) + Environment.NewLine);                                                   // UPDATE_PG_ID
                sb.Append("       ," + ExEscape.zRepStr(ipAdress) + Environment.NewLine);                                               // UPDATE_ADRESS
                sb.Append("       ," + ExEscape.zRepStr(userId) + Environment.NewLine);                                                 // UPDATE_USER_ID
                sb.Append("       ," + ExEscape.zRepStr(person_id) + Environment.NewLine);                                              // UPDATE_PERSON_ID
                sb.Append("       ," + ExEscape.zRepStr(date) + Environment.NewLine);                                                   // UPDATE_DATE
                sb.Append("       ," + ExEscape.zRepStr(time) + Environment.NewLine);                                                   // UPDATE_TIME
            }
            else
            {
                // Update
                string _pgId     = "";
                string _adress   = "";
                string _userId   = "";
                string _personId = "";
                string _date     = "";
                string _time     = "";

                GetSQLCommonUpdate(denNo, tblName, ref _pgId, ref _adress, ref _userId, ref _personId, ref _date, ref _time);
                sb.Append("       ,1" + Environment.NewLine);                                                                           // UPDATE_FLG
                sb.Append("       ,0" + Environment.NewLine);                                                                           // DELETE_FLG
                sb.Append("       ," + ExEscape.zRepStr(_pgId) + Environment.NewLine);                                                  // CREATE_PG_ID
                sb.Append("       ," + ExEscape.zRepStr(_adress) + Environment.NewLine);                                                // CREATE_ADRESS
                sb.Append("       ," + ExEscape.zRepStr(_userId) + Environment.NewLine);                                                // CREATE_USER_ID
                sb.Append("       ," + ExEscape.zRepStr(_personId) + Environment.NewLine);                                              // CREATE_PERSON_ID
                sb.Append("       ," + ExEscape.zRepStr(ExCast.zDateNullToDefault(_date)) + Environment.NewLine);                       // CREATE_DATE
                sb.Append("       ," + ExEscape.zRepStr(ExCast.zTimeNullToDefault(_time)) + Environment.NewLine);                       // CREATE_TIME
                sb.Append("       ," + ExEscape.zRepStr(pgid) + Environment.NewLine);                                                   // UPDATE_PG_ID
                sb.Append("       ," + ExEscape.zRepStr(ipAdress) + Environment.NewLine);                                               // UPDATE_ADRESS
                sb.Append("       ," + ExEscape.zRepStr(userId) + Environment.NewLine);                                                 // UPDATE_USER_ID
                sb.Append("       ," + ExEscape.zRepStr(person_id) + Environment.NewLine);                                              // UPDATE_PERSON_ID
                sb.Append("       ," + ExEscape.zRepStr(date) + Environment.NewLine);                                                   // UPDATE_DATE
                sb.Append("       ," + ExEscape.zRepStr(time) + Environment.NewLine);                                                   // UPDATE_TIME
            }

            return(sb.ToString());
        }
Пример #3
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 void UpdPaymentCredit(string companyId,
                                            string groupId,
                                            ExMySQLData db,
                                            string purchaseId,
                                            double price,
                                            string pg_nm,
                                            int update_person_id,
                                            string ipAdress,
                                            string userId)
        {
            StringBuilder sb;

            try
            {
                sb        = new StringBuilder();
                sb.Length = 0;

                sb.Append("UPDATE M_PURCHASE " + Environment.NewLine);
                sb.Append(CommonUtl.GetUpdSQLCommonColums(pg_nm,
                                                          update_person_id,
                                                          ipAdress,
                                                          userId,
                                                          0));
                sb.Append("      ,PAYMENT_CREDIT_PRICE = PAYMENT_CREDIT_PRICE + " + price.ToString() + Environment.NewLine);

                sb.Append(" WHERE COMPANY_ID = " + companyId + Environment.NewLine);                                            // COMPANY_ID
                sb.Append("   AND ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(purchaseId)) + Environment.NewLine);   // ID

                db.ExecuteSQL(sb.ToString(), false);

                sb.Length = 0;
                sb.Append("UPDATE M_PAYMENT_CREDIT_BALANCE " + Environment.NewLine);

                sb.Append(CommonUtl.GetUpdSQLCommonColums(pg_nm,
                                                          update_person_id,
                                                          ipAdress,
                                                          userId,
                                                          0));
                sb.Append("      ,PAYMENT_CREDIT_PRICE = PAYMENT_CREDIT_PRICE + " + price.ToString() + 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(purchaseId)) + Environment.NewLine);  // ID

                db.ExecuteSQL(sb.ToString(), false);
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdPaymentCredit", ex);
                throw;
            }
        }
        /// <summary>
        /// 商品在庫更新
        /// </summary>
        /// <param name="companyId"></param>
        /// <param name="db"></param>
        /// <param name="customerId"></param>
        /// <param name="ipAdress"></param>
        /// <param name="userId"></param>
        public static void UpdCommodityInventory(string companyId,
                                                 string groupId,
                                                 ExMySQLData db,
                                                 string customerId,
                                                 double number,
                                                 string pg_nm,
                                                 int update_person_id,
                                                 string ipAdress,
                                                 string userId)
        {
            StringBuilder sb;

            try
            {
                sb = new StringBuilder();

                sb.Length = 0;
                sb.Append("UPDATE M_COMMODITY " + Environment.NewLine);
                sb.Append(CommonUtl.GetUpdSQLCommonColums(pg_nm,
                                                          update_person_id,
                                                          ipAdress,
                                                          userId,
                                                          0));
                sb.Append("      ,INVENTORY_NUMBER = INVENTORY_NUMBER + " + number.ToString() + Environment.NewLine);

                sb.Append(" WHERE COMPANY_ID = " + companyId + Environment.NewLine);                                          // COMPANY_ID
                sb.Append("   AND ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(customerId)) + Environment.NewLine); // ID

                db.ExecuteSQL(sb.ToString(), false);

                sb.Length = 0;
                sb.Append("UPDATE M_COMMODITY_INVENTORY " + Environment.NewLine);
                sb.Append(CommonUtl.GetUpdSQLCommonColums(pg_nm,
                                                          update_person_id,
                                                          ipAdress,
                                                          userId,
                                                          0));
                sb.Append("      ,INVENTORY_NUMBER = INVENTORY_NUMBER + " + number.ToString() + Environment.NewLine);

                sb.Append(" WHERE COMPANY_ID = " + companyId + Environment.NewLine);                                           // COMPANY_ID
                sb.Append("   AND GROUP_ID = " + groupId + Environment.NewLine);
                sb.Append("   AND ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(customerId)) + Environment.NewLine);  // ID

                db.ExecuteSQL(sb.ToString(), false);
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdCommodityInventory", ex);
                throw;
            }
        }
Пример #5
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;
            }
        }
Пример #6
0
        /// <summary>
        /// 共通更新SQL(WHO COLUMS)取得
        /// </summary>
        /// <param name="pgid"></param>
        /// <param name="person_id"></param>
        /// <param name="ipAdress"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public static string GetUpdSQLCommonColums(string pgid, int person_id, string ipAdress, string userId, int delete_flg)
        {
            // 日時取得
            DateTime now  = DateTime.Now;
            string   date = now.ToString("yyyy/MM/dd");
            string   time = now.ToString("HH:mm:ss");

            StringBuilder sb = new StringBuilder();

            sb.Append("   SET DELETE_FLG = " + delete_flg.ToString() + Environment.NewLine);
            sb.Append("      ,UPDATE_FLG = 1" + Environment.NewLine);
            sb.Append("      ,UPDATE_PG_ID = " + ExEscape.zRepStr(pgid) + Environment.NewLine);                        // UPDATE_PG_ID
            sb.Append("      ,UPDATE_ADRESS = " + ExEscape.zRepStr(ipAdress) + Environment.NewLine);                   // UPDATE_ADRESS
            sb.Append("      ,UPDATE_USER_ID = " + ExEscape.zRepStr(userId) + Environment.NewLine);                    // UPDATE_USER_ID
            sb.Append("      ,UPDATE_PERSON_ID = " + ExEscape.zRepStr(person_id) + Environment.NewLine);               // UPDATE_PERSON_ID
            sb.Append("      ,UPDATE_DATE = " + ExEscape.zRepStr(date) + Environment.NewLine);                         // UPDATE_DATE
            sb.Append("      ,UPDATE_TIME = " + ExEscape.zRepStr(time) + Environment.NewLine);                         // UPDATE_TIME

            return(sb.ToString());
        }
        // 条件句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);
        }
Пример #8
0
        // 条件句SQL設定
        private string GetSQLWhere()
        {
            string strWhrer        = "";
            string strWhrerString1 = "";
            string strWhrerString2 = "";

            #region 出金番号

            if (this.utlPaymentCashNo_F.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.NO >= " + ExCast.zCLng(this.utlPaymentCashNo_F.txtID.Text.Trim()) + Environment.NewLine;
                strWhrerString1 += "[出金番号 " + ExEscape.zRepStrNoQuota(this.utlPaymentCashNo_F.txtID.Text.Trim()) + "~";
            }
            else
            {
                strWhrerString1 += "[出金番号 未指定~";
            }
            if (this.utlPaymentCashNo_T.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.NO <= " + ExCast.zCLng(this.utlPaymentCashNo_T.txtID.Text.Trim()) + Environment.NewLine;
                strWhrerString1 += ExEscape.zRepStrNoQuota(this.utlPaymentCashNo_T.txtID.Text.Trim());
            }
            else
            {
                strWhrerString1 += "未指定";
            }

            #endregion

            #region 出金日

            if (Common.gWinType == Common.geWinType.ListPaymentCashMonth)
            {
                if (this.datPaymentCashYmd_F.Text.Trim() != "")
                {
                    strWhrer        += "   AND replace(date_format(T.PAYMENT_CASH_YMD , " + ExEscape.SQL_YM + "), '0000/00', '') >= " + ExEscape.zRepStr(this.datPaymentCashYmd_F.Text.Trim()) + Environment.NewLine;
                    strWhrerString1 += "] [出金日 " + ExEscape.zRepStrNoQuota(this.datPaymentCashYmd_F.Text.Trim()) + "~";
                }
                else
                {
                    strWhrerString1 += "] [出金日 未指定~";
                }
                if (this.datPaymentCashYmd_T.Text.Trim() != "")
                {
                    strWhrer        += "   AND replace(date_format(T.PAYMENT_CASH_YMD , " + ExEscape.SQL_YM + "), '0000/00', '') <= " + ExEscape.zRepStr(this.datPaymentCashYmd_T.Text.Trim()) + Environment.NewLine;
                    strWhrerString1 += ExEscape.zRepStrNoQuota(this.datPaymentCashYmd_T.Text.Trim()) + "]";
                }
                else
                {
                    strWhrerString1 += "未指定]";
                }
            }
            else
            {
                if (this.datPaymentCashYmd_F.Text.Trim() != "")
                {
                    strWhrer        += "   AND T.PAYMENT_CASH_YMD >= " + ExEscape.zRepStr(this.datPaymentCashYmd_F.Text.Trim()) + Environment.NewLine;
                    strWhrerString1 += "] [出金日 " + ExEscape.zRepStrNoQuota(this.datPaymentCashYmd_F.Text.Trim()) + "~";
                }
                else
                {
                    strWhrerString1 += "] [出金日 未指定~";
                }
                if (this.datPaymentCashYmd_T.Text.Trim() != "")
                {
                    strWhrer        += "   AND T.PAYMENT_CASH_YMD <= " + ExEscape.zRepStr(this.datPaymentCashYmd_T.Text.Trim()) + Environment.NewLine;
                    strWhrerString1 += ExEscape.zRepStrNoQuota(this.datPaymentCashYmd_T.Text.Trim()) + "]";
                }
                else
                {
                    strWhrerString1 += "未指定]";
                }
            }

            #endregion

            #region 入力担当者

            if (this.utlPerson_F.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.PERSON_ID >= " + ExCast.zCLng(this.utlPerson_F.txtID.Text.Trim()) + Environment.NewLine;
                strWhrerString2 += "[入力担当者 " + this.utlPerson_F.txtID.Text.Trim() + ":" + ExEscape.zRepStrNoQuota(this.utlPerson_F.txtNm.Text.Trim()) + "~";
            }
            else
            {
                strWhrerString2 += "[入力担当者 未指定~";
            }
            if (this.utlPerson_T.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.PERSON_ID <= " + ExCast.zCLng(this.utlPerson_T.txtID.Text.Trim()) + Environment.NewLine;
                strWhrerString2 += this.utlPerson_T.txtID.Text.Trim() + ":" + ExEscape.zRepStrNoQuota(this.utlPerson_T.txtNm.Text.Trim());
            }
            else
            {
                strWhrerString2 += "未指定";
            }

            #endregion

            #region 仕入先

            if (this.utlPurchase.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.PURCHASE_ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(this.utlPurchase.txtID.Text.Trim())) + Environment.NewLine;
                strWhrerString2 += "] [仕入先 " + ExEscape.zRepStrNoQuota(this.utlPurchase.txtID.Text.Trim()) + ":" + ExEscape.zRepStrNoQuota(this.utlPurchase.txtNm.Text.Trim()) + "]";
            }
            else
            {
                strWhrerString2 += "] [仕入先 未指定]";
            }

            #endregion

            if (Common.gWinType == Common.geWinType.ListPaymentCashDay)
            {
                strWhrer += "<group kbn>1";
            }
            else if (Common.gWinType == Common.geWinType.ListPaymentCashMonth)
            {
                strWhrer += "<group kbn>2";
            }

            strWhrer = strWhrer.Replace(",", "<<@escape_comma@>>");

            return(strWhrer + "WhereString =>" + strWhrerString1 + ";" + strWhrerString2);
        }
        public string UpdateInvoiceBalance(string random, int type, List <EntityInvoiceBalance> 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 + ".UpdateInvoiceBalance(認証処理)", ex);
                return(CLASS_NM + ".UpdateInvoiceBalance : 認証処理に失敗しました。" + 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 + ".UpdateInvoiceBalance(DbOpen)", ex);
                return(CLASS_NM + ".UpdateInvoiceBalance(DbOpen) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            #region BeginTransaction

            try
            {
                db.ExBeginTransaction();
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateInvoiceBalance(BeginTransaction)", ex);
                return(CLASS_NM + ".UpdateInvoiceBalance(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_invoice_price_upd - entity[i].before_invoice_price;

                            #region Update Invoice Balance

                            try
                            {
                                sb.Length = 0;
                                sb.Append("UPDATE T_INVOICE " + Environment.NewLine);

                                sb.Append(CommonUtl.GetUpdSQLCommonColums(PG_NM,
                                                                          ExCast.zCInt(personId),
                                                                          ipAdress,
                                                                          userId,
                                                                          0));

                                sb.Append("      ,BEFORE_INVOICE_PRICE = BEFORE_INVOICE_PRICE + " + upd_balance + Environment.NewLine);
                                sb.Append("      ,TRANSFER_PRICE = TRANSFER_PRICE + " + upd_balance + Environment.NewLine);
                                sb.Append("      ,INVOICE_PRICE = INVOICE_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 INVOICE_KBN = 0 " + Environment.NewLine);
                                sb.Append("   AND INVOICE_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 + ".UpdateInvoiceBalance(Update Invoice Balance)", ex);
                                return(CLASS_NM + ".UpdateInvoiceBalance(Update Invoice Balance) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
                            }

                            #endregion
                        }
                    }
                }
                catch (Exception ex)
                {
                    db.ExRollbackTransaction();
                    CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateInvoiceBalance(Insert)", ex);
                    return(CLASS_NM + ".UpdateInvoiceBalance(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 + ".UpdateInvoiceBalance(DelLockPg)", ex);
            //    return CLASS_NM + ".UpdateInvoiceBalance(DelLockPg) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message;
            //}

            #endregion

            #region CommitTransaction

            try
            {
                db.ExCommitTransaction();
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateInvoiceBalance(CommitTransaction)", ex);
                return(CLASS_NM + ".UpdateInvoiceBalance(CommitTransaction) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            #region Database Close

            try
            {
                db.DbClose();
            }
            catch (Exception ex)
            {
                db.ExRollbackTransaction();
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateInvoiceBalance(DbClose)", ex);
                return(CLASS_NM + ".UpdateInvoiceBalance(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 + ".UpdateInvoiceBalance(Add Evidence)", ex);
                return(CLASS_NM + ".UpdateInvoiceBalance(Add Evidence) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            return("");
        }
Пример #10
0
        // 条件句SQL設定
        private string GetSQLWhere()
        {
            string strWhrer        = "";
            string strWhrerString1 = "";
            string strWhrerString2 = "";

            // 見積番号
            if (this.utlEstimateNo_F.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.NO >= " + ExCast.zCLng(this.utlEstimateNo_F.txtID.Text.Trim()) + Environment.NewLine;
                strWhrerString1 += "[見積番号 " + this.utlEstimateNo_F.txtID.Text.Trim() + "~";
            }
            else
            {
                strWhrerString1 += "[見積番号 未指定~";
            }
            if (this.utlEstimateNo_T.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.NO <= " + ExCast.zCLng(this.utlEstimateNo_T.txtID.Text.Trim()) + Environment.NewLine;
                strWhrerString1 += this.utlEstimateNo_T.txtID.Text.Trim();
            }
            else
            {
                strWhrerString1 += "未指定";
            }

            // 見積日
            if (this.datEstimateYmd_F.Text.Trim() != "")
            {
                strWhrer        += "   AND T.ESTIMATE_YMD >= " + ExEscape.zRepStr(this.datEstimateYmd_F.Text.Trim()) + Environment.NewLine;
                strWhrerString1 += "] [見積日 " + ExEscape.zRepStrNoQuota(this.datEstimateYmd_F.Text.Trim()) + "~";
            }
            else
            {
                strWhrerString1 += "] [見積日 未指定~";
            }
            if (this.datEstimateYmd_T.Text.Trim() != "")
            {
                strWhrer        += "   AND T.ESTIMATE_YMD <= " + ExEscape.zRepStr(this.datEstimateYmd_T.Text.Trim()) + Environment.NewLine;
                strWhrerString1 += ExEscape.zRepStrNoQuota(this.datEstimateYmd_T.Text.Trim());
            }
            else
            {
                strWhrerString1 += "未指定";
            }

            // 納入指定日
            if (this.datNokiYmd_F.Text.Trim() != "")
            {
                strWhrer        += "   AND T.SUPPLY_YMD >= " + ExEscape.zRepStr(this.datNokiYmd_F.Text.Trim()) + Environment.NewLine;
                strWhrerString1 += "] [納入指定日 " + ExEscape.zRepStrNoQuota(this.datNokiYmd_F.Text.Trim()) + "~";
            }
            else
            {
                strWhrerString1 += "] [納入指定日 未指定~";
            }
            if (this.datNokiYmd_T.Text.Trim() != "")
            {
                strWhrer        += "   AND T.SUPPLY_YMD <= " + ExEscape.zRepStr(this.datNokiYmd_T.Text.Trim()) + Environment.NewLine;
                strWhrerString1 += ExEscape.zRepStrNoQuota(this.datNokiYmd_T.Text.Trim()) + "]";
            }
            else
            {
                strWhrerString1 += "未指定]";
            }

            // 入力担当者
            if (this.utlPerson_F.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.PERSON_ID >= " + ExCast.zCLng(this.utlPerson_F.txtID.Text.Trim()) + Environment.NewLine;
                strWhrerString2 += "[入力担当者 " + this.utlPerson_F.txtID.Text.Trim() + ":" + ExEscape.zRepStrNoQuota(this.utlPerson_F.txtNm.Text.Trim()) + "~";
            }
            else
            {
                strWhrerString2 += "[入力担当者 未指定~";
            }
            if (this.utlPerson_T.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.PERSON_ID <= " + ExCast.zCLng(this.utlPerson_T.txtID.Text.Trim()) + Environment.NewLine;
                strWhrerString2 += this.utlPerson_T.txtID.Text.Trim() + ":" + ExEscape.zRepStrNoQuota(this.utlPerson_T.txtNm.Text.Trim());
            }
            else
            {
                strWhrerString2 += "未指定";
            }

            // 得意先
            if (this.utlCustomer.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.CUSTOMER_ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(this.utlCustomer.txtID.Text.Trim())) + Environment.NewLine;
                strWhrerString2 += "] [得意先 " + ExEscape.zRepStrNoQuota(this.utlCustomer.txtID.Text.Trim()) + ":" + ExEscape.zRepStrNoQuota(this.utlCustomer.txtNm.Text.Trim());
            }
            else
            {
                strWhrerString2 += "] [得意先 未指定";
            }

            // 納入先
            if (this.utlSupply.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.SUPPLIER_ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(this.utlSupply.txtID.Text.Trim())) + Environment.NewLine;
                strWhrerString2 += "] [納入先 " + ExEscape.zRepStrNoQuota(this.utlSupply.txtID.Text.Trim()) + ":" + ExEscape.zRepStrNoQuota(this.utlSupply.txtNm.Text.Trim());
            }
            else
            {
                strWhrerString2 += "] [納入先 未指定";
            }

            // 商品コード
            if (this.utlCommodity.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND OD.COMMODITY_ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(this.utlCommodity.txtID.Text.Trim())) + Environment.NewLine;
                strWhrerString2 += "] [商品コード " + ExEscape.zRepStrNoQuota(this.utlCommodity.txtID.Text.Trim()) + ":" + ExEscape.zRepStrNoQuota(this.utlCommodity.txtNm.Text.Trim()) + "]";
            }
            else
            {
                strWhrerString2 += "] [商品コード 未指定" + "]";
            }

            // 取引区分
            string _buf = "";

            if (this.chkKake.IsChecked == true)
            {
                // 掛売上
                strWhrer += "   AND (T.BUSINESS_DIVISION_ID = 1";
                _buf     += " [取引区分 掛売上";
            }
            if (this.chkCash.IsChecked == true)
            {
                // 現金
                if (_buf == "")
                {
                    strWhrer += "   AND (T.BUSINESS_DIVISION_ID = 2";
                    _buf     += " [取引区分 現金";
                }
                else
                {
                    strWhrer += " OR T.BUSINESS_DIVISION_ID = 2";
                    _buf     += " 現金";
                }
            }
            if (_buf == "")
            {
                _buf += " [取引区分 指定無し]";
            }
            else
            {
                strWhrer += ")" + Environment.NewLine;
                _buf     += "]";
            }
            strWhrerString2 += _buf;
            _buf             = "";

            // 承認状態
            if (Common.gintEstimateApprovalFlg == 1)
            {
                if (this.chkStillApproval.IsChecked == true)
                {
                    // 未承認
                    strWhrer += "   AND (T.STATE = 0";
                    _buf     += " [承認状態 未承認";
                }
                if (this.chkApproval.IsChecked == true)
                {
                    // 承認
                    if (_buf == "")
                    {
                        strWhrer += "   AND (T.STATE = 1";
                        _buf     += " [承認状態 承認";
                    }
                    else
                    {
                        strWhrer += " OR T.STATE = 1";
                        _buf     += " 承認";
                    }
                }
                if (this.chkResevation.IsChecked == true)
                {
                    // 保留
                    if (_buf == "")
                    {
                        strWhrer += "   AND (T.STATE = 2";
                        _buf     += " [承認状態 保留";
                    }
                    else
                    {
                        strWhrer += " OR T.STATE = 2";
                        _buf     += " 保留";
                    }
                }
                if (this.chkRejetion.IsChecked == true)
                {
                    // 取消
                    if (_buf == "")
                    {
                        strWhrer += "   AND (T.STATE = 3";
                        _buf     += " [承認状態 取消";
                    }
                    else
                    {
                        strWhrer += " OR T.STATE = 3";
                        _buf     += " 取消";
                    }
                }

                if (_buf == "")
                {
                    _buf += " [承認状態 指定無し]";
                }
                else
                {
                    strWhrer += ")" + Environment.NewLine;
                    _buf     += "]";
                }
                strWhrerString2 += _buf;
            }

            _buf = "";

            // 見積書発行
            if (this.borPrint.Visibility == System.Windows.Visibility.Visible)
            {
                if (this.chkPrintNo.IsChecked == true)
                {
                    strWhrer += "   AND (T.ESTIMATE_PRINT_FLG = 0";
                    _buf     += " [見積書発行 発行未";
                }
                if (this.chkPrintYes.IsChecked == true)
                {
                    if (_buf == "")
                    {
                        strWhrer += "   AND (T.ESTIMATE_PRINT_FLG = 1";
                        _buf     += " [見積書発行 発行済";
                    }
                    else
                    {
                        strWhrer += " OR T.ESTIMATE_PRINT_FLG = 1";
                        _buf     += " 発行済";
                    }
                }
                if (_buf == "")
                {
                    _buf += " [見積書発行 指定無し]";
                }
                else
                {
                    strWhrer += ")" + Environment.NewLine;
                    _buf     += "]";
                }
                strWhrerString2 += _buf;
                _buf             = "";
            }


            UpdPrintNo = "";
            if (this.ProcKbn == eProcKbn.Report)
            {
                strWhrer        = "";
                strWhrerString1 = "";
                strWhrerString2 = "";

                string _no = "";
                for (int i = 0; i <= lst.Count - 1; i++)
                {
                    if (lst[i].exec_flg == true)
                    {
                        if (string.IsNullOrEmpty(_no))
                        {
                            _no += ExCast.zCLng(this.lst[i].no).ToString();
                        }
                        else
                        {
                            _no += "<<@escape_comma@>>" + ExCast.zCLng(this.lst[i].no).ToString();
                        }
                    }
                }
                if (!string.IsNullOrEmpty(_no))
                {
                    UpdPrintNo = _no;
                    strWhrer  += "   AND T.NO IN (" + _no + ")" + Environment.NewLine;
                }
            }

            return(strWhrer + "WhereString =>" + strWhrerString1 + ";" + strWhrerString2);
        }
Пример #11
0
        public string UpdateCompany(string random, int type, EntityCompany 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 + ".UpdateCompany(認証処理)", ex);
                return(CLASS_NM + ".UpdateCompany : 認証処理に失敗しました。" + 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();
                db.DbOpen();
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateCompany(DbOpen)", ex);
                return(CLASS_NM + ".UpdateCompany(DbOpen) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            #region BeginTransaction

            try
            {
                db.ExBeginTransaction();
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateCompany(BeginTransaction)", ex);
                return(CLASS_NM + ".UpdateCompany(BeginTransaction) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            #region Update

            if (type == 0)
            {
                try
                {
                    #region Company SQL

                    sb.Length = 0;
                    sb.Append("UPDATE SYS_M_COMPANY " + 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("      ,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("      ,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("      ,MEMO = " + ExEscape.zRepStr(entity.memo) + Environment.NewLine);
                    sb.Append(" WHERE ID = " + companyId + Environment.NewLine);                            // COMPANY_ID

                    #endregion

                    db.ExecuteSQL(sb.ToString(), false);

                    #region System Setting SQL

                    sb.Length = 0;
                    sb.Append("UPDATE SYS_M_SETTING " + Environment.NewLine);
                    sb.Append(CommonUtl.GetUpdSQLCommonColums(PG_NM,
                                                              ExCast.zCInt(personId),
                                                              ipAdress,
                                                              userId,
                                                              0));
                    sb.Append("      ,GROUP_DISPLAY_NAME = " + ExEscape.zRepStr(entity.group_display_name) + Environment.NewLine);
                    sb.Append("      ,ID_FIGURE_SLIP_NO = " + entity.id_figure_slip_no + Environment.NewLine);
                    sb.Append("      ,ID_FIGURE_CUSTOMER = " + entity.id_figure_customer + Environment.NewLine);
                    sb.Append("      ,ID_FIGURE_PURCHASE = " + entity.id_figure_purchase + Environment.NewLine);
                    sb.Append("      ,ID_FIGURE_GOODS = " + entity.id_figure_commodity + Environment.NewLine);
                    sb.Append(" WHERE COMPANY_ID = " + companyId + Environment.NewLine);                            // COMPANY_ID

                    #endregion

                    db.ExecuteSQL(sb.ToString(), false);
                }
                catch (Exception ex)
                {
                    db.ExRollbackTransaction();
                    CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateCompany(Update)", ex);
                    return(CLASS_NM + ".UpdateCompany(Update) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
                }
            }

            #endregion

            #region Delete

            if (type == 2)
            {
                //#region Exist Data

                //try
                //{
                //    bool _ret = false;
                //    _ret = DataExists.IsExistData(db, companyId, "", "SYS_M_COMPANY", "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", "Company_ID", ExCast.zNumZeroNothingFormat(Id), CommonUtl.geStrOrNumKbn.String);
                //    if (_ret == true)
                //    {
                //        return "得意先ID : " + Id + " は受注データの得意先に使用されている為、削除できません。";
                //    }

                //}
                //catch (Exception ex)
                //{
                //    db.ExRollbackTransaction();
                //    CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateCompany(Exist Data)", ex);
                //    return CLASS_NM + ".UpdateCompany(Exist Data) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message;
                //}

                //#endregion

                //#region Update

                //try
                //{
                //    sb.Length = 0;
                //    sb.Append("UPDATE SYS_M_COMPANY " + 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 + ".UpdateCompany(Delete)", ex);
                //    return CLASS_NM + ".UpdateCompany(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 + ".UpdateCompany(DelLockPg)", ex);
                    return(CLASS_NM + ".UpdateCompany(DelLockPg) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
                }
            }

            #endregion

            #region CommitTransaction

            try
            {
                db.ExCommitTransaction();
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateCompany(CommitTransaction)", ex);
                return(CLASS_NM + ".UpdateCompany(CommitTransaction) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            #region Database Close

            try
            {
                db.DbClose();
            }
            catch (Exception ex)
            {
                db.ExRollbackTransaction();
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateCompany(DbClose)", ex);
                return(CLASS_NM + ".UpdateCompany(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:" + companyId.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:" + companyId.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:" + companyId.ToString());
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateCompany(Add Evidence)", ex);
                return(CLASS_NM + ".UpdateCompany(Add Evidence) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            #region Return

            return("");

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

            // 支払書番号
            if (this.utlPaymentNo_F.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.NO >= " + ExCast.zCLng(this.utlPaymentNo_F.txtID.Text.Trim()) + Environment.NewLine;
                strWhrerString1 += "[支払書番号 " + ExCast.zCLng(this.utlPaymentNo_F.txtID.Text.Trim()) + "~";
            }
            else
            {
                strWhrerString1 += "[支払書番号 未指定~";
            }
            if (this.utlPaymentNo_T.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.NO <= " + ExCast.zCLng(this.utlPaymentNo_T.txtID.Text.Trim()) + Environment.NewLine;
                strWhrerString1 += ExCast.zCLng(this.utlPaymentNo_T.txtID.Text.Trim());
            }
            else
            {
                strWhrerString1 += "未指定";
            }

            // 支払締日
            if (this.datPaymentCloseYmd_F.Text.Trim() != "")
            {
                strWhrer        += "   AND T.PAYMENT_YYYYMMDD >= " + ExEscape.zRepStr(this.datPaymentCloseYmd_F.Text.Trim()) + Environment.NewLine;
                strWhrerString1 += "] [支払締日 " + this.datPaymentCloseYmd_F.Text.Trim() + "~";
            }
            else
            {
                strWhrerString1 += "] [支払締日 未指定~";
            }
            if (this.datPaymentCloseYmd_T.Text.Trim() != "")
            {
                strWhrer        += "   AND T.PAYMENT_YYYYMMDD <= " + ExEscape.zRepStr(this.datPaymentCloseYmd_T.Text.Trim()) + Environment.NewLine;
                strWhrerString1 += this.datPaymentCloseYmd_T.Text.Trim();
            }
            else
            {
                strWhrerString1 += "未指定";
            }

            // 仕入先
            if (this.utlPurchase.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.PURCHASE_ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(this.utlPurchase.txtID.Text.Trim())) + Environment.NewLine;
                strWhrerString2 += "[仕入先 " + ExEscape.zRepStrNoQuota(this.utlPurchase.txtID.Text.Trim()) + ":" + ExEscape.zRepStrNoQuota(this.utlPurchase.txtNm.Text.Trim());
            }
            else
            {
                strWhrerString2 += "[仕入先 未指定";
            }

            // 締区分
            if (this.utlSummingUp.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.SUMMING_UP_GROUP_ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(this.utlSummingUp.txtID.Text.Trim())) + Environment.NewLine;
                strWhrerString2 += "] [締区分 " + ExEscape.zRepStrNoQuota(this.utlSummingUp.txtID.Text.Trim()) + ":" + ExEscape.zRepStrNoQuota(this.utlSummingUp.txtNm.Text.Trim());
            }
            else
            {
                strWhrerString2 += "] [締区分 未指定";
            }

            string _buf = "";

            // 支払書発行
            if (borPrint.Visibility == System.Windows.Visibility.Visible)
            {
                if (this.chkPrintNo.IsChecked == true)
                {
                    // 発行済を除く
                    strWhrer += "   AND (T.PAYMENT_PRINT_FLG = 0";
                    _buf     += " [支払書発行 発行未";
                }
                if (this.chkPrintYes.IsChecked == true)
                {
                    // 都度請求
                    if (_buf == "")
                    {
                        strWhrer += "   AND (T.PAYMENT_PRINT_FLG = 1";
                        _buf     += " [支払書発行 発行済";
                    }
                    else
                    {
                        strWhrer += " OR T.PAYMENT_PRINT_FLG = 1";
                        _buf     += " 発行済";
                    }
                }
                if (_buf == "")
                {
                    _buf += " [支払書発行 指定無し]";
                }
                else
                {
                    strWhrer += ")" + Environment.NewLine;
                    _buf     += "]";
                }
                strWhrerString2 += _buf;
            }

            _buf = "";

            // 出金消込
            if (borReceipt.Visibility == System.Windows.Visibility.Visible)
            {
                if (this.chkPaymentNo.IsChecked == true)
                {
                    strWhrer += "   AND (IFNULL(RP_SUM.SUM_PRICE, 0) = 0";
                    _buf     += " [出金消込 消込未";
                }
                if (this.chkPaymentPlace.IsChecked == true)
                {
                    if (_buf == "")
                    {
                        strWhrer += "   AND (IFNULL(RP_SUM.SUM_PRICE, 0) < IFNULL(T.PAYMENT_PRICE, 0)";
                        _buf     += " [出金消込 一部消込";
                    }
                    else
                    {
                        strWhrer += " OR IFNULL(RP_SUM.SUM_PRICE, 0) < IFNULL(T.PAYMENT_PRICE, 0)";
                        _buf     += " 一部消込";
                    }
                }
                if (this.chkPaymentYes.IsChecked == true)
                {
                    if (_buf == "")
                    {
                        strWhrer += "   AND (IFNULL(RP_SUM.SUM_PRICE, 0) = IFNULL(T.PAYMENT_PRICE, 0)";
                        _buf     += " [出金消込 消込済";
                    }
                    else
                    {
                        strWhrer += " OR IFNULL(RP_SUM.SUM_PRICE, 0) = IFNULL(T.PAYMENT_PRICE, 0)";
                        _buf     += " 消込済";
                    }
                }
                if (this.chkPaymentOver.IsChecked == true)
                {
                    if (_buf == "")
                    {
                        strWhrer += "   AND (IFNULL(RP_SUM.SUM_PRICE, 0) > IFNULL(T.PAYMENT_PRICE, 0)";
                        _buf     += " [出金消込 超過消込";
                    }
                    else
                    {
                        strWhrer += " OR IFNULL(RP_SUM.SUM_PRICE, 0) > IFNULL(T.PAYMENT_PRICE, 0)";
                        _buf     += " 超過消込";
                    }
                }
                if (_buf == "")
                {
                    _buf += " [出金消込 指定無し]";
                }
                else
                {
                    strWhrer += ")" + Environment.NewLine;
                    _buf     += "]";
                }
                strWhrerString2 += _buf;
            }

            _buf = "";

            lstUpd.Clear();
            if (this.ProcKbn == eProcKbn.Report)
            {
                strWhrer        = "";
                strWhrerString1 = "";
                strWhrerString2 = "";

                string _no = "";
                for (int i = 0; i <= lst.Count - 1; i++)
                {
                    if (lst[i].exec_flg == true)
                    {
                        EntityPaymentClose entityUpd = new EntityPaymentClose();
                        entityUpd._no = lst[i].no;
                        lstUpd.Add(entityUpd);

                        if (string.IsNullOrEmpty(_no))
                        {
                            _no += ExCast.zCLng(this.lst[i].no).ToString();
                        }
                        else
                        {
                            _no += "<<@escape_comma@>>" + ExCast.zCLng(this.lst[i].no).ToString();
                        }
                    }
                }
                if (!string.IsNullOrEmpty(_no))
                {
                    strWhrer += "   AND T.NO IN (" + _no + ")" + Environment.NewLine;
                }

                if (datIssueYmd.SelectedDate != null)
                {
                    strWhrer += "<issue ymd>" + ((DateTime)datIssueYmd.SelectedDate).ToString("yyyy/MM/dd");
                }
            }

            return(strWhrer + "WhereString =>" + strWhrerString1 + ";" + strWhrerString2);
        }
Пример #13
0
        public string UpdateUser(string random, int type, long Id, EntityUser 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 + ".UpdateUser(認証処理)", ex);
                return(CLASS_NM + ".UpdateUser : 認証処理に失敗しました。" + Environment.NewLine + ex.Message.ToString());
            }

            #endregion

            #region Field

            StringBuilder sb = new StringBuilder();
            DataTable     dt;
            ExMySQLData   db  = null;
            string        _Id = "";
            _Id = Id.ToString();

            #endregion

            #region Databese Open

            try
            {
                db = new ExMySQLData();
                db.DbOpen();
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateUser(DbOpen)", ex);
                return(CLASS_NM + ".UpdateUser(DbOpen) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            #region BeginTransaction

            try
            {
                db.ExBeginTransaction();
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateUser(BeginTransaction)", ex);
                return(CLASS_NM + ".UpdateUser(BeginTransaction) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            #region Update

            if (type == 0)
            {
                try
                {
                    #region SQL

                    sb.Length = 0;
                    sb.Append("UPDATE SYS_M_USER " + Environment.NewLine);
                    sb.Append(CommonUtl.GetUpdSQLCommonColums(PG_NM,
                                                              ExCast.zCInt(personId),
                                                              ipAdress,
                                                              userId,
                                                              0));
                    sb.Append("      ,GROUP_ID = " + entity.group_id + Environment.NewLine);
                    sb.Append("      ,LOGIN_ID = " + ExEscape.zRepStr(entity.after_login_id) + Environment.NewLine);
                    sb.Append("      ,NAME = " + ExEscape.zRepStr(entity.name) + Environment.NewLine);
                    sb.Append("      ,PASSWORD = "******"      ,PERSON_ID = " + entity.person_id + Environment.NewLine);
                    sb.Append("      ,MEMO = " + ExEscape.zRepStr(entity.memo) + Environment.NewLine);
                    sb.Append("      ,DISPLAY_FLG = 1" + Environment.NewLine);
                    sb.Append(" WHERE ID = " + Id.ToString() + Environment.NewLine);            // ID

                    #endregion

                    db.ExecuteSQL(sb.ToString(), false);
                }
                catch (Exception ex)
                {
                    db.ExRollbackTransaction();
                    CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateUser(Update)", ex);
                    return(CLASS_NM + ".UpdateUser(Update) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
                }
            }

            #endregion

            #region Delete

            if (type == 2)
            {
                //#region Exist Data

                //try
                //{
                //    bool _ret = false;
                //    _ret = DataExists.IsExistData(db, companyId, "", "T_ORDER_H", "User_ID", Id.ToString(), CommonUtl.geStrOrNumKbn.Number);
                //    if (_ret == true)
                //    {
                //        return "担当ID : " + Id + " は受注データの入力担当者に使用されている為、削除できません。";
                //    }
                //}
                //catch (Exception ex)
                //{
                //    db.ExRollbackTransaction();
                //    CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateUser(Exist Data)", ex);
                //    return CLASS_NM + ".UpdateUser(Exist Data) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message;
                //}

                //#endregion

                //#region Update

                //try
                //{
                //    sb.Length = 0;
                //    sb.Append("UPDATE SYS_M_USER " + 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 = " + Id.ToString() + Environment.NewLine);        // ID

                //    db.ExecuteSQL(sb.ToString(), false);

                //}
                //catch (Exception ex)
                //{
                //    db.ExRollbackTransaction();
                //    CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateUser(Delete)", ex);
                //    return CLASS_NM + ".UpdateUser(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 + ".UpdateUser(DelLockPg)", ex);
                    return(CLASS_NM + ".UpdateUser(DelLockPg) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
                }
            }

            #endregion

            #region CommitTransaction

            try
            {
                db.ExCommitTransaction();
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateUser(CommitTransaction)", ex);
                return(CLASS_NM + ".UpdateUser(CommitTransaction) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            #region Database Close

            try
            {
                db.DbClose();
            }
            catch (Exception ex)
            {
                db.ExRollbackTransaction();
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateUser(DbClose)", ex);
                return(CLASS_NM + ".UpdateUser(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 + ".UpdateUser(Add Evidence)", ex);
                return(CLASS_NM + ".UpdateUser(Add Evidence) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            #region Return

            if (type == 1 && Id == 0)
            {
                return("Auto Insert success : " + "ID : " + _Id.ToString() + "で登録しました。");
            }
            else
            {
                return("");
            }

            #endregion
        }
Пример #14
0
        // 条件句SQL設定
        private string GetSQLWhere()
        {
            string strWhrer        = "";
            string strWhrerString1 = "";
            string strWhrerString2 = "";



            if (Common.gWinType == Common.geWinType.ListCollectPlan)
            {
                #region 回収予定日

                if (this.datCollectPlanYmd_F.Text.Trim() != "")
                {
                    strWhrer        += "   AND T.COLLECT_PLAN_DAY >= " + ExEscape.zRepStr(this.datCollectPlanYmd_F.Text.Trim()) + Environment.NewLine;
                    strWhrerString1 += "[回収予定日 " + ExEscape.zRepStrNoQuota(this.datCollectPlanYmd_F.Text.Trim()) + "~";
                }
                else
                {
                    strWhrerString1 += "[回収予定日 未指定~";
                }
                if (this.datCollectPlanYmd_T.Text.Trim() != "")
                {
                    strWhrer        += "   AND T.COLLECT_PLAN_DAY <= " + ExEscape.zRepStr(this.datCollectPlanYmd_T.Text.Trim()) + Environment.NewLine;
                    strWhrerString1 += ExEscape.zRepStrNoQuota(this.datCollectPlanYmd_T.Text.Trim()) + "]";
                }
                else
                {
                    strWhrerString1 += "未指定]";
                }

                #endregion

                #region 請求先

                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 += "] [請求先 " + ExEscape.zRepStrNoQuota(this.utlInvoice_F.txtID.Text.Trim()) + ":" + ExEscape.zRepStrNoQuota(this.utlInvoice_F.txtNm.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 += ExEscape.zRepStrNoQuota(this.utlInvoice_T.txtID.Text.Trim()) + ":" + ExEscape.zRepStrNoQuota(this.utlInvoice_T.txtNm.Text.Trim()) + "]";
                }
                else
                {
                    strWhrerString1 += "未指定]";
                }

                #endregion
            }
            else if (Common.gWinType == Common.geWinType.ListPaymentPlan)
            {
                #region 支払予定日

                if (this.datCollectPlanYmd_F.Text.Trim() != "")
                {
                    strWhrer        += "   AND T.PAYMENT_PLAN_DAY >= " + ExEscape.zRepStr(this.datCollectPlanYmd_F.Text.Trim()) + Environment.NewLine;
                    strWhrerString1 += "[支払予定日 " + ExEscape.zRepStrNoQuota(this.datCollectPlanYmd_F.Text.Trim()) + "~";
                }
                else
                {
                    strWhrerString1 += "[支払予定日 未指定~";
                }
                if (this.datCollectPlanYmd_T.Text.Trim() != "")
                {
                    strWhrer        += "   AND T.PAYMENT_PLAN_DAY <= " + ExEscape.zRepStr(this.datCollectPlanYmd_T.Text.Trim()) + Environment.NewLine;
                    strWhrerString1 += ExEscape.zRepStrNoQuota(this.datCollectPlanYmd_T.Text.Trim()) + "]";
                }
                else
                {
                    strWhrerString1 += "未指定]";
                }

                #endregion

                #region 仕入先

                if (this.utlPurchase_F.txtID.Text.Trim() != "")
                {
                    strWhrer        += "   AND T.PURCHASE_ID >= " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(this.utlPurchase_F.txtID.Text.Trim())) + Environment.NewLine;
                    strWhrerString1 += "] [仕入先 " + ExEscape.zRepStrNoQuota(this.utlPurchase_F.txtID.Text.Trim()) + ":" + ExEscape.zRepStrNoQuota(this.utlPurchase_F.txtNm.Text.Trim()) + "~";
                }
                else
                {
                    strWhrerString1 += "] [仕入先 未指定~";
                }
                if (this.utlPurchase_T.txtID.Text.Trim() != "")
                {
                    strWhrer        += "   AND T.PURCHASE_ID >= " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(this.utlPurchase_T.txtID.Text.Trim())) + Environment.NewLine;
                    strWhrerString1 += ExEscape.zRepStrNoQuota(this.utlPurchase_T.txtID.Text.Trim()) + ":" + ExEscape.zRepStrNoQuota(this.utlPurchase_T.txtNm.Text.Trim()) + "]";
                }
                else
                {
                    strWhrerString1 += "未指定]";
                }

                #endregion
            }

            string _buf = "";

            //if (Common.gWinType == Common.geWinType.ListSalesDay)
            //{
            //    strWhrer += "<group kbn>1";
            //}
            //else if (Common.gWinType == Common.geWinType.ListSalesMonth)
            //{
            //    strWhrer += "<group kbn>2";
            //}
            //else if (Common.gWinType == Common.geWinType.ListSalesChange)
            //{
            //    strWhrer += "<group kbn>3";
            //}

            strWhrer = strWhrer.Replace(",", "<<@escape_comma@>>");

            return(strWhrer + "WhereString =>" + strWhrerString1 + ";" + strWhrerString2);
        }
Пример #15
0
        public string UpdateSupplier(string random, int type, string CustomerId, string Id, EntitySupplier 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 + ".UpdateSupplier(認証処理)", ex);
                return(CLASS_NM + ".UpdateSupplier : 認証処理に失敗しました。" + 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 + ".UpdateSupplier(DbOpen)", ex);
                return(CLASS_NM + ".UpdateSupplier(DbOpen) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            #region BeginTransaction

            try
            {
                db.ExBeginTransaction();
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateSupplier(BeginTransaction)", ex);
                return(CLASS_NM + ".UpdateSupplier(BeginTransaction) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            #region Get Max Master ID

            if (type == 1 && (Id == "" || Id == "0"))
            {
                try
                {
                    DataMasterId.GetMaxMasterId(companyId,
                                                ExCast.zNumZeroNothingFormat(CustomerId),
                                                db,
                                                DataMasterId.geMasterMaxIdKbn.Supplier,
                                                out _Id);

                    if (_Id == "")
                    {
                        return("ID取得に失敗しました。");
                    }
                }
                catch (Exception ex)
                {
                    CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateSupplier(GetMaxMasterId)", ex);
                    return(CLASS_NM + ".UpdateSupplier(GetMaxMasterId) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
                }
            }
            else
            {
                _Id = Id;
            }

            #endregion

            #region Insert

            if (type == 1)
            {
                try
                {
                    #region Delete SQL

                    sb.Length = 0;
                    sb.Append("DELETE FROM M_SUPPLIER " + Environment.NewLine);
                    sb.Append(" WHERE DELETE_FLG = 1 " + Environment.NewLine);
                    sb.Append("   AND COMPANY_ID = " + companyId + Environment.NewLine);
                    sb.Append("   AND ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(_Id)) + Environment.NewLine);
                    sb.Append("   AND CUSTOMER_ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(CustomerId)) + Environment.NewLine);

                    #endregion

                    db.ExecuteSQL(sb.ToString(), false);

                    #region Insert SQL

                    sb.Length = 0;
                    sb.Append("INSERT INTO M_SUPPLIER " + Environment.NewLine);
                    sb.Append("       ( COMPANY_ID" + Environment.NewLine);
                    sb.Append("       , CUSTOMER_ID" + Environment.NewLine);
                    sb.Append("       , ID" + Environment.NewLine);
                    sb.Append("       , ID2" + Environment.NewLine);
                    sb.Append("       , NAME" + Environment.NewLine);
                    sb.Append("       , KANA" + Environment.NewLine);
                    sb.Append("       , ABOUT_NAME" + Environment.NewLine);
                    sb.Append("       , ZIP_CODE" + Environment.NewLine);
                    sb.Append("       , PREFECTURE_ID" + Environment.NewLine);
                    sb.Append("       , CITY_ID" + Environment.NewLine);
                    sb.Append("       , TOWN_ID" + Environment.NewLine);
                    sb.Append("       , ADRESS_CITY" + Environment.NewLine);
                    sb.Append("       , ADRESS_TOWN" + Environment.NewLine);
                    sb.Append("       , ADRESS1" + Environment.NewLine);
                    sb.Append("       , ADRESS2" + Environment.NewLine);
                    sb.Append("       , STATION_NAME" + Environment.NewLine);
                    sb.Append("       , POST_NAME" + Environment.NewLine);
                    sb.Append("       , PERSON_NAME" + Environment.NewLine);
                    sb.Append("       , TITLE_ID" + Environment.NewLine);
                    sb.Append("       , TITLE_NAME" + Environment.NewLine);
                    sb.Append("       , TEL" + Environment.NewLine);
                    sb.Append("       , FAX" + Environment.NewLine);
                    sb.Append("       , MAIL_ADRESS" + Environment.NewLine);
                    sb.Append("       , MOBILE_TEL" + Environment.NewLine);
                    sb.Append("       , MOBILE_ADRESS" + Environment.NewLine);
                    sb.Append("       , URL" + Environment.NewLine);
                    sb.Append("       , DIVIDE_PERMISSION_ID" + 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("       ," + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(CustomerId)) + Environment.NewLine);       // CUSTOMER_ID
                    sb.Append("       ," + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(_Id)) + Environment.NewLine);              // ID
                    sb.Append("       ," + ExCast.zIdForNumIndex(_Id) + Environment.NewLine);                                       // ID2
                    sb.Append("       ," + ExEscape.zRepStr(entity.name) + Environment.NewLine);                                    // NAME
                    sb.Append("       ," + ExEscape.zRepStr(entity.kana) + Environment.NewLine);                                    // KANA
                    sb.Append("       ," + ExEscape.zRepStr(entity.about_name) + Environment.NewLine);                              // ABOUT_NAME
                    sb.Append("       ," + ExCast.zNullToZero(entity.zip_code_from + entity.zip_code_to) + Environment.NewLine);    // ZIP_CODE
                    sb.Append("       ," + entity.prefecture_id + Environment.NewLine);                                             // PREFECTURE_ID
                    sb.Append("       ," + entity.city_id + Environment.NewLine);                                                   // CITY_ID
                    sb.Append("       ," + entity.town_id + Environment.NewLine);                                                   // TOWN_ID
                    sb.Append("       ," + ExEscape.zRepStr(entity.adress_city) + Environment.NewLine);                             // ADRESS_CITY
                    sb.Append("       ," + ExEscape.zRepStr(entity.adress_town) + Environment.NewLine);                             // ADRESS_TOWN
                    sb.Append("       ," + ExEscape.zRepStr(entity.adress1) + Environment.NewLine);                                 // ADRESS1
                    sb.Append("       ," + ExEscape.zRepStr(entity.adress2) + Environment.NewLine);                                 // ADRESS2
                    sb.Append("       ," + ExEscape.zRepStr(entity.station_name) + Environment.NewLine);                            // STATION_NAME
                    sb.Append("       ," + ExEscape.zRepStr(entity.post_name) + Environment.NewLine);                               // POST_NAME
                    sb.Append("       ," + ExEscape.zRepStr(entity.person_name) + Environment.NewLine);                             // PERSON_NAME
                    sb.Append("       ," + entity.title_id + Environment.NewLine);                                                  // TITLE_ID
                    sb.Append("       ," + ExEscape.zRepStr(entity.title_name) + Environment.NewLine);                              // TITLE_NAME
                    sb.Append("       ," + ExEscape.zRepStr(entity.tel) + Environment.NewLine);                                     // TEL
                    sb.Append("       ," + ExEscape.zRepStr(entity.fax) + Environment.NewLine);                                     // FAX
                    sb.Append("       ," + ExEscape.zRepStr(entity.mail_adress) + Environment.NewLine);                             // MAIL_ADRESS
                    sb.Append("       ," + ExEscape.zRepStr(entity.mobile_tel) + Environment.NewLine);                              // MOBILE_TEL
                    sb.Append("       ," + ExEscape.zRepStr(entity.mobile_adress) + Environment.NewLine);                           // MOBILE_ADRESS
                    sb.Append("       ," + ExEscape.zRepStr(entity.url) + Environment.NewLine);                                     // URL
                    sb.Append("       ," + entity.divide_permission_id + Environment.NewLine);                                      // DIVIDE_PERMISSION_ID
                    sb.Append("       ," + ExEscape.zRepStr(entity.memo) + Environment.NewLine);                                    // MEMO
                    sb.Append("       ," + entity.display_division_id + Environment.NewLine);                                       // DISPLAY_FLG
                    sb.Append(CommonUtl.GetInsSQLCommonColums(CommonUtl.UpdKbn.Ins,
                                                              PG_NM,
                                                              "M_SUPPLIER",
                                                              ExCast.zCInt(personId),
                                                              _Id,
                                                              ipAdress,
                                                              userId));

                    #endregion

                    db.ExecuteSQL(sb.ToString(), false);
                }
                catch (Exception ex)
                {
                    db.ExRollbackTransaction();
                    CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateSupplier(Insert)", ex);
                    return(CLASS_NM + ".UpdateSupplier(Insert) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
                }
            }

            #endregion

            #region Update

            if (type == 0)
            {
                try
                {
                    #region SQL

                    sb.Length = 0;
                    sb.Append("UPDATE M_SUPPLIER " + 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("      ,DIVIDE_PERMISSION_ID = " + entity.divide_permission_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
                    sb.Append("   AND CUSTOMER_ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(CustomerId)) + Environment.NewLine);

                    #endregion

                    db.ExecuteSQL(sb.ToString(), false);
                }
                catch (Exception ex)
                {
                    db.ExRollbackTransaction();
                    CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateSupplier(Update)", ex);
                    return(CLASS_NM + ".UpdateSupplier(Insert) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
                }
            }

            #endregion

            #region Delete

            if (type == 2)
            {
                #region Exist Data

                try
                {
                    bool _ret = false;
                    _ret = DataExists.IsExistDataDouble(db, companyId, "", "T_ESTIMATE_H", "SUPPLIER_ID", ExCast.zNumZeroNothingFormat(Id), "CUSTOMER_ID", ExCast.zNumZeroNothingFormat(CustomerId), CommonUtl.geStrOrNumKbn.String);
                    if (_ret == true)
                    {
                        return("ID : " + Id + " は見積データの納入先に使用されている為、削除できません。");
                    }

                    _ret = DataExists.IsExistDataDouble(db, companyId, "", "T_ORDER_H", "SUPPLIER_ID", ExCast.zNumZeroNothingFormat(Id), "CUSTOMER_ID", ExCast.zNumZeroNothingFormat(CustomerId), CommonUtl.geStrOrNumKbn.String);
                    if (_ret == true)
                    {
                        return("ID : " + Id + " は受注データの納入先に使用されている為、削除できません。");
                    }

                    _ret = DataExists.IsExistDataDouble(db, companyId, "", "T_SALES_H", "SUPPLIER_ID", ExCast.zNumZeroNothingFormat(Id), "CUSTOMER_ID", ExCast.zNumZeroNothingFormat(CustomerId), CommonUtl.geStrOrNumKbn.String);
                    if (_ret == true)
                    {
                        return("ID : " + Id + " は売上データの納入先に使用されている為、削除できません。");
                    }
                }
                catch (Exception ex)
                {
                    db.ExRollbackTransaction();
                    CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateSupplier(Exist Data)", ex);
                    return(CLASS_NM + ".UpdateSupplier(Exist Data) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
                }

                #endregion

                #region Update

                try
                {
                    sb.Length = 0;
                    sb.Append("UPDATE M_SUPPLIER " + 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
                    sb.Append("   AND CUSTOMER_ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(CustomerId)) + Environment.NewLine);

                    db.ExecuteSQL(sb.ToString(), false);
                }
                catch (Exception ex)
                {
                    db.ExRollbackTransaction();
                    CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateSupplier(Delete)", ex);
                    return(CLASS_NM + ".UpdateSupplier(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 + ".UpdateSupplier(DelLockPg)", ex);
                    return(CLASS_NM + ".UpdateSupplier(DelLockPg) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
                }
            }

            #endregion

            #region CommitTransaction

            try
            {
                db.ExCommitTransaction();
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateSupplier(CommitTransaction)", ex);
                return(CLASS_NM + ".UpdateSupplier(CommitTransaction) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            #region Database Close

            try
            {
                db.DbClose();
            }
            catch (Exception ex)
            {
                db.ExRollbackTransaction();
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateSupplier(DbClose)", ex);
                return(CLASS_NM + ".UpdateSupplier(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 + ".UpdateSupplier(Add Evidence)", ex);
                return(CLASS_NM + ".UpdateSupplier(Add Evidence) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            #region Return

            if (type == 1 && (Id == "0" || Id == ""))
            {
                return("Auto Insert success : " + "ID : " + _Id.ToString() + "で登録しました。");
            }
            else
            {
                return("");
            }

            #endregion
        }
Пример #16
0
        public EntityCommodity GetCommodity(string random, string Id)
        {
            EntityCommodity 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 EntityCommodity();
                    entity.MESSAGE = _message;
                    return(entity);
                }
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".GetCommodity(認証処理)", ex);
                entity         = new EntityCommodity();
                entity.MESSAGE = CLASS_NM + ".GetCommodity : 認証処理に失敗しました。" + Environment.NewLine + ex.Message.ToString();;
                return(entity);
            }


            #endregion

            StringBuilder sb;
            DataTable     dt;
            ExMySQLData   db;

            try
            {
                db = ExSession.GetSessionDb(ExCast.zCInt(HttpContext.Current.Session[ExSession.USER_ID]),
                                            ExCast.zCStr(HttpContext.Current.Session[ExSession.SESSION_RANDOM_STR]));

                sb = new StringBuilder();

                #region SQL

                sb.Append("SELECT MT.* " + Environment.NewLine);
                sb.Append("      ,PU.NAME AS MAIN_PURCHASE_NAME " + Environment.NewLine);
                sb.Append("      ,NM1.DESCRIPTION AS UNIT_NAME " + Environment.NewLine);
                sb.Append("      ,NM2.DESCRIPTION AS TAXATION_DIVISION_NAME " + Environment.NewLine);
                sb.Append("      ,NM3.DESCRIPTION AS INVENTORY_MANAGEMENT_DIVISION_NAME " + Environment.NewLine);
                sb.Append("      ,NM4.DESCRIPTION AS INVENTORY_EVALUATION_NAME " + Environment.NewLine);
                sb.Append("      ,CL1.NAME AS GROUP1_NAME " + Environment.NewLine);
                sb.Append("      ,CL2.NAME AS GROUP2_NAME " + Environment.NewLine);
                sb.Append("      ,CL3.NAME AS GROUP3_NAME " + Environment.NewLine);
                sb.Append("      ,NM.DESCRIPTION AS DISPLAY_DIVISION_NAME " + Environment.NewLine);
                sb.Append("  FROM M_COMMODITY AS MT" + Environment.NewLine);

                #region Join

                // 仕入先
                sb.Append("  LEFT JOIN M_PURCHASE AS PU" + Environment.NewLine);
                sb.Append("    ON PU.DELETE_FLG = 0 " + Environment.NewLine);
                sb.Append("   AND PU.DISPLAY_FLG = 1 " + Environment.NewLine);
                sb.Append("   AND PU.COMPANY_ID = MT.COMPANY_ID" + Environment.NewLine);
                sb.Append("   AND PU.ID = MT.MAIN_PURCHASE_ID" + Environment.NewLine);

                // 単位
                sb.Append("  LEFT JOIN SYS_M_NAME AS NM1" + Environment.NewLine);
                sb.Append("    ON NM1.DELETE_FLG = 0 " + Environment.NewLine);
                sb.Append("   AND NM1.DISPLAY_FLG = 1 " + Environment.NewLine);
                sb.Append("   AND NM1.DIVISION_ID = " + (int)CommonUtl.geNameKbn.UNIT_ID + Environment.NewLine);
                sb.Append("   AND NM1.ID = MT.UNIT_ID" + Environment.NewLine);

                // 課税区分
                sb.Append("  LEFT JOIN SYS_M_NAME AS NM2" + Environment.NewLine);
                sb.Append("    ON NM2.DELETE_FLG = 0 " + Environment.NewLine);
                sb.Append("   AND NM2.DISPLAY_FLG = 1 " + Environment.NewLine);
                sb.Append("   AND NM2.DIVISION_ID = " + (int)CommonUtl.geNameKbn.TAX_DIVISION_ID + Environment.NewLine);
                sb.Append("   AND NM2.ID = MT.TAXATION_DIVISION_ID" + Environment.NewLine);

                // 在庫管理区分
                sb.Append("  LEFT JOIN SYS_M_NAME AS NM3" + Environment.NewLine);
                sb.Append("    ON NM3.DELETE_FLG = 0 " + Environment.NewLine);
                sb.Append("   AND NM3.DISPLAY_FLG = 1 " + Environment.NewLine);
                sb.Append("   AND NM3.DIVISION_ID = " + (int)CommonUtl.geNameKbn.INVENTORY_DIVISION_ID + Environment.NewLine);
                sb.Append("   AND NM3.ID = MT.INVENTORY_MANAGEMENT_DIVISION_ID" + Environment.NewLine);

                // 在庫評価
                sb.Append("  LEFT JOIN SYS_M_NAME AS NM4" + Environment.NewLine);
                sb.Append("    ON NM4.DELETE_FLG = 0 " + Environment.NewLine);
                sb.Append("   AND NM4.DISPLAY_FLG = 1 " + Environment.NewLine);
                sb.Append("   AND NM4.DIVISION_ID = " + (int)CommonUtl.geNameKbn.INVENTORY_DIVISION_ID + Environment.NewLine);
                sb.Append("   AND NM4.ID = MT.INVENTORY_EVALUATION_ID" + Environment.NewLine);

                // 商品分類1
                sb.Append("  LEFT JOIN M_CLASS AS CL1" + Environment.NewLine);
                sb.Append("    ON CL1.DELETE_FLG = 0 " + Environment.NewLine);
                sb.Append("   AND CL1.DISPLAY_FLG = 1 " + Environment.NewLine);
                sb.Append("   AND CL1.COMPANY_ID = MT.COMPANY_ID" + Environment.NewLine);
                sb.Append("   AND CL1.CLASS_DIVISION_ID = " + (int)CommonUtl.geMGroupKbn.CommodityGrouop1 + Environment.NewLine);
                sb.Append("   AND CL1.ID = MT.GROUP1_ID" + Environment.NewLine);

                // 商品分類2
                sb.Append("  LEFT JOIN M_CLASS AS CL2" + Environment.NewLine);
                sb.Append("    ON CL2.DELETE_FLG = 0 " + Environment.NewLine);
                sb.Append("   AND CL2.DISPLAY_FLG = 1 " + Environment.NewLine);
                sb.Append("   AND CL2.COMPANY_ID = MT.COMPANY_ID" + Environment.NewLine);
                sb.Append("   AND CL2.CLASS_DIVISION_ID = " + (int)CommonUtl.geMGroupKbn.CommodityGrouop2 + Environment.NewLine);
                sb.Append("   AND CL2.ID = MT.GROUP2_ID" + Environment.NewLine);

                // 商品分類3
                sb.Append("  LEFT JOIN M_CLASS AS CL3" + Environment.NewLine);
                sb.Append("    ON CL3.DELETE_FLG = 0 " + Environment.NewLine);
                sb.Append("   AND CL3.DISPLAY_FLG = 1 " + Environment.NewLine);
                sb.Append("   AND CL3.COMPANY_ID = MT.COMPANY_ID" + Environment.NewLine);
                sb.Append("   AND CL3.CLASS_DIVISION_ID = " + (int)CommonUtl.geMGroupKbn.CommodityGrouop3 + Environment.NewLine);
                sb.Append("   AND CL3.ID = MT.GROUP3_ID" + Environment.NewLine);

                // 表示区分
                sb.Append("  LEFT JOIN SYS_M_NAME AS NM" + Environment.NewLine);
                sb.Append("    ON NM.DELETE_FLG = 0 " + Environment.NewLine);
                sb.Append("   AND NM.DISPLAY_FLG = 1 " + Environment.NewLine);
                sb.Append("   AND NM.DIVISION_ID = " + (int)CommonUtl.geNameKbn.DISPLAY_DIVISION_ID + Environment.NewLine);
                sb.Append("   AND NM.ID = MT.DISPLAY_FLG" + Environment.NewLine);

                #endregion

                sb.Append(" WHERE MT.COMPANY_ID = " + companyId + Environment.NewLine);
                sb.Append("   AND MT.DELETE_FLG = 0 " + Environment.NewLine);
                sb.Append("   AND MT.SET_COMMODITY_FLG = 0 " + Environment.NewLine);
                sb.Append("   AND MT.ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(Id)) + Environment.NewLine);

                sb.Append(" ORDER BY MT.COMPANY_ID " + Environment.NewLine);
                sb.Append("         ,MT.ID " + Environment.NewLine);

                #endregion

                dt = db.GetDataTable(sb.ToString());

                if (dt.DefaultView.Count > 0)
                {
                    entity = new EntityCommodity();

                    // 排他制御
                    DataPgLock.geLovkFlg lockFlg;
                    string strErr = DataPgLock.SetLockPg(companyId, userId, PG_NM, ExCast.zNumZeroNothingFormat(Id), ipAdress, db, out lockFlg);
                    if (strErr != "")
                    {
                        entity.MESSAGE = CLASS_NM + ".GetCommodity : 排他制御(ロック情報取得)に失敗しました。" + Environment.NewLine + strErr;
                    }

                    #region Set Entity

                    entity.id   = ExCast.zCStr(dt.DefaultView[0]["ID"]);
                    entity.name = ExCast.zCStr(dt.DefaultView[0]["NAME"]);
                    entity.kana = ExCast.zCStr(dt.DefaultView[0]["KANA"]);

                    entity.unit_id = ExCast.zCInt(dt.DefaultView[0]["UNIT_ID"]);
                    entity.unit_nm = ExCast.zCStr(dt.DefaultView[0]["UNIT_NAME"]);

                    entity.enter_number         = ExCast.zCDbl(dt.DefaultView[0]["ENTER_NUMBER"]);
                    entity.number_decimal_digit = ExCast.zCInt(dt.DefaultView[0]["NUMBER_DECIMAL_DIGIT"]);
                    entity.unit_decimal_digit   = ExCast.zCInt(dt.DefaultView[0]["UNIT_DECIMAL_DIGIT"]);

                    entity.taxation_divition_id = ExCast.zCInt(dt.DefaultView[0]["TAXATION_DIVISION_ID"]);
                    entity.taxation_divition_nm = ExCast.zCStr(dt.DefaultView[0]["TAXATION_DIVISION_NAME"]);

                    entity.inventory_management_division_id = ExCast.zCInt(dt.DefaultView[0]["INVENTORY_MANAGEMENT_DIVISION_ID"]);
                    entity.inventory_management_division_nm = ExCast.zCStr(dt.DefaultView[0]["INVENTORY_MANAGEMENT_DIVISION_NAME"]);

                    entity.purchase_lot          = ExCast.zCDbl(dt.DefaultView[0]["PURCHASE_LOT"]);
                    entity.lead_time             = ExCast.zCInt(dt.DefaultView[0]["LEAD_TIME"]);
                    entity.just_inventory_number = ExCast.zCDbl(dt.DefaultView[0]["JUST_INVENTORY_NUMBER"]);
                    entity.inventory_number      = ExCast.zCDbl(dt.DefaultView[0]["INVENTORY_NUMBER"]);

                    entity.inventory_evaluation_id = ExCast.zCInt(dt.DefaultView[0]["INVENTORY_EVALUATION_ID"]);
                    entity.inventory_evaluation_nm = ExCast.zCStr(dt.DefaultView[0]["INVENTORY_EVALUATION_NAME"]);

                    entity.main_purchase_id = ExCast.zCStr(dt.DefaultView[0]["MAIN_PURCHASE_ID"]);
                    entity.main_purchase_nm = ExCast.zCStr(dt.DefaultView[0]["MAIN_PURCHASE_NAME"]);

                    entity.retail_price_skip_tax          = ExCast.zCDbl(dt.DefaultView[0]["RETAIL_PRICE_SKIP_TAX"]);
                    entity.retail_price_before_tax        = ExCast.zCDbl(dt.DefaultView[0]["RETAIL_PRICE_BEFORE_TAX"]);
                    entity.sales_unit_price_skip_tax      = ExCast.zCDbl(dt.DefaultView[0]["SALES_UNIT_PRICE_SKIP_TAX"]);
                    entity.sales_unit_price_before_tax    = ExCast.zCDbl(dt.DefaultView[0]["SALES_UNIT_PRICE_BEFORE_TAX"]);
                    entity.sales_cost_price_skip_tax      = ExCast.zCDbl(dt.DefaultView[0]["SALES_COST_PRICE_SKIP_TAX"]);
                    entity.sales_cost_price_before_tax    = ExCast.zCDbl(dt.DefaultView[0]["SALES_COST_PRICE_BEFORE_TAX"]);
                    entity.purchase_unit_price_skip_tax   = ExCast.zCDbl(dt.DefaultView[0]["PURCHASE_UNIT_PRICE_SKIP_TAX"]);
                    entity.purchase_unit_price_before_tax = ExCast.zCDbl(dt.DefaultView[0]["PURCHASE_UNIT_PRICE_BEFORE_TAX"]);

                    entity.group1_id = ExCast.zCStr(dt.DefaultView[0]["GROUP1_ID"]);
                    entity.group1_nm = ExCast.zCStr(dt.DefaultView[0]["GROUP1_NAME"]);

                    entity.group2_id = ExCast.zCStr(dt.DefaultView[0]["GROUP2_ID"]);
                    entity.group2_nm = ExCast.zCStr(dt.DefaultView[0]["GROUP2_NAME"]);

                    entity.group3_id = ExCast.zCStr(dt.DefaultView[0]["GROUP3_ID"]);
                    entity.group3_nm = ExCast.zCStr(dt.DefaultView[0]["GROUP3_NAME"]);

                    entity.display_division_id = ExCast.zCInt(dt.DefaultView[0]["DISPLAY_FLG"]);
                    entity.display_division_nm = ExCast.zCStr(dt.DefaultView[0]["DISPLAY_DIVISION_NAME"]);

                    entity.memo = ExCast.zCStr(dt.DefaultView[0]["MEMO"]);

                    entity.lock_flg = (int)lockFlg;

                    #endregion
                }
                else
                {
                    entity = null;
                }
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".GetCommodity", ex);
                entity         = new EntityCommodity();
                entity.MESSAGE = CLASS_NM + ".GetCommodity : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message.ToString();
            }
            finally
            {
                db = null;
            }

            svcPgEvidence.gAddEvidence(ExCast.zCInt(HttpContext.Current.Session[ExSession.EVIDENCE_SAVE_FLG]),
                                       companyId,
                                       userId,
                                       ipAdress,
                                       sessionString,
                                       PG_NM,
                                       DataPgEvidence.geOperationType.Select,
                                       "ID:" + Id.ToString());

            return(entity);
        }
Пример #17
0
        public EntitySupplier GetSupplier(string random, string CustomerId, string Id)
        {
            EntitySupplier 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 EntitySupplier();
                    entity.MESSAGE = _message;
                    return(entity);
                }
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".GetSupplier(認証処理)", ex);
                entity         = new EntitySupplier();
                entity.MESSAGE = CLASS_NM + ".GetSupplier : 認証処理に失敗しました。" + Environment.NewLine + ex.Message.ToString();;
                return(entity);
            }


            #endregion

            StringBuilder sb;
            DataTable     dt;
            ExMySQLData   db;

            try
            {
                db = ExSession.GetSessionDb(ExCast.zCInt(HttpContext.Current.Session[ExSession.USER_ID]),
                                            ExCast.zCStr(HttpContext.Current.Session[ExSession.SESSION_RANDOM_STR]));

                sb = new StringBuilder();

                #region SQL

                sb.Append("SELECT MT.* " + Environment.NewLine);
                sb.Append("      ,CM.NAME AS CUSTOMER_NAME " + Environment.NewLine);
                sb.Append("      ,NM1.DESCRIPTION AS DIVIDE_PERMISSION_NAME " + Environment.NewLine);
                sb.Append("      ,NM.DESCRIPTION AS DISPLAY_DIVISION_NAME " + Environment.NewLine);
                sb.Append("  FROM M_SUPPLIER AS MT" + Environment.NewLine);

                #region Join

                // 得意先
                sb.Append("  LEFT JOIN M_CUSTOMER AS CM" + Environment.NewLine);
                sb.Append("    ON CM.DELETE_FLG = 0 " + Environment.NewLine);
                sb.Append("   AND CM.DISPLAY_FLG = 1 " + Environment.NewLine);
                sb.Append("   AND CM.COMPANY_ID = MT.COMPANY_ID" + Environment.NewLine);
                sb.Append("   AND CM.ID = MT.CUSTOMER_ID" + Environment.NewLine);

                // 分納許可
                sb.Append("  LEFT JOIN SYS_M_NAME AS NM1" + Environment.NewLine);
                sb.Append("    ON NM1.DELETE_FLG = 0 " + Environment.NewLine);
                sb.Append("   AND NM1.DISPLAY_FLG = 1 " + Environment.NewLine);
                sb.Append("   AND NM1.DIVISION_ID = " + (int)CommonUtl.geNameKbn.DIVIDE_PERMISSION_ID + Environment.NewLine);
                sb.Append("   AND NM1.ID = MT.DIVIDE_PERMISSION_ID" + Environment.NewLine);

                // 表示区分
                sb.Append("  LEFT JOIN SYS_M_NAME AS NM" + Environment.NewLine);
                sb.Append("    ON NM.DELETE_FLG = 0 " + Environment.NewLine);
                sb.Append("   AND NM.DISPLAY_FLG = 1 " + Environment.NewLine);
                sb.Append("   AND NM.DIVISION_ID = " + (int)CommonUtl.geNameKbn.DISPLAY_DIVISION_ID + Environment.NewLine);
                sb.Append("   AND NM.ID = MT.DISPLAY_FLG" + Environment.NewLine);

                #endregion

                sb.Append(" WHERE MT.COMPANY_ID = " + companyId + Environment.NewLine);
                sb.Append("   AND MT.DELETE_FLG = 0 " + Environment.NewLine);
                sb.Append("   AND MT.CUSTOMER_ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(CustomerId)) + Environment.NewLine);
                sb.Append("   AND MT.ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(Id)) + Environment.NewLine);

                sb.Append(" ORDER BY MT.COMPANY_ID " + Environment.NewLine);
                sb.Append("         ,MT.ID " + Environment.NewLine);

                #endregion

                dt = db.GetDataTable(sb.ToString());

                if (dt.DefaultView.Count > 0)
                {
                    entity = new EntitySupplier();

                    // 排他制御
                    DataPgLock.geLovkFlg lockFlg;
                    string strErr = DataPgLock.SetLockPg(companyId, userId, PG_NM, ExCast.zNumZeroNothingFormat(CustomerId) + "-" + ExCast.zNumZeroNothingFormat(Id), ipAdress, db, out lockFlg);
                    if (strErr != "")
                    {
                        entity.MESSAGE = CLASS_NM + ".GetSupplier : 排他制御(ロック情報取得)に失敗しました。" + Environment.NewLine + strErr;
                    }

                    #region Set Entity

                    entity.id         = ExCast.zCStr(dt.DefaultView[0]["ID"]);
                    entity.name       = ExCast.zCStr(dt.DefaultView[0]["NAME"]);
                    entity.kana       = ExCast.zCStr(dt.DefaultView[0]["KANA"]);
                    entity.about_name = ExCast.zCStr(dt.DefaultView[0]["ABOUT_NAME"]);

                    string _zip = ExCast.zCStr(dt.DefaultView[0]["ZIP_CODE"]);
                    if (!string.IsNullOrEmpty(_zip) && ExCast.zCStr(_zip) != "0")
                    {
                        _zip = string.Format("{0:0000000}", ExCast.zCDbl(_zip));
                        entity.zip_code_from = _zip.Substring(0, 3);
                        entity.zip_code_to   = _zip.Substring(3, 4);
                    }
                    else
                    {
                        entity.zip_code_from = "";
                        entity.zip_code_to   = "";
                    }

                    entity.prefecture_id = ExCast.zCInt(dt.DefaultView[0]["PREFECTURE_ID"]);
                    entity.city_id       = ExCast.zCInt(dt.DefaultView[0]["CITY_ID"]);
                    entity.town_id       = ExCast.zCInt(dt.DefaultView[0]["TOWN_ID"]);
                    entity.adress_city   = ExCast.zCStr(dt.DefaultView[0]["ADRESS_CITY"]);
                    entity.adress_town   = ExCast.zCStr(dt.DefaultView[0]["ADRESS_TOWN"]);
                    entity.adress1       = ExCast.zCStr(dt.DefaultView[0]["ADRESS1"]);
                    entity.adress2       = ExCast.zCStr(dt.DefaultView[0]["ADRESS2"]);
                    entity.station_name  = ExCast.zCStr(dt.DefaultView[0]["STATION_NAME"]);
                    entity.post_name     = ExCast.zCStr(dt.DefaultView[0]["POST_NAME"]);
                    entity.person_name   = ExCast.zCStr(dt.DefaultView[0]["PERSON_NAME"]);
                    entity.title_id      = ExCast.zCInt(dt.DefaultView[0]["TITLE_ID"]);
                    entity.title_name    = ExCast.zCStr(dt.DefaultView[0]["TITLE_NAME"]);
                    entity.tel           = ExCast.zCStr(dt.DefaultView[0]["TEL"]);
                    entity.fax           = ExCast.zCStr(dt.DefaultView[0]["FAX"]);
                    entity.mail_adress   = ExCast.zCStr(dt.DefaultView[0]["MAIL_ADRESS"]);
                    entity.mobile_tel    = ExCast.zCStr(dt.DefaultView[0]["MOBILE_TEL"]);
                    entity.mobile_adress = ExCast.zCStr(dt.DefaultView[0]["MOBILE_ADRESS"]);
                    entity.url           = ExCast.zCStr(dt.DefaultView[0]["URL"]);

                    entity.customer_id = ExCast.zCStr(dt.DefaultView[0]["CUSTOMER_ID"]);
                    entity.customer_nm = ExCast.zCStr(dt.DefaultView[0]["CUSTOMER_NAME"]);

                    entity.divide_permission_id = ExCast.zCInt(dt.DefaultView[0]["DISPLAY_FLG"]);
                    entity.divide_permission_nm = ExCast.zCStr(dt.DefaultView[0]["DISPLAY_DIVISION_NAME"]);

                    entity.display_division_id = ExCast.zCInt(dt.DefaultView[0]["DISPLAY_FLG"]);
                    entity.display_division_nm = ExCast.zCStr(dt.DefaultView[0]["DISPLAY_DIVISION_NAME"]);

                    entity.lock_flg = (int)lockFlg;
                    entity.memo     = ExCast.zCStr(dt.DefaultView[0]["MEMO"]);

                    #endregion
                }
                else
                {
                    entity = null;
                }
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".GetSupplier", ex);
                entity         = new EntitySupplier();
                entity.MESSAGE = CLASS_NM + ".GetSupplier : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message.ToString();
            }
            finally
            {
                db = null;
            }

            svcPgEvidence.gAddEvidence(ExCast.zCInt(HttpContext.Current.Session[ExSession.EVIDENCE_SAVE_FLG]),
                                       companyId,
                                       userId,
                                       ipAdress,
                                       sessionString,
                                       PG_NM,
                                       DataPgEvidence.geOperationType.Select,
                                       "ID:" + Id.ToString());

            return(entity);
        }
Пример #18
0
        public static bool IsExistData(ExMySQLData db,
                                       string companyId,
                                       string groupId,
                                       string tblName,
                                       string col1Name,
                                       string col1Value,
                                       string col2Name,
                                       string col2Value,
                                       CommonUtl.geStrOrNumKbn col1Type)
        {
            StringBuilder sb;
            DataTable     dt;

            try
            {
                sb = new StringBuilder();

                #region SQL

                sb.Append("SELECT TBL.* " + Environment.NewLine);
                sb.Append("  FROM " + tblName + " AS TBL" + Environment.NewLine);

                sb.Append(" WHERE TBL.DELETE_FLG = 0 " + Environment.NewLine);
                if (companyId != "")
                {
                    sb.Append("   AND TBL.COMPANY_ID = " + companyId + Environment.NewLine);
                }
                if (groupId != "")
                {
                    sb.Append("   AND TBL.GROUP_ID = " + groupId + Environment.NewLine);
                }
                if (col1Type == CommonUtl.geStrOrNumKbn.String)
                {
                    sb.Append("   AND TBL." + col1Name + " = " + ExEscape.zRepStr(col1Value) + Environment.NewLine);
                    sb.Append("   AND TBL." + col2Name + " <> " + ExEscape.zRepStr(col2Value) + Environment.NewLine);
                }
                else
                {
                    sb.Append("   AND TBL." + col1Name + " = " + ExCast.zCDbl(col1Value) + Environment.NewLine);
                    sb.Append("   AND TBL." + col2Name + " <> " + ExCast.zCDbl(col2Value) + Environment.NewLine);
                }
                sb.Append(" LIMIT 0, 1" + Environment.NewLine);

                #endregion

                dt = db.GetDataTable(sb.ToString());

                if (dt.DefaultView.Count > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".IsExistData", ex);
                throw;
            }
            finally
            {
            }
        }
Пример #19
0
        public static void GetData(ExMySQLData db,
                                   string companyId,
                                   string groupId,
                                   string tblName,
                                   string col1Name,
                                   string col1Value,
                                   CommonUtl.geStrOrNumKbn col1Type,
                                   string get_col1Name,
                                   string get_col2Name,
                                   string get_col3Name,
                                   string get_col4Name,
                                   string get_col5Name,
                                   string get_another_col1Name,
                                   string get_another_col2Name,
                                   string get_another_col3Name,
                                   string get_another_col4Name,
                                   string get_another_col5Name,
                                   ref string get_col1Value,
                                   ref string get_col2Value,
                                   ref string get_col3Value,
                                   ref string get_col4Value,
                                   ref string get_col5Value)
        {
            StringBuilder sb;
            DataTable     dt;

            try
            {
                sb = new StringBuilder();

                #region SQL

                sb.Append("SELECT " + get_col1Name + Environment.NewLine);
                if (!string.IsNullOrEmpty(get_col2Name))
                {
                    sb.Append("      ," + get_col2Name + Environment.NewLine);
                }
                if (!string.IsNullOrEmpty(get_col3Name))
                {
                    sb.Append("      ," + get_col3Name + Environment.NewLine);
                }
                if (!string.IsNullOrEmpty(get_col4Name))
                {
                    sb.Append("      ," + get_col4Name + Environment.NewLine);
                }
                if (!string.IsNullOrEmpty(get_col5Name))
                {
                    sb.Append("      ," + get_col5Name + Environment.NewLine);
                }
                sb.Append("  FROM " + tblName + " AS TBL" + Environment.NewLine);

                sb.Append(" WHERE TBL.DELETE_FLG = 0 " + Environment.NewLine);
                if (companyId != "")
                {
                    sb.Append("   AND TBL.COMPANY_ID = " + companyId + Environment.NewLine);
                }
                if (groupId != "")
                {
                    sb.Append("   AND TBL.GROUP_ID = " + groupId + Environment.NewLine);
                }
                if (col1Type == CommonUtl.geStrOrNumKbn.String)
                {
                    sb.Append("   AND TBL." + col1Name + " = " + ExEscape.zRepStr(col1Value) + Environment.NewLine);
                }
                else
                {
                    sb.Append("   AND TBL." + col1Name + " = " + ExCast.zCDbl(col1Value) + Environment.NewLine);
                }
                sb.Append(" LIMIT 0, 1" + Environment.NewLine);

                #endregion

                dt = db.GetDataTable(sb.ToString());

                if (dt.DefaultView.Count > 0)
                {
                    get_col1Value = ExCast.zCStr(dt.DefaultView[0][get_another_col1Name]);
                    if (!string.IsNullOrEmpty(get_col2Name))
                    {
                        get_col2Value = ExCast.zCStr(dt.DefaultView[0][get_another_col2Name]);
                    }
                    if (!string.IsNullOrEmpty(get_col3Name))
                    {
                        get_col3Value = ExCast.zCStr(dt.DefaultView[0][get_another_col3Name]);
                    }
                    if (!string.IsNullOrEmpty(get_col4Name))
                    {
                        get_col4Value = ExCast.zCStr(dt.DefaultView[0][get_another_col4Name]);
                    }
                    if (!string.IsNullOrEmpty(get_col5Name))
                    {
                        get_col5Value = ExCast.zCStr(dt.DefaultView[0][get_another_col5Name]);
                    }
                }
                else
                {
                    get_col1Value = "";
                    get_col2Value = "";
                    get_col3Value = "";
                    get_col4Value = "";
                    get_col5Value = "";
                }
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".GetData", ex);
                throw;
            }
            finally
            {
            }
        }
Пример #20
0
        public static string DelLockPg(string companyId,
                                       string userId,
                                       string pgId,
                                       string lockId,
                                       string ipAdress,
                                       bool commitFlg,
                                       ExMySQLData _db)
        {
            StringBuilder sb;
            DataTable     dt;
            ExMySQLData   db = null;

            string ret = "err";

            #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 + ".DelLockPg(DbOpen)", ex);
                return(CLASS_NM + ".DelLockPg(DbOpen) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            #region BeginTransaction

            try
            {
                db.ExBeginTransaction();
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".DelLockPg", ex);
                return(CLASS_NM + ".DelLockPg(BeginTransaction) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            try
            {
                sb        = new StringBuilder();
                sb.Length = 0;

                sb.Append("DELETE FROM S_PG_LOCK " + Environment.NewLine);
                sb.Append(" WHERE COMPANY_ID = " + companyId + Environment.NewLine);
                sb.Append("   AND USER_ID = " + userId + Environment.NewLine);
                if (pgId != "")
                {
                    sb.Append("   AND PG_ID = " + ExEscape.zRepStr(pgId) + Environment.NewLine);
                }
                if (lockId != "")
                {
                    sb.Append("   AND LOCK_ID = " + ExEscape.zRepStr(lockId) + Environment.NewLine);
                }

                db.ExecuteSQL(sb.ToString(), false);

                ret = "";
            }
            catch (Exception ex)
            {
                db.ExRollbackTransaction();
                ret = CLASS_NM + ".DelLockPg : " + ex.Message;
                CommonUtl.ExLogger.Error(CLASS_NM + ".DelLockPg", ex);
            }

            #region CommitTransaction

            try
            {
                if (commitFlg == true)
                {
                    db.ExCommitTransaction();
                }
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".DelLockPg(CommitTransaction)", ex);
                return(CLASS_NM + ".DelLockPg(CommitTransaction) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            #region Database Close

            try
            {
                db.DbClose();
            }
            catch (Exception ex)
            {
                db.ExRollbackTransaction();
                CommonUtl.ExLogger.Error(CLASS_NM + ".DelLockPg(DbClose)", ex);
                return(CLASS_NM + ".DelLockPg(DbClose) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }
            finally
            {
                db = null;
            }

            #endregion

            return(ret);
        }
Пример #21
0
        public static string SetLockPg(string companyId,
                                       string userId,
                                       string pgId,
                                       string lockId,
                                       string ipAdress,
                                       ExMySQLData _db,
                                       out geLovkFlg lockFlg)
        {
            StringBuilder sb;
            DataTable     dt;
            ExMySQLData   db = null;

            string ret = "err";

            lockFlg = geLovkFlg.UnLock;

            if (CommonUtl.gDemoKbn == 1)
            {
                lockFlg = DataPgLock.geLovkFlg.UnLock;
                return("");
            }

            #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 + ".SetLockPg(DbOpen)", ex);
                return(CLASS_NM + ".SetLockPg(DbOpen) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            #region BeginTransaction

            try
            {
                db.ExBeginTransaction();
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".SetLockPg(BeginTransaction)", ex);
                return(CLASS_NM + ".SetLockPg(BeginTransaction) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            try
            {
                sb        = new StringBuilder();
                sb.Length = 0;

                ret = DataPgLock.DelLockPg(companyId, userId, pgId, "", ipAdress, false, db);
                if (ret != "")
                {
                    return(ret);
                }

                #region SQL

                // 存在確認
                sb.Append("SELECT TBL.* " + Environment.NewLine);
                sb.Append("  FROM S_PG_LOCK AS TBL" + Environment.NewLine);
                sb.Append(" WHERE TBL.COMPANY_ID = " + companyId + Environment.NewLine);
                sb.Append("   AND TBL.PG_ID = " + ExEscape.zRepStr(pgId) + Environment.NewLine);
                sb.Append("   AND TBL.LOCK_ID = " + ExEscape.zRepStr(lockId) + Environment.NewLine);
                sb.Append(" LIMIT 0, 1" + Environment.NewLine);
                sb.Append(" FOR UPDATE");

                #endregion

                dt = db.GetDataTable(sb.ToString());

                if (dt.DefaultView.Count > 0)
                {
                    if (!string.IsNullOrEmpty(userId))
                    {
                        if (userId != ExCast.zCStr(dt.DefaultView[0]["USER_ID"]))
                        {
                            lockFlg = DataPgLock.geLovkFlg.Lock;
                        }
                        else
                        {
                            lockFlg = DataPgLock.geLovkFlg.UnLock;
                        }
                    }
                    else
                    {
                        lockFlg = DataPgLock.geLovkFlg.Lock;
                    }
                }
                else
                {
                    #region SQL

                    sb.Length = 0;
                    sb.Append("INSERT INTO S_PG_LOCK " + Environment.NewLine);
                    sb.Append("       ( COMPANY_ID" + Environment.NewLine);
                    sb.Append("       , USER_ID" + Environment.NewLine);
                    sb.Append("       , PG_ID" + Environment.NewLine);
                    sb.Append("       , LOCK_ID" + 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("VALUES (" + Environment.NewLine);
                    sb.Append("        " + companyId + Environment.NewLine);                // COMPANY_ID
                    sb.Append("       ," + userId + Environment.NewLine);                   // USER_ID
                    sb.Append("       ," + ExEscape.zRepStr(pgId) + Environment.NewLine);   // PG_ID
                    sb.Append("       ," + ExEscape.zRepStr(lockId) + Environment.NewLine); // LOCK_ID
                    sb.Append(CommonUtl.GetInsSQLCommonColums(CommonUtl.UpdKbn.Ins, "pgId", "S_PG_LOCK", 9999, "0", ipAdress, userId));
                    sb.Append(")" + Environment.NewLine);

                    #endregion

                    db.ExecuteSQL(sb.ToString(), false);

                    lockFlg = DataPgLock.geLovkFlg.UnLock;
                }

                ret = "";
            }
            catch (Exception ex)
            {
                db.ExRollbackTransaction();
                ret = CLASS_NM + ".SetLockPg(Insert) : " + ex.Message;
                CommonUtl.ExLogger.Error(CLASS_NM + ".SetLockPg(Insert)", ex);
                throw;
            }

            #region CommitTransaction

            try
            {
                db.ExCommitTransaction();
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".SetLockPg(CommitTransaction)", ex);
                return(CLASS_NM + ".SetLockPg(CommitTransaction) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            #region Database Close

            try
            {
                db.DbClose();
            }
            catch (Exception ex)
            {
                db.ExRollbackTransaction();
                CommonUtl.ExLogger.Error(CLASS_NM + ".SetLockPg(DbClose)", ex);
                return(CLASS_NM + ".SetLockPg(DbClose) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }
            finally
            {
                db = null;
            }

            #endregion

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

            // 受注日
            if (this.datOrderYmd_F.Text.Trim() != "")
            {
                strWhrer        += "   AND T.ORDER_YMD >= " + ExEscape.zRepStr(this.datOrderYmd_F.Text.Trim()) + Environment.NewLine;
                strWhrerString1 += "[受注日 " + ExEscape.zRepStrNoQuota(this.datOrderYmd_F.Text.Trim()) + "~";
            }
            else
            {
                strWhrerString1 += "[受注日 未指定~";
            }
            if (this.datOrderYmd_T.Text.Trim() != "")
            {
                strWhrer        += "   AND T.ORDER_YMD <= " + ExEscape.zRepStr(this.datOrderYmd_T.Text.Trim()) + Environment.NewLine;
                strWhrerString1 += ExEscape.zRepStrNoQuota(this.datOrderYmd_T.Text.Trim());
            }
            else
            {
                strWhrerString1 += "未指定";
            }

            // 受注番号
            if (this.utlOrderNo_F.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.NO >= " + ExCast.zCLng(this.utlOrderNo_F.txtID.Text.Trim()) + Environment.NewLine;
                strWhrerString1 += "] [受注番号 " + this.utlOrderNo_F.txtID.Text.Trim() + "~";
            }
            else
            {
                strWhrerString1 += "] [受注番号 未指定~";
            }
            if (this.utlOrderNo_T.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.NO <= " + ExCast.zCLng(this.utlOrderNo_T.txtID.Text.Trim()) + Environment.NewLine;
                strWhrerString1 += this.utlOrderNo_T.txtID.Text.Trim();
            }
            else
            {
                strWhrerString1 += "未指定";
            }

            // 納入指定日
            if (this.datNokiYmd_F.Text.Trim() != "")
            {
                strWhrer        += "   AND T.SUPPLY_YMD >= " + ExEscape.zRepStr(this.datNokiYmd_F.Text.Trim()) + Environment.NewLine;
                strWhrerString1 += "] [納入指定日 " + ExEscape.zRepStrNoQuota(this.datNokiYmd_F.Text.Trim()) + "~";
            }
            else
            {
                strWhrerString1 += "] [納入指定日 未指定~";
            }
            if (this.datNokiYmd_T.Text.Trim() != "")
            {
                strWhrer        += "   AND T.SUPPLY_YMD <= " + ExEscape.zRepStr(this.datNokiYmd_T.Text.Trim()) + Environment.NewLine;
                strWhrerString1 += ExEscape.zRepStrNoQuota(this.datNokiYmd_T.Text.Trim());
            }
            else
            {
                strWhrerString1 += "未指定";
            }

            // 見積番号
            if (this.utlEstimateNo_F.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.ESTIMATENO >= " + ExCast.zCLng(this.utlEstimateNo_F.txtID.Text.Trim()) + Environment.NewLine;
                strWhrerString1 += "] [見積番号 " + this.utlEstimateNo_F.txtID.Text.Trim() + "~";
            }
            else
            {
                strWhrerString1 += "] [見積番号 未指定~";
            }
            if (this.utlEstimateNo_T.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.ESTIMATENO <= " + ExCast.zCLng(this.utlEstimateNo_T.txtID.Text.Trim()) + Environment.NewLine;
                strWhrerString1 += this.utlEstimateNo_T.txtID.Text.Trim() + "]";
            }
            else
            {
                strWhrerString1 += "未指定]";
            }

            // 入力担当者
            if (this.utlPerson_F.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.PERSON_ID >= " + ExCast.zCLng(this.utlPerson_F.txtID.Text.Trim()) + Environment.NewLine;
                strWhrerString2 += "[入力担当者 " + this.utlPerson_F.txtID.Text.Trim() + ":" + ExEscape.zRepStrNoQuota(this.utlPerson_F.txtNm.Text.Trim()) + "~";
            }
            else
            {
                strWhrerString2 += "[入力担当者 未指定~";
            }
            if (this.utlPerson_T.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.PERSON_ID <= " + ExCast.zCLng(this.utlPerson_T.txtID.Text.Trim()) + Environment.NewLine;
                strWhrerString2 += this.utlPerson_T.txtID.Text.Trim() + ":" + ExEscape.zRepStrNoQuota(this.utlPerson_T.txtNm.Text.Trim());
            }
            else
            {
                strWhrerString2 += "未指定";
            }

            // 得意先
            if (this.utlCustomer.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.CUSTOMER_ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(this.utlCustomer.txtID.Text.Trim())) + Environment.NewLine;
                strWhrerString2 += "] [得意先 " + ExEscape.zRepStrNoQuota(this.utlCustomer.txtID.Text.Trim()) + ":" + ExEscape.zRepStrNoQuota(this.utlCustomer.txtNm.Text.Trim());
            }
            else
            {
                strWhrerString2 += "] [得意先 未指定";
            }

            // 納入先
            if (this.utlSupply.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.SUPPLIER_ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(this.utlSupply.txtID.Text.Trim())) + Environment.NewLine;
                strWhrerString2 += "] [納入先 " + ExEscape.zRepStrNoQuota(this.utlSupply.txtID.Text.Trim()) + ":" + ExEscape.zRepStrNoQuota(this.utlSupply.txtNm.Text.Trim());
            }
            else
            {
                strWhrerString2 += "] [納入先 未指定";
            }

            // 商品コード
            if (this.utlCommodity.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND EXISTS (SELECT 1 " + Environment.NewLine;
                strWhrer        += "                 FROM T_ORDER_D AS OOD " + Environment.NewLine;
                strWhrer        += "                WHERE OOD.COMPANY_ID = T.COMPANY_ID " + Environment.NewLine;
                strWhrer        += "                  AND OOD.GROUP_ID = T.GROUP_ID " + Environment.NewLine;
                strWhrer        += "                  AND OOD.ORDER_ID = T.ID " + Environment.NewLine;
                strWhrer        += "                  AND OOD.COMMODITY_ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(this.utlCommodity.txtID.Text.Trim())) + Environment.NewLine;
                strWhrer        += "                  ) " + Environment.NewLine;
                strWhrerString2 += "] [商品コード " + ExEscape.zRepStrNoQuota(this.utlCommodity.txtID.Text.Trim()) + ":" + ExEscape.zRepStrNoQuota(this.utlCommodity.txtNm.Text.Trim()) + "]";
            }
            else
            {
                strWhrerString2 += "] [商品コード 未指定" + "]";
            }

            // 取引区分
            string _buf = "";

            if (this.chkKake.IsChecked == true)
            {
                // 掛売上
                strWhrer += "   AND (T.BUSINESS_DIVISION_ID = 1";
                _buf     += " [取引区分 掛売上";
            }
            if (this.chkCash.IsChecked == true)
            {
                // 現金
                if (_buf == "")
                {
                    strWhrer += "   AND (T.BUSINESS_DIVISION_ID = 2";
                    _buf     += " [取引区分 現金";
                }
                else
                {
                    strWhrer += " OR T.BUSINESS_DIVISION_ID = 2";
                    _buf     += " 現金";
                }
            }
            if (_buf == "")
            {
                _buf += " [取引区分 指定無し]";
            }
            else
            {
                strWhrer += ")" + Environment.NewLine;
                _buf     += "]";
            }
            strWhrerString2 += _buf;
            _buf             = "";

            // 完納区分
            if (this.chkUnDelivary.IsChecked == true)
            {
                // 未納
                strWhrer += "   AND (EXISTS (SELECT 1 " + Environment.NewLine;
                strWhrer += "                  FROM T_ORDER_D AS OOD " + Environment.NewLine;
                strWhrer += "                 WHERE OOD.COMPANY_ID = T.COMPANY_ID " + Environment.NewLine;
                strWhrer += "                   AND OOD.GROUP_ID = T.GROUP_ID " + Environment.NewLine;
                strWhrer += "                   AND OOD.ORDER_ID = T.ID " + Environment.NewLine;
                strWhrer += "                   AND OOD.DELIVER_DIVISION_ID = 1 " + Environment.NewLine;
                strWhrer += "                   ) " + Environment.NewLine;
                _buf     += " [完納区分 未納";
            }
            if (this.chkPartDelivary.IsChecked == true)
            {
                // 一部納品
                if (_buf == "")
                {
                    strWhrer += "   AND (EXISTS (SELECT 1 " + Environment.NewLine;
                    strWhrer += "                  FROM T_ORDER_D AS OOD " + Environment.NewLine;
                    strWhrer += "                 WHERE OOD.COMPANY_ID = T.COMPANY_ID " + Environment.NewLine;
                    strWhrer += "                   AND OOD.GROUP_ID = T.GROUP_ID " + Environment.NewLine;
                    strWhrer += "                   AND OOD.ORDER_ID = T.ID " + Environment.NewLine;
                    strWhrer += "                   AND OOD.DELIVER_DIVISION_ID = 2 " + Environment.NewLine;
                    strWhrer += "                   ) " + Environment.NewLine;
                    _buf     += " [完納区分 分納";
                }
                else
                {
                    strWhrer += "OR EXISTS (SELECT 1 " + Environment.NewLine;
                    strWhrer += "             FROM T_ORDER_D AS OOD " + Environment.NewLine;
                    strWhrer += "            WHERE OOD.COMPANY_ID = T.COMPANY_ID " + Environment.NewLine;
                    strWhrer += "              AND OOD.GROUP_ID = T.GROUP_ID " + Environment.NewLine;
                    strWhrer += "              AND OOD.ORDER_ID = T.ID " + Environment.NewLine;
                    strWhrer += "              AND OOD.DELIVER_DIVISION_ID = 2 " + Environment.NewLine;
                    strWhrer += "              ) " + Environment.NewLine;
                    _buf     += " 分納";
                }
            }
            if (this.chkFullDelivary.IsChecked == true)
            {
                // 完納
                if (_buf == "")
                {
                    strWhrer += "   AND (EXISTS (SELECT 1 " + Environment.NewLine;
                    strWhrer += "                  FROM T_ORDER_D AS OOD " + Environment.NewLine;
                    strWhrer += "                 WHERE OOD.COMPANY_ID = T.COMPANY_ID " + Environment.NewLine;
                    strWhrer += "                   AND OOD.GROUP_ID = T.GROUP_ID " + Environment.NewLine;
                    strWhrer += "                   AND OOD.ORDER_ID = T.ID " + Environment.NewLine;
                    strWhrer += "                   AND OOD.DELIVER_DIVISION_ID = 3 " + Environment.NewLine;
                    strWhrer += "                   ) " + Environment.NewLine;
                    _buf     += " [完納区分 完納";
                }
                else
                {
                    strWhrer += "OR EXISTS (SELECT 1 " + Environment.NewLine;
                    strWhrer += "             FROM T_ORDER_D AS OOD " + Environment.NewLine;
                    strWhrer += "            WHERE OOD.COMPANY_ID = T.COMPANY_ID " + Environment.NewLine;
                    strWhrer += "              AND OOD.GROUP_ID = T.GROUP_ID " + Environment.NewLine;
                    strWhrer += "              AND OOD.ORDER_ID = T.ID " + Environment.NewLine;
                    strWhrer += "              AND OOD.DELIVER_DIVISION_ID = 3 " + Environment.NewLine;
                    strWhrer += "              ) " + Environment.NewLine;
                    _buf     += " 完納";
                }
            }
            if (this.chkTorikeshi.IsChecked == true)
            {
                // 取消
                if (_buf == "")
                {
                    strWhrer += "   AND (EXISTS (SELECT 1 " + Environment.NewLine;
                    strWhrer += "                  FROM T_ORDER_D AS OOD " + Environment.NewLine;
                    strWhrer += "                 WHERE OOD.COMPANY_ID = T.COMPANY_ID " + Environment.NewLine;
                    strWhrer += "                   AND OOD.GROUP_ID = T.GROUP_ID " + Environment.NewLine;
                    strWhrer += "                   AND OOD.ORDER_ID = T.ID " + Environment.NewLine;
                    strWhrer += "                   AND OOD.DELIVER_DIVISION_ID = 4 " + Environment.NewLine;
                    strWhrer += "                   ) " + Environment.NewLine;
                    _buf     += " [完納区分 取消";
                }
                else
                {
                    strWhrer += "OR EXISTS (SELECT 1 " + Environment.NewLine;
                    strWhrer += "             FROM T_ORDER_D AS OOD " + Environment.NewLine;
                    strWhrer += "            WHERE OOD.COMPANY_ID = T.COMPANY_ID " + Environment.NewLine;
                    strWhrer += "              AND OOD.GROUP_ID = T.GROUP_ID " + Environment.NewLine;
                    strWhrer += "              AND OOD.ORDER_ID = T.ID " + Environment.NewLine;
                    strWhrer += "              AND OOD.DELIVER_DIVISION_ID = 4 " + Environment.NewLine;
                    strWhrer += "              ) " + Environment.NewLine;
                    _buf     += " 取消";
                }
            }
            if (_buf == "")
            {
                _buf += " [完納区分 指定無し]";
            }
            else
            {
                strWhrer += ")" + Environment.NewLine;
                _buf     += "]";
            }
            strWhrerString2 += _buf;

            _buf = "";

            // 注文請書発行
            if (this.borPrint.Visibility == System.Windows.Visibility.Visible)
            {
                if (this.chkPrintNo.IsChecked == true)
                {
                    strWhrer += "   AND (T.ORDER_PRINT_FLG = 0";
                    _buf     += " [注文請書発行 発行未";
                }
                if (this.chkPrintYes.IsChecked == true)
                {
                    if (_buf == "")
                    {
                        strWhrer += "   AND (T.ORDER_PRINT_FLG = 1";
                        _buf     += " [注文請書発行 発行済";
                    }
                    else
                    {
                        strWhrer += " OR T.ORDER_PRINT_FLG = 1";
                        _buf     += " 発行済";
                    }
                }
                if (_buf == "")
                {
                    _buf += " [注文請書発行 指定無し]";
                }
                else
                {
                    strWhrer += ")" + Environment.NewLine;
                    _buf     += "]";
                }
                strWhrerString2 += _buf;
                _buf             = "";
            }

            UpdPrintNo = "";
            if (this.ProcKbn == eProcKbn.Report)
            {
                strWhrer        = "";
                strWhrerString1 = "";
                strWhrerString2 = "";

                string _no = "";
                for (int i = 0; i <= lst.Count - 1; i++)
                {
                    if (lst[i].exec_flg == true)
                    {
                        if (string.IsNullOrEmpty(_no))
                        {
                            _no += ExCast.zCLng(this.lst[i].no).ToString();
                        }
                        else
                        {
                            _no += "<<@escape_comma@>>" + ExCast.zCLng(this.lst[i].no).ToString();
                        }
                    }
                }
                if (!string.IsNullOrEmpty(_no))
                {
                    UpdPrintNo = _no;
                    strWhrer  += "   AND T.NO IN (" + _no + ")" + Environment.NewLine;
                }
            }

            return(strWhrer + "WhereString =>" + strWhrerString1 + ";" + strWhrerString2);
        }
Пример #23
0
        public string UpdateAuthority(string random, List <EntityAuthority> entity, int _user_id)
        {
            #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(Authority_NM + ".UpdateAuthority(認証処理)", ex);
                return(Authority_NM + ".UpdateAuthority : 認証処理に失敗しました。" + Environment.NewLine + ex.Message.ToString());
            }

            #endregion

            #region Field

            StringBuilder sb = new StringBuilder();
            DataTable     dt;
            ExMySQLData   db = null;
            string        str_authority_kbn = "";

            #endregion

            #region 権限不可ユーザ0件チェック

            try
            {
                bool _flg = true;
                for (int i = 0; i <= entity.Count - 1; i++)
                {
                    if (entity[i].authority_kbn < 2 && entity[i].pg_id == "AuthorityMst")
                    {
                        _flg = false;
                    }
                }
                if (_flg == false)
                {
                    ExMySQLData dbSelect = ExSession.GetSessionDb(ExCast.zCInt(HttpContext.Current.Session[ExSession.USER_ID]),
                                                                  ExCast.zCStr(HttpContext.Current.Session[ExSession.SESSION_RANDOM_STR]));

                    #region SQL

                    sb.Append("SELECT MT.USER_ID " + Environment.NewLine);
                    sb.Append("  FROM M_AUTHORITY AS MT" + Environment.NewLine);

                    #region Join

                    sb.Append("  INNER JOIN SYS_M_USER AS UR" + Environment.NewLine);
                    sb.Append("    ON UR.DELETE_FLG = 0 " + Environment.NewLine);
                    sb.Append("   AND UR.DISPLAY_FLG = 1 " + Environment.NewLine);
                    sb.Append("   AND UR.COMPANY_ID = " + companyId + Environment.NewLine);
                    sb.Append("   AND UR.ID = MT.USER_ID " + Environment.NewLine);
                    sb.Append("   AND UR.ID <> " + _user_id + Environment.NewLine);

                    #endregion

                    sb.Append(" WHERE MT.DELETE_FLG = 0 " + Environment.NewLine);
                    sb.Append("   AND MT.PG_ID = 'AuthorityMst' " + Environment.NewLine);
                    sb.Append("   AND MT.AUTHORITY_KBN >= 2 " + Environment.NewLine);

                    #endregion

                    dt = dbSelect.GetDataTable(sb.ToString());

                    if (dt.DefaultView.Count == 0)
                    {
                        return("権限を付加できるユーザが0件になる為、更新できません。");
                    }

                    dbSelect = null;
                }
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(Authority_NM + ".UpdateAuthority(Check)", ex);
                return(Authority_NM + ".UpdateAuthority(Check) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #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(Authority_NM + ".UpdateAuthority(DbOpen)", ex);
                return(Authority_NM + ".UpdateAuthority(DbOpen) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            #region BeginTransaction

            try
            {
                db.ExBeginTransaction();
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(Authority_NM + ".UpdateAuthority(BeginTransaction)", ex);
                return(Authority_NM + ".UpdateAuthority(BeginTransaction) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            #region Delete

            try
            {
                #region Delete SQL

                sb.Length = 0;
                sb.Append("DELETE FROM M_AUTHORITY " + Environment.NewLine);
                sb.Append(" WHERE USER_ID = " + _user_id + Environment.NewLine);

                #endregion

                db.ExecuteSQL(sb.ToString(), false);
            }
            catch (Exception ex)
            {
                db.ExRollbackTransaction();
                CommonUtl.ExLogger.Error(Authority_NM + ".UpdateAuthority(Delete)", ex);
                return(Authority_NM + ".UpdateAuthority(Delete) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            #region Insert

            try
            {
                for (int i = 0; i <= entity.Count - 1; i++)
                {
                    #region Insert SQL

                    sb.Length = 0;
                    sb.Append("INSERT INTO M_AUTHORITY " + Environment.NewLine);
                    sb.Append("       ( USER_ID" + Environment.NewLine);
                    sb.Append("       , PG_ID" + Environment.NewLine);
                    sb.Append("       , AUTHORITY_KBN" + Environment.NewLine);
                    sb.Append("       , MEMO" + Environment.NewLine);
                    sb.Append("       , DISPLAY_INDEX" + 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  " + _user_id + Environment.NewLine);                                 // USER_ID
                    sb.Append("       ," + ExEscape.zRepStr(entity[i].pg_id) + Environment.NewLine);        // PG_ID
                    sb.Append("       ," + entity[i].authority_kbn + Environment.NewLine);                  // AUTHORITY_KBN
                    sb.Append("       ," + ExEscape.zRepStr(entity[i].memo) + Environment.NewLine);         // MEMO
                    sb.Append("       ," + entity[i].display_index + Environment.NewLine);                  // DISPLAY_INDEX
                    sb.Append("       ,1" + Environment.NewLine);                                           // DISPLAY_FLG
                    sb.Append(CommonUtl.GetInsSQLCommonColums(CommonUtl.UpdKbn.Ins,
                                                              PG_NM,
                                                              "M_AUTHORITY",
                                                              ExCast.zCInt(personId),
                                                              _user_id.ToString(),
                                                              ipAdress,
                                                              userId));

                    #endregion

                    db.ExecuteSQL(sb.ToString(), false);

                    if (entity[i].pg_id == "ReportTotal" && _user_id == ExCast.zCInt(userId))
                    {
                        str_authority_kbn = ExCast.zCStr(entity[i].authority_kbn);
                        HttpContext.Current.Session[ExSession.REPORT_TOTAL_AUTHORITY_KBN] = entity[i].authority_kbn;
                    }
                }
            }
            catch (Exception ex)
            {
                db.ExRollbackTransaction();
                CommonUtl.ExLogger.Error(Authority_NM + ".UpdateAuthority(Insert)", ex);
                return(Authority_NM + ".UpdateAuthority(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(Authority_NM + ".UpdateAuthority(DelLockPg)", ex);
                return(Authority_NM + ".UpdateAuthority(DelLockPg) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            #region CommitTransaction

            try
            {
                db.ExCommitTransaction();
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(Authority_NM + ".UpdateAuthority(CommitTransaction)", ex);
                return(Authority_NM + ".UpdateAuthority(CommitTransaction) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            #region Database Close

            try
            {
                db.DbClose();
            }
            catch (Exception ex)
            {
                db.ExRollbackTransaction();
                CommonUtl.ExLogger.Error(Authority_NM + ".UpdateAuthority(DbClose)", ex);
                return(Authority_NM + ".UpdateAuthority(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(Authority_NM + ".UpdateAuthority(Add Evidence)", ex);
                return(Authority_NM + ".UpdateAuthority(Add Evidence) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            if (str_authority_kbn != "")
            {
                HttpContext.Current.Session[ExSession.REPORT_TOTAL_AUTHORITY_KBN] = ExCast.zCInt(str_authority_kbn);
            }

            return("");
        }
Пример #24
0
        public string UpdateInquiry(string random, int type, long no, EntityInquiry 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 + ".UpdateInquiry(認証処理)", ex);
                return(CLASS_NM + ".UpdateInquiry : 認証処理に失敗しました。" + Environment.NewLine + ex.Message.ToString());
            }

            #endregion

            #region Field

            StringBuilder sb = new StringBuilder();
            DataTable     dt;
            ExMySQLData   sys_db = null;
            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
            {
                sys_db = new ExMySQLData();
                sys_db.DbOpen();
                db = new ExMySQLData(ExCast.zCStr(HttpContext.Current.Session[ExSession.DB_CONNECTION_STR]));
                db.DbOpen();
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateInquiry(DbOpen)", ex);
                return(CLASS_NM + ".UpdateInquiry(DbOpen) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            #region BeginTransaction

            try
            {
                sys_db.ExBeginTransaction();
                if (CommonUtl.gSysDbKbn == 0)
                {
                    db.ExBeginTransaction();
                }
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateInquiry(BeginTransaction)", ex);
                return(CLASS_NM + ".UpdateInquiry(BeginTransaction) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            #region Get Max ID

            if (type == 1)
            {
                try
                {
                    DataMaxId.GetMaxId(sys_db,
                                       "SYS_T_INQUIRY_H",
                                       "NO",
                                       out _no);

                    if (_no == "")
                    {
                        return("サポートNOの取得に失敗しました。");
                    }
                }
                catch (Exception ex)
                {
                    sys_db.ExRollbackTransaction();
                    if (CommonUtl.gSysDbKbn == 0)
                    {
                        db.ExRollbackTransaction();
                    }
                    CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateInquiry(GetMaxId)", ex);
                    return(CLASS_NM + ".UpdateInquiry(GetMaxId) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
                }
            }
            else
            {
                _no = no.ToString();
            }

            #endregion

            #region Insert

            if (type == 1)
            {
                try
                {
                    #region Insert SQL

                    sb.Length = 0;
                    sb.Append("INSERT INTO SYS_T_INQUIRY_H " + Environment.NewLine);
                    sb.Append("       ( NO" + Environment.NewLine);
                    sb.Append("       , COMPANY_ID" + Environment.NewLine);
                    sb.Append("       , GROUP_ID" + Environment.NewLine);
                    sb.Append("       , PERSON_ID" + Environment.NewLine);
                    sb.Append("       , DATE" + Environment.NewLine);
                    sb.Append("       , TIME" + Environment.NewLine);
                    sb.Append("       , TITLE" + Environment.NewLine);
                    sb.Append("       , INQUIRY_DIVISION_ID" + Environment.NewLine);
                    sb.Append("       , INQUIRY_LEVEL_ID" + Environment.NewLine);
                    sb.Append("       , INQUIRY_STATE_ID" + 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  " + _no + Environment.NewLine);                              // NO
                    sb.Append("       ," + companyId + Environment.NewLine);                        // COMPANY_ID
                    sb.Append("       ," + groupId + Environment.NewLine);                          // GROUP_ID
                    sb.Append("       ," + entity.person_id + Environment.NewLine);                 // PERSON_ID
                    sb.Append("       ," + ExEscape.zRepStr(date) + Environment.NewLine);           // DATE
                    sb.Append("       ," + ExEscape.zRepStr(time) + Environment.NewLine);           // TIME
                    sb.Append("       ," + ExEscape.zRepStr(entity.title) + Environment.NewLine);   // TITLE
                    sb.Append("       ," + entity.inquiry_division_id + Environment.NewLine);       // INQUIRY_DIVISION_ID
                    sb.Append("       ," + entity.inquiry_level_id + Environment.NewLine);          // INQUIRY_LEVEL_ID
                    sb.Append("       ," + entity.inquiry_level_state_id + Environment.NewLine);    // INQUIRY_STATE_ID
                    sb.Append("       ," + ExEscape.zRepStr(entity.memo) + Environment.NewLine);    // MEMO
                    sb.Append(CommonUtl.GetInsSQLCommonColums(CommonUtl.UpdKbn.Ins,
                                                              PG_NM,
                                                              "SYS_T_INQUIRY_H",
                                                              ExCast.zCInt(personId),
                                                              _no,
                                                              ipAdress,
                                                              userId));

                    #endregion

                    sys_db.ExecuteSQL(sb.ToString(), false);
                    if (CommonUtl.gSysDbKbn == 0)
                    {
                        db.ExecuteSQL(sb.ToString(), false);
                    }
                }
                catch (Exception ex)
                {
                    sys_db.ExRollbackTransaction();
                    if (CommonUtl.gSysDbKbn == 0)
                    {
                        db.ExRollbackTransaction();
                    }
                    CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateInquiry(Insert)", ex);
                    return(CLASS_NM + ".UpdateInquiry(Insert) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
                }
            }

            #endregion

            #region Update

            if (type == 0)
            {
                #region Update Head

                try
                {
                    #region SQL

                    sb.Length = 0;
                    sb.Append("UPDATE SYS_T_INQUIRY_H " + Environment.NewLine);
                    sb.Append(CommonUtl.GetUpdSQLCommonColums(PG_NM,
                                                              ExCast.zCInt(personId),
                                                              ipAdress,
                                                              userId,
                                                              0));
                    sb.Append("      ,INQUIRY_STATE_ID = " + entity.inquiry_level_state_id + Environment.NewLine);
                    sb.Append(" WHERE NO = " + _no + Environment.NewLine);

                    #endregion

                    sys_db.ExecuteSQL(sb.ToString(), false);
                    if (CommonUtl.gSysDbKbn == 0)
                    {
                        db.ExecuteSQL(sb.ToString(), false);
                    }
                }
                catch (Exception ex)
                {
                    sys_db.ExRollbackTransaction();
                    if (CommonUtl.gSysDbKbn == 0)
                    {
                        db.ExRollbackTransaction();
                    }
                    CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateInquiry(Update Head)", ex);
                    return(CLASS_NM + ".UpdateInquiry(Update Head) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
                }

                #endregion
            }

            #endregion

            #region Update Or Insert(Detail)

            if (type <= 1)
            {
                try
                {
                    #region Upload File Set

                    if (!string.IsNullOrEmpty(entity.upload_file_path1))
                    {
                        if (System.IO.Directory.Exists(CommonUtl.gstrFileUpLoadDir + entity.upload_file_path1) && !System.IO.Directory.Exists(CommonUtl.gstrFileUpLoadDir + _no + "-" + entity.rec_no.ToString()))
                        {
                            System.IO.Directory.Move(CommonUtl.gstrFileUpLoadDir + entity.upload_file_path1, CommonUtl.gstrFileUpLoadDir + _no + "-" + entity.rec_no.ToString());
                            entity.upload_file_path1 = CommonUtl.gstrFileUpLoadDir + _no + "-" + entity.rec_no.ToString();
                        }
                    }

                    #endregion

                    #region Insert SQL

                    sb.Length = 0;
                    sb.Append("INSERT INTO SYS_T_INQUIRY_D " + Environment.NewLine);
                    sb.Append("       ( NO" + Environment.NewLine);
                    sb.Append("       , REC_NO" + Environment.NewLine);
                    sb.Append("       , DATE" + Environment.NewLine);
                    sb.Append("       , TIME" + Environment.NewLine);
                    sb.Append("       , KBN" + Environment.NewLine);
                    sb.Append("       , PERSON_ID" + Environment.NewLine);
                    sb.Append("       , SUPPORT_PERSON_NAME" + 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("       , CONTENT" + 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  " + _no + Environment.NewLine);                                        // NO
                    sb.Append("       ," + entity.rec_no + Environment.NewLine);                              // REC_NO
                    sb.Append("       ," + ExEscape.zRepStr(date) + Environment.NewLine);                     // DATE
                    sb.Append("       ," + ExEscape.zRepStr(time) + Environment.NewLine);                     // TIME
                    sb.Append("       ," + entity.kbn + Environment.NewLine);                                 // KBN
                    sb.Append("       ," + entity.d_person_id + Environment.NewLine);                         // PERSON_ID
                    sb.Append("       ," + ExEscape.zRepStr(entity.support_person_nm) + Environment.NewLine); // SUPPORT_PERSON_NAME
                    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.content) + Environment.NewLine);           // CONTENT
                    sb.Append("       ," + ExEscape.zRepStr(entity.memo) + Environment.NewLine);              // MEMO
                    sb.Append(CommonUtl.GetInsSQLCommonColums(CommonUtl.UpdKbn.Ins,
                                                              PG_NM,
                                                              "SYS_T_INQUIRY_D",
                                                              ExCast.zCInt(personId),
                                                              _no,
                                                              ipAdress,
                                                              userId));

                    #endregion

                    sys_db.ExecuteSQL(sb.ToString(), false);
                    if (CommonUtl.gSysDbKbn == 0)
                    {
                        db.ExecuteSQL(sb.ToString(), false);
                    }
                }
                catch (Exception ex)
                {
                    if (CommonUtl.gSysDbKbn == 0)
                    {
                        db.ExRollbackTransaction();
                    }
                    sys_db.ExRollbackTransaction();
                    CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateInquiry(Insert Detail)", ex);
                    return(CLASS_NM + ".UpdateInquiry(Insert Detail) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
                }
            }

            #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)
                {
                    if (CommonUtl.gSysDbKbn == 0)
                    {
                        db.ExRollbackTransaction();
                    }
                    sys_db.ExRollbackTransaction();
                    CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateInquiry(DelLockPg)", ex);
                    return(CLASS_NM + ".UpdateInquiry(DelLockPg) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
                }
            }

            #endregion

            #region CommitTransaction

            try
            {
                sys_db.ExCommitTransaction();
                if (CommonUtl.gSysDbKbn == 0)
                {
                    db.ExCommitTransaction();
                }
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateInquiry(CommitTransaction)", ex);
                return(CLASS_NM + ".UpdateInquiry(CommitTransaction) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            #region Database Close

            try
            {
                sys_db.DbClose();
                db.DbClose();
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateInquiry(DbClose)", ex);
                return(CLASS_NM + ".UpdateInquiry(DbClose) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }
            finally
            {
                sys_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 + ".UpdateInquiry(Add Evidence)", ex);
                return(CLASS_NM + ".UpdateInquiry(Add Evidence) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            #region Return

            if (type == 1)
            {
                //return "Auto Insert success : " + "ID : " + _Id.ToString() + "で登録しました。";
                return("");
            }
            else
            {
                return("");
            }

            #endregion
        }
Пример #25
0
        public string UpdateCommodity(string random, int type, string Id, EntityCommodity 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 + ".UpdateCommodity(認証処理)", ex);
                return(CLASS_NM + ".UpdateCommodity : 認証処理に失敗しました。" + 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 + ".UpdateCommodity(DbOpen)", ex);
                return(CLASS_NM + ".UpdateCommodity(DbOpen) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            #region BeginTransaction

            try
            {
                db.ExBeginTransaction();
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateCommodity(BeginTransaction)", ex);
                return(CLASS_NM + ".UpdateCommodity(BeginTransaction) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            #region Get Max Master ID

            if (type == 1 && (Id == "" || Id == "0"))
            {
                try
                {
                    DataMasterId.GetMaxMasterId(companyId,
                                                "",
                                                db,
                                                DataMasterId.geMasterMaxIdKbn.Commodity,
                                                out _Id);

                    if (_Id == "")
                    {
                        return("ID取得に失敗しました。");
                    }
                }
                catch (Exception ex)
                {
                    CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateCommodity(GetMaxMasterId)", ex);
                    return(CLASS_NM + ".UpdateCommodity(GetMaxMasterId) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
                }
            }
            else
            {
                _Id = Id;
            }

            #endregion

            #region Insert

            if (type == 1)
            {
                try
                {
                    #region Delete SQL

                    sb.Length = 0;
                    sb.Append("DELETE FROM M_COMMODITY " + Environment.NewLine);
                    sb.Append(" WHERE DELETE_FLG = 1 " + Environment.NewLine);
                    sb.Append("   AND COMPANY_ID = " + companyId + Environment.NewLine);
                    sb.Append("   AND ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(_Id)) + Environment.NewLine);

                    #endregion

                    db.ExecuteSQL(sb.ToString(), false);

                    #region Insert SQL

                    string _main_purchase_id = entity.main_purchase_id;
                    if (ExCast.IsNumeric(_main_purchase_id))
                    {
                        _main_purchase_id = ExCast.zCDbl(_main_purchase_id).ToString();
                    }

                    #region SQL

                    sb.Length = 0;
                    sb.Append("INSERT INTO M_COMMODITY " + Environment.NewLine);
                    sb.Append("       ( COMPANY_ID" + Environment.NewLine);
                    sb.Append("       , ID" + Environment.NewLine);
                    sb.Append("       , ID2" + Environment.NewLine);
                    sb.Append("       , NAME" + Environment.NewLine);
                    sb.Append("       , KANA" + Environment.NewLine);
                    sb.Append("       , UNIT_ID" + Environment.NewLine);
                    sb.Append("       , ENTER_NUMBER" + Environment.NewLine);
                    sb.Append("       , NUMBER_DECIMAL_DIGIT" + Environment.NewLine);
                    sb.Append("       , UNIT_DECIMAL_DIGIT" + Environment.NewLine);
                    sb.Append("       , TAXATION_DIVISION_ID" + Environment.NewLine);
                    sb.Append("       , INVENTORY_MANAGEMENT_DIVISION_ID" + Environment.NewLine);
                    sb.Append("       , PURCHASE_LOT" + Environment.NewLine);
                    sb.Append("       , LEAD_TIME" + Environment.NewLine);
                    sb.Append("       , JUST_INVENTORY_NUMBER" + Environment.NewLine);
                    sb.Append("       , INVENTORY_NUMBER" + Environment.NewLine);
                    sb.Append("       , INVENTORY_EVALUATION_ID" + Environment.NewLine);
                    sb.Append("       , MAIN_PURCHASE_ID" + Environment.NewLine);
                    sb.Append("       , RETAIL_PRICE_SKIP_TAX" + Environment.NewLine);
                    sb.Append("       , RETAIL_PRICE_BEFORE_TAX" + Environment.NewLine);
                    sb.Append("       , SALES_UNIT_PRICE_SKIP_TAX" + Environment.NewLine);
                    sb.Append("       , SALES_UNIT_PRICE_BEFORE_TAX" + Environment.NewLine);
                    sb.Append("       , SALES_COST_PRICE_SKIP_TAX" + Environment.NewLine);
                    sb.Append("       , SALES_COST_PRICE_BEFORE_TAX" + Environment.NewLine);
                    sb.Append("       , PURCHASE_UNIT_PRICE_SKIP_TAX" + Environment.NewLine);
                    sb.Append("       , PURCHASE_UNIT_PRICE_BEFORE_TAX" + Environment.NewLine);
                    sb.Append("       , GROUP1_ID" + Environment.NewLine);
                    sb.Append("       , GROUP2_ID" + Environment.NewLine);
                    sb.Append("       , GROUP3_ID" + 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("       ," + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(_Id)) + Environment.NewLine);      // ID
                    sb.Append("       ," + ExCast.zIdForNumIndex(_Id) + Environment.NewLine);                               // ID2
                    sb.Append("       ," + ExEscape.zRepStr(entity.name) + Environment.NewLine);                            // NAME
                    sb.Append("       ," + ExEscape.zRepStr(entity.kana) + Environment.NewLine);                            // KANA
                    sb.Append("       ," + entity.unit_id + Environment.NewLine);                                           // UNIT_ID
                    sb.Append("       ," + entity.enter_number + Environment.NewLine);                                      // ENTER_NUMBER
                    sb.Append("       ," + entity.number_decimal_digit + Environment.NewLine);                              // NUMBER_DECIMAL_DIGIT
                    sb.Append("       ," + entity.unit_decimal_digit + Environment.NewLine);                                // UNIT_DECIMAL_DIGIT
                    sb.Append("       ," + entity.taxation_divition_id + Environment.NewLine);                              // TAXATION_DIVISION_ID
                    sb.Append("       ," + entity.inventory_management_division_id + Environment.NewLine);                  // INVENTORY_MANAGEMENT_DIVISION_ID
                    sb.Append("       ," + entity.purchase_lot + Environment.NewLine);                                      // PURCHASE_LOT
                    sb.Append("       ," + entity.lead_time + Environment.NewLine);                                         // LEAD_TIME
                    sb.Append("       ," + entity.just_inventory_number + Environment.NewLine);                             // JUST_INVENTORY_NUMBER
                    sb.Append("       ," + entity.inventory_number + Environment.NewLine);                                  // INVENTORY_NUMBER
                    sb.Append("       ," + entity.inventory_evaluation_id + Environment.NewLine);                           // INVENTORY_EVALUATION_ID
                    sb.Append("       ," + ExEscape.zRepStr(_main_purchase_id) + Environment.NewLine);                      // MAIN_PURCHASE_ID
                    sb.Append("       ," + entity.retail_price_skip_tax + Environment.NewLine);                             // RETAIL_PRICE_SKIP_TAX
                    sb.Append("       ," + entity.retail_price_before_tax + Environment.NewLine);                           // RETAIL_PRICE_BEFORE_TAX
                    sb.Append("       ," + entity.sales_unit_price_skip_tax + Environment.NewLine);                         // SALES_UNIT_PRICE_SKIP_TAX
                    sb.Append("       ," + entity.sales_unit_price_before_tax + Environment.NewLine);                       // SALES_UNIT_PRICE_BEFORE_TAX
                    sb.Append("       ," + entity.sales_cost_price_skip_tax + Environment.NewLine);                         // SALES_COST_PRICE_SKIP_TAX
                    sb.Append("       ," + entity.sales_cost_price_before_tax + Environment.NewLine);                       // SALES_COST_PRICE_BEFORE_TAX
                    sb.Append("       ," + entity.purchase_unit_price_skip_tax + Environment.NewLine);                      // PURCHASE_UNIT_PRICE_SKIP_TAX
                    sb.Append("       ," + entity.purchase_unit_price_before_tax + Environment.NewLine);                    // PURCHASE_UNIT_PRICE_BEFORE_TAX
                    sb.Append("       ," + ExEscape.zRepStr(entity.group1_id) + Environment.NewLine);                       // GROUP1_ID
                    sb.Append("       ," + ExEscape.zRepStr(entity.group2_id) + Environment.NewLine);                       // GROUP2_ID
                    sb.Append("       ," + ExEscape.zRepStr(entity.group3_id) + Environment.NewLine);                       // GROUP3_ID
                    sb.Append("       ," + ExEscape.zRepStr(entity.memo) + Environment.NewLine);                            // MEMO
                    sb.Append("       ," + entity.display_division_id + Environment.NewLine);                               // DISPLAY_FLG
                    sb.Append(CommonUtl.GetInsSQLCommonColums(CommonUtl.UpdKbn.Ins,
                                                              PG_NM,
                                                              "M_COMMODITY",
                                                              ExCast.zCInt(personId),
                                                              _Id,
                                                              ipAdress,
                                                              userId));

                    #endregion

                    #endregion

                    db.ExecuteSQL(sb.ToString(), false);

                    #region Commodity Inventory Insert

                    try
                    {
                        #region Delete SQL

                        sb.Length = 0;
                        sb.Append("DELETE FROM M_COMMODITY_INVENTORY " + 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);

                        #region SQL

                        sb.Length = 0;
                        sb.Append("SELECT MT.* " + Environment.NewLine);
                        sb.Append("  FROM SYS_M_COMPANY_GROUP AS MT" + Environment.NewLine);
                        sb.Append(" WHERE MT.COMPANY_ID = " + companyId + Environment.NewLine);
                        sb.Append("   AND MT.DELETE_FLG = 0 " + Environment.NewLine);
                        sb.Append(" ORDER BY MT.ID " + Environment.NewLine);

                        #endregion

                        dt = db.GetDataTable(sb.ToString());

                        if (dt.DefaultView.Count > 0)
                        {
                            for (int i = 0; i <= dt.DefaultView.Count - 1; i++)
                            {
                                #region Insert SQL

                                sb.Length = 0;
                                sb.Append("INSERT INTO M_COMMODITY_INVENTORY " + Environment.NewLine);
                                sb.Append("       ( COMPANY_ID" + Environment.NewLine);
                                sb.Append("       , GROUP_ID" + Environment.NewLine);
                                sb.Append("       , ID" + Environment.NewLine);
                                sb.Append("       , INVENTORY_NUMBER" + 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("       ," + ExCast.zCStr(dt.DefaultView[i]["ID"]) + Environment.NewLine);                            // GROUP_ID
                                sb.Append("       ," + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(_Id)) + Environment.NewLine);              // ID
                                sb.Append("       ,0" + Environment.NewLine);                                                                   // INVENTORY_NUMBER
                                sb.Append(CommonUtl.GetInsSQLCommonColums(CommonUtl.UpdKbn.Ins,
                                                                          PG_NM,
                                                                          "M_COMMODITY_INVENTORY",
                                                                          ExCast.zCInt(personId),
                                                                          _Id,
                                                                          ipAdress,
                                                                          userId));

                                #endregion

                                db.ExecuteSQL(sb.ToString(), false);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        db.ExRollbackTransaction();
                        CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateCommodity(Commodity Inventory Insert)", ex);
                        return(CLASS_NM + ".UpdateCommodity(Commodity Inventory Insert) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
                    }

                    #endregion
                }
                catch (Exception ex)
                {
                    db.ExRollbackTransaction();
                    CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateCommodity(Insert)", ex);
                    return(CLASS_NM + ".UpdateCommodity(Insert) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
                }
            }

            #endregion

            #region Update

            if (type == 0)
            {
                try
                {
                    #region SQL

                    string _main_purchase_id = entity.main_purchase_id;
                    if (ExCast.IsNumeric(_main_purchase_id))
                    {
                        _main_purchase_id = ExCast.zCDbl(_main_purchase_id).ToString();
                    }

                    sb.Length = 0;
                    sb.Append("UPDATE M_COMMODITY " + 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("      ,UNIT_ID = " + entity.unit_id + Environment.NewLine);
                    sb.Append("      ,ENTER_NUMBER = " + entity.enter_number + Environment.NewLine);
                    sb.Append("      ,NUMBER_DECIMAL_DIGIT = " + entity.number_decimal_digit + Environment.NewLine);
                    sb.Append("      ,UNIT_DECIMAL_DIGIT = " + entity.unit_decimal_digit + Environment.NewLine);
                    sb.Append("      ,TAXATION_DIVISION_ID = " + entity.taxation_divition_id + Environment.NewLine);
                    sb.Append("      ,INVENTORY_MANAGEMENT_DIVISION_ID = " + entity.inventory_management_division_id + Environment.NewLine);
                    sb.Append("      ,PURCHASE_LOT = " + entity.purchase_lot + Environment.NewLine);
                    sb.Append("      ,LEAD_TIME = " + entity.lead_time + Environment.NewLine);
                    sb.Append("      ,JUST_INVENTORY_NUMBER = " + entity.just_inventory_number + Environment.NewLine);
                    sb.Append("      ,INVENTORY_NUMBER = " + entity.inventory_number + Environment.NewLine);
                    sb.Append("      ,INVENTORY_EVALUATION_ID = " + entity.inventory_evaluation_id + Environment.NewLine);
                    sb.Append("      ,MAIN_PURCHASE_ID = " + ExEscape.zRepStr(_main_purchase_id) + Environment.NewLine);
                    sb.Append("      ,RETAIL_PRICE_SKIP_TAX = " + entity.retail_price_skip_tax + Environment.NewLine);
                    sb.Append("      ,RETAIL_PRICE_BEFORE_TAX = " + entity.retail_price_before_tax + Environment.NewLine);
                    sb.Append("      ,SALES_UNIT_PRICE_SKIP_TAX = " + entity.sales_unit_price_skip_tax + Environment.NewLine);
                    sb.Append("      ,SALES_UNIT_PRICE_BEFORE_TAX = " + entity.sales_unit_price_before_tax + Environment.NewLine);
                    sb.Append("      ,SALES_COST_PRICE_SKIP_TAX = " + entity.sales_cost_price_skip_tax + Environment.NewLine);
                    sb.Append("      ,SALES_COST_PRICE_BEFORE_TAX = " + entity.sales_cost_price_before_tax + Environment.NewLine);
                    sb.Append("      ,PURCHASE_UNIT_PRICE_SKIP_TAX = " + entity.purchase_unit_price_skip_tax + Environment.NewLine);
                    sb.Append("      ,PURCHASE_UNIT_PRICE_BEFORE_TAX = " + entity.purchase_unit_price_before_tax + 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 + ".UpdateCommodity(Update)", ex);
                    return(CLASS_NM + ".UpdateCommodity(Insert) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
                }
            }

            #endregion

            #region Delete

            if (type == 2)
            {
                #region Exist Data

                try
                {
                    bool _ret = false;

                    _ret = DataExists.IsExistData(db, companyId, groupId, "T_ESTIMATE_D", "COMMODITY_ID", ExCast.zNumZeroNothingFormat(Id), CommonUtl.geStrOrNumKbn.String);
                    if (_ret == true)
                    {
                        return("商品ID : " + Id + " は見積データに使用されている為、削除できません。");
                    }

                    _ret = DataExists.IsExistData(db, companyId, groupId, "T_ORDER_D", "COMMODITY_ID", ExCast.zNumZeroNothingFormat(Id), CommonUtl.geStrOrNumKbn.String);
                    if (_ret == true)
                    {
                        return("商品ID : " + Id + " は受注データに使用されている為、削除できません。");
                    }

                    _ret = DataExists.IsExistData(db, companyId, groupId, "T_SALES_D", "COMMODITY_ID", ExCast.zNumZeroNothingFormat(Id), CommonUtl.geStrOrNumKbn.String);
                    if (_ret == true)
                    {
                        return("商品ID : " + Id + " は売上データに使用されている為、削除できません。");
                    }
                }
                catch (Exception ex)
                {
                    db.ExRollbackTransaction();
                    CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateCommodity(Exist Data)", ex);
                    return(CLASS_NM + ".UpdateCommodity(Exist Data) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
                }

                #endregion

                #region Delete Commodity Inventory

                try
                {
                    sb.Length = 0;
                    sb.Append("UPDATE M_COMMODITY_INVENTORY " + 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 + ".UpdateCommodity(Delete Commodity Inventory)", ex);
                    return(CLASS_NM + ".UpdateCommodity(Commodity Inventory) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
                }

                #endregion

                #region Update

                try
                {
                    sb.Length = 0;
                    sb.Append("UPDATE M_COMMODITY " + 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 + ".UpdateCommodity(Delete)", ex);
                    return(CLASS_NM + ".UpdateCommodity(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 + ".UpdateCommodity(DelLockPg)", ex);
                    return(CLASS_NM + ".UpdateCommodity(DelLockPg) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
                }
            }

            #endregion

            #region CommitTransaction

            try
            {
                db.ExCommitTransaction();
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateCommodity(CommitTransaction)", ex);
                return(CLASS_NM + ".UpdateCommodity(CommitTransaction) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            #region Database Close

            try
            {
                db.DbClose();
            }
            catch (Exception ex)
            {
                db.ExRollbackTransaction();
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateCommodity(DbClose)", ex);
                return(CLASS_NM + ".UpdateCommodity(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 + ".UpdateCommodity(Add Evidence)", ex);
                return(CLASS_NM + ".UpdateCommodity(Add Evidence) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            #region Return

            if (type == 1 && (Id == "0" || Id == ""))
            {
                return("Auto Insert success : " + "ID : " + _Id.ToString() + "で登録しました。");
            }
            else
            {
                return("");
            }

            #endregion
        }
Пример #26
0
        // 条件句SQL設定
        private string GetSQLWhere()
        {
            string strWhrer        = "";
            string strWhrerString1 = "";
            string strWhrerString2 = "";

            #region 入金番号

            if (this.utlReceiptNo_F.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.NO >= " + ExCast.zCLng(this.utlReceiptNo_F.txtID.Text.Trim()) + Environment.NewLine;
                strWhrerString1 += "[入金番号 " + ExEscape.zRepStrNoQuota(this.utlReceiptNo_F.txtID.Text.Trim()) + "~";
            }
            else
            {
                strWhrerString1 += "[入金番号 未指定~";
            }
            if (this.utlReceiptNo_T.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.NO <= " + ExCast.zCLng(this.utlReceiptNo_T.txtID.Text.Trim()) + Environment.NewLine;
                strWhrerString1 += ExEscape.zRepStrNoQuota(this.utlReceiptNo_T.txtID.Text.Trim());
            }
            else
            {
                strWhrerString1 += "未指定";
            }

            #endregion

            #region 入金日

            if (Common.gWinType == Common.geWinType.ListReceiptMonth)
            {
                if (this.datReceiptYmd_F.Text.Trim() != "")
                {
                    strWhrer        += "   AND replace(date_format(T.RECEIPT_YMD , " + ExEscape.SQL_YM + "), '0000/00', '') >= " + ExEscape.zRepStr(this.datReceiptYmd_F.Text.Trim()) + Environment.NewLine;
                    strWhrerString1 += "] [入金年月 " + ExEscape.zRepStrNoQuota(this.datReceiptYmd_F.Text.Trim()) + "~";
                }
                else
                {
                    strWhrerString1 += "] [入金年月 未指定~";
                }
                if (this.datReceiptYmd_T.Text.Trim() != "")
                {
                    strWhrer        += "   AND replace(date_format(T.RECEIPT_YMD , " + ExEscape.SQL_YM + "), '0000/00', '') <= " + ExEscape.zRepStr(this.datReceiptYmd_T.Text.Trim()) + Environment.NewLine;
                    strWhrerString1 += ExEscape.zRepStrNoQuota(this.datReceiptYmd_T.Text.Trim()) + "]";
                }
                else
                {
                    strWhrerString1 += "未指定]";
                }
            }
            else
            {
                if (this.datReceiptYmd_F.Text.Trim() != "")
                {
                    strWhrer        += "   AND T.RECEIPT_YMD >= " + ExEscape.zRepStr(this.datReceiptYmd_F.Text.Trim()) + Environment.NewLine;
                    strWhrerString1 += "] [入金日 " + ExEscape.zRepStrNoQuota(this.datReceiptYmd_F.Text.Trim()) + "~";
                }
                else
                {
                    strWhrerString1 += "] [入金日 未指定~";
                }
                if (this.datReceiptYmd_T.Text.Trim() != "")
                {
                    strWhrer        += "   AND T.RECEIPT_YMD <= " + ExEscape.zRepStr(this.datReceiptYmd_T.Text.Trim()) + Environment.NewLine;
                    strWhrerString1 += ExEscape.zRepStrNoQuota(this.datReceiptYmd_T.Text.Trim()) + "]";
                }
                else
                {
                    strWhrerString1 += "未指定]";
                }
            }

            #endregion

            #region 入力担当者

            if (this.utlPerson_F.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.PERSON_ID >= " + ExCast.zCLng(this.utlPerson_F.txtID.Text.Trim()) + Environment.NewLine;
                strWhrerString2 += "[入力担当者 " + this.utlPerson_F.txtID.Text.Trim() + ":" + ExEscape.zRepStrNoQuota(this.utlPerson_F.txtNm.Text.Trim()) + "~";
            }
            else
            {
                strWhrerString2 += "[入力担当者 未指定~";
            }
            if (this.utlPerson_T.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.PERSON_ID <= " + ExCast.zCLng(this.utlPerson_T.txtID.Text.Trim()) + Environment.NewLine;
                strWhrerString2 += this.utlPerson_T.txtID.Text.Trim() + ":" + ExEscape.zRepStrNoQuota(this.utlPerson_T.txtNm.Text.Trim());
            }
            else
            {
                strWhrerString2 += "未指定";
            }

            #endregion

            #region 請求先

            if (this.utlInvoice.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.INVOICE_ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(this.utlInvoice.txtID.Text.Trim())) + Environment.NewLine;
                strWhrerString2 += "] [請求先 " + ExEscape.zRepStrNoQuota(this.utlInvoice.txtID.Text.Trim()) + ":" + ExEscape.zRepStrNoQuota(this.utlInvoice.txtNm.Text.Trim()) + "]";
            }
            else
            {
                strWhrerString2 += "] [請求先 未指定]";
            }

            #endregion

            if (Common.gWinType == Common.geWinType.ListReceiptDay)
            {
                strWhrer += "<group kbn>1";
            }
            else if (Common.gWinType == Common.geWinType.ListReceiptMonth)
            {
                strWhrer += "<group kbn>2";
            }

            strWhrer = strWhrer.Replace(",", "<<@escape_comma@>>");

            return(strWhrer + "WhereString =>" + strWhrerString1 + ";" + strWhrerString2);
        }
Пример #27
0
        public string UpdateClass(string random, List <EntityClass> entity, int classKbn)
        {
            #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 + ".UpdateClass(認証処理)", ex);
                return(CLASS_NM + ".UpdateClass : 認証処理に失敗しました。" + Environment.NewLine + ex.Message.ToString());
            }

            #endregion

            #region Field

            StringBuilder sb = new StringBuilder();
            DataTable     dt;
            ExMySQLData   db        = null;
            string        _Id       = "";
            int           _classKbn = 0;

            #endregion

            #region データ存在チェック

            sb = new StringBuilder();

            #region SQL

            _classKbn = ((classKbn - 1)) * 3 + 1;

            sb.Length = 0;
            sb.Append("SELECT MT.* " + Environment.NewLine);
            sb.Append("  FROM M_CLASS AS MT" + Environment.NewLine);
            sb.Append(" WHERE MT.COMPANY_ID = " + companyId + Environment.NewLine);
            sb.Append("   AND MT.DELETE_FLG = 0 " + Environment.NewLine);
            sb.Append("   AND MT.CLASS_DIVISION_ID = " + _classKbn.ToString() + Environment.NewLine);
            sb.Append(" ORDER BY MT.COMPANY_ID " + Environment.NewLine);
            sb.Append("         ,MT.ID " + 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 lngClassId = 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) == lngClassId)
                        {
                            exists_flg = true;
                        }
                    }

                    string strClassId = string.Format("{0:000}", ExCast.zCDbl(lngClassId));

                    if (exists_flg == false)
                    {
                        bool _ret = false;

                        switch (classKbn)
                        {
                        case 1:         // 得意先分類
                            _ret = DataExists.IsExistData(db, companyId, "", "M_CUSTOMER", "GROUP1_ID", strClassId, CommonUtl.geStrOrNumKbn.String);
                            if (_ret == true)
                            {
                                ret_msg += "得意先分類ID : " + strClassId + " は得意先マスタで使用されている為、削除できません。" + Environment.NewLine;
                            }
                            break;

                        case 2:         // 商品分類
                            _ret = DataExists.IsExistData(db, companyId, "", "M_COMMODITY", "GROUP1_ID", strClassId, CommonUtl.geStrOrNumKbn.String);
                            if (_ret == true)
                            {
                                ret_msg += "商品分類ID : " + strClassId + " は商品マスタで使用されている為、削除できません。" + Environment.NewLine;
                            }
                            break;

                        case 3:         // 仕入先分類
                            _ret = DataExists.IsExistData(db, companyId, "", "M_PURCHASE", "GROUP1_ID", strClassId, CommonUtl.geStrOrNumKbn.String);
                            if (_ret == true)
                            {
                                ret_msg += "仕入先分類ID : " + strClassId + " は仕入先マスタで使用されている為、削除できません。" + Environment.NewLine;
                            }
                            break;
                        }
                    }
                }

                if (!string.IsNullOrEmpty(ret_msg))
                {
                    return(ret_msg);
                }
            }


            #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 + ".UpdateClass(DbOpen)", ex);
                return(CLASS_NM + ".UpdateClass(DbOpen) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            #region BeginTransaction

            try
            {
                db.ExBeginTransaction();
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateClass(BeginTransaction)", ex);
                return(CLASS_NM + ".UpdateClass(BeginTransaction) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            #region Delete

            try
            {
                #region Delete SQL

                _classKbn = ((classKbn - 1)) * 3 + 1;

                sb.Length = 0;
                sb.Append("DELETE FROM M_CLASS " + Environment.NewLine);
                sb.Append(" WHERE COMPANY_ID = " + companyId + Environment.NewLine);
                sb.Append("   AND CLASS_DIVISION_ID = " + _classKbn.ToString() + Environment.NewLine);

                #endregion

                db.ExecuteSQL(sb.ToString(), false);
            }
            catch (Exception ex)
            {
                db.ExRollbackTransaction();
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateClass(Delete)", ex);
                return(CLASS_NM + ".UpdateClass(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_CLASS " + Environment.NewLine);
                        sb.Append("       ( COMPANY_ID" + Environment.NewLine);
                        sb.Append("       , CLASS_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("       ," + _classKbn.ToString() + Environment.NewLine);                                             // Class_DIVISION_ID
                        sb.Append("       ," + ExEscape.zRepStr(ExCast.zNumZeroFormat("{0:000}", 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_Class",
                                                                  ExCast.zCInt(personId),
                                                                  _Id,
                                                                  ipAdress,
                                                                  userId));

                        #endregion

                        db.ExecuteSQL(sb.ToString(), false);
                    }
                }
            }
            catch (Exception ex)
            {
                db.ExRollbackTransaction();
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateClass(Insert)", ex);
                return(CLASS_NM + ".UpdateClass(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 + ".UpdateClass(DelLockPg)", ex);
                return(CLASS_NM + ".UpdateClass(DelLockPg) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            #region CommitTransaction

            try
            {
                db.ExCommitTransaction();
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateClass(CommitTransaction)", ex);
                return(CLASS_NM + ".UpdateClass(CommitTransaction) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            #region Database Close

            try
            {
                db.DbClose();
            }
            catch (Exception ex)
            {
                db.ExRollbackTransaction();
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateClass(DbClose)", ex);
                return(CLASS_NM + ".UpdateClass(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 + ".UpdateClass(Add Evidence)", ex);
                return(CLASS_NM + ".UpdateClass(Add Evidence) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            return("");
        }
Пример #28
0
        public EntitySysLogin Login(string LoginID, string PassWord, int confirmFlg)
        {
            CommonUtl.ExLogger.Info(CLASS_NM + ".Login");

            CommonUtl.ExLogger.Info(CommonUtl.gConnectionString1);

            #region Field

            EntitySysLogin entity = null;

            int    userId    = 0;
            string userNm    = "";
            int    companyId = 0;
            string companyNm = "";
            int    groupId   = 0;
            string groupNm   = "";
            int    personId  = 0;
            string personNm  = "";

            int beforeUserId = 0;

            string accountBeginPeriod  = "";
            string accountEndPeriod    = "";
            string databaseString      = "";
            string databaseProvider    = "";
            string groupDisplayNm      = "";
            int    evidenceSaveFlg     = 0;
            int    invoicePrintFlg     = 0;
            int    idFigureSlipNo      = 10;
            int    idFigureCustomer    = 10;
            int    idFigurePurchase    = 10;
            int    idFigureGoods       = 10;
            int    estimateApprovalFlg = 1;
            int    reportSizeUser      = 0;
            int    reportSizeAll       = 0;
            int    demoFlg             = 0;
            string sysVer = "";

            string message = "";

            ExMySQLData sysdb = null;
            ExMySQLData db;

            StringBuilder sb;
            DataTable     dt;

            #endregion

            #region ログインID、パスワードチェック

            try
            {
                //
                sb = new StringBuilder();
                sb.Append("SELECT UR.* " + Environment.NewLine);
                sb.Append("      ,CP.NAME AS COMPANY_NAME " + Environment.NewLine);
                sb.Append("      ,GP.NAME AS GROUP_NAME " + Environment.NewLine);
                sb.Append("      ,GP.ESTIMATE_APPROVAL_FLG " + Environment.NewLine);
                sb.Append("      ,GP.INVOICE_PRINT_FLG " + Environment.NewLine);
                sb.Append("  FROM SYS_M_USER AS UR" + Environment.NewLine);
                sb.Append("  LEFT JOIN SYS_M_COMPANY AS CP" + Environment.NewLine);
                sb.Append("    ON UR.COMPANY_ID = CP.ID " + Environment.NewLine);
                sb.Append("   AND CP.DELETE_FLG = 0 " + Environment.NewLine);
                sb.Append("   AND CP.DISPLAY_FLG = 1 " + Environment.NewLine);
                sb.Append("  LEFT JOIN SYS_M_COMPANY_GROUP AS GP" + Environment.NewLine);
                sb.Append("    ON UR.GROUP_ID = GP.ID " + Environment.NewLine);
                sb.Append("   AND GP.DELETE_FLG = 0 " + Environment.NewLine);
                sb.Append("   AND GP.DISPLAY_FLG = 1 " + Environment.NewLine);
                sb.Append(" WHERE UR.DELETE_FLG = 0 " + Environment.NewLine);
                sb.Append("   AND UR.LOGIN_ID = " + ExEscape.zRepStr(LoginID) + Environment.NewLine);
                sb.Append("   AND UR.PASSWORD = "******"ID"]);
                    userNm              = ExCast.zCStr(dt.DefaultView[0]["NAME"]);
                    companyId           = ExCast.zCInt(dt.DefaultView[0]["COMPANY_ID"]);
                    companyNm           = ExCast.zCStr(dt.DefaultView[0]["COMPANY_NAME"]);
                    groupId             = ExCast.zCInt(dt.DefaultView[0]["GROUP_ID"]);
                    groupNm             = ExCast.zCStr(dt.DefaultView[0]["GROUP_NAME"]);
                    personId            = ExCast.zCInt(dt.DefaultView[0]["PERSON_ID"]);
                    estimateApprovalFlg = ExCast.zCInt(dt.DefaultView[0]["ESTIMATE_APPROVAL_FLG"]);
                    invoicePrintFlg     = ExCast.zCInt(dt.DefaultView[0]["INVOICE_PRINT_FLG"]);

                    // 前回セッションIDの保持
                    beforeUserId = ExCast.zCInt(HttpContext.Current.Session[ExSession.USER_ID]);
                }
                else
                {
                    entity = new EntitySysLogin((int)EntitySysLogin.geLoginReturn.Failure,   // Return CD
                                                "ログインID、または、パスワードが不正です。");                   // Return Message
                    return(entity);
                }
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".Login(ID,Pass Check)", ex);
                entity = new EntitySysLogin((int)EntitySysLogin.geLoginReturn.Error,                   // Return CD
                                            "ログイン処理でエラーが発生しました。" + Environment.NewLine +
                                            "システム管理者へ報告して下さい。" + Environment.NewLine + ex.ToString()); // Return Message
                return(entity);
            }

            #endregion

            #region 前回ログインチェック

            try
            {
                // 前回ログイン有り
                if (ExCast.zCStr(HttpContext.Current.Session[ExSession.USER_ID]) != "")
                {
                    // 前回ログインと同じ
                    if (ExCast.zCInt(HttpContext.Current.Session[ExSession.USER_ID]) == userId)
                    {
                        if (CommonUtl.gDemoKbn == 1)
                        {
                            // 再ログインとして返す
                            entity = new EntitySysLogin((int)EntitySysLogin.geLoginReturn.Again,     // Return CD
                                                        "");                                         // Return Message
                            return(entity);
                        }

                        // 同一セッションが存在しているか確認
                        if (ExSession.ExistsSessionInf(userId, ExCast.zCStr(HttpContext.Current.Session[ExSession.SESSION_RANDOM_STR]), ref message) == true)
                        {
                            // 再ログインとして返す
                            entity = new EntitySysLogin((int)EntitySysLogin.geLoginReturn.Again,     // Return CD
                                                        "");                                         // Return Message
                            return(entity);
                        }
                        else
                        {
                            // 違うセッションパラメータが設定されていた場合、削除
                            ExSession.DelSessionInf(userId);
                        }
                    }
                    //// 前回ログインと別
                    //else
                    //{
                    //    // 一旦ログオフする
                    //    if (pvtLogoff(ExCast.zCStr(HttpContext.Current.Session[ExSession.IP_ADRESS]),
                    //              ExCast.zCStr(HttpContext.Current.Session[ExSession.USER_ID]),
                    //              ExCast.zCStr(HttpContext.Current.Session[ExSession.SESSION_RANDOM_STR]),
                    //              ExCast.zCStr(HttpContext.Current.Session[ExSession.PERSON_ID])) == false)
                    //    {
                    //        entity = new EntitySysLogin((int)EntitySysLogin.geLoginReturn.Error,              // Return CD
                    //                                    "ログオフ処理に失敗しました。" + Environment.NewLine +
                    //                                    "システム管理者へ報告して下さい。" + CommonUtl.gstrErrMsg);   // Return Message
                    //    }
                    //}
                }
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".Login(Before Login Check)", ex);
                entity = new EntitySysLogin((int)EntitySysLogin.geLoginReturn.Error,                   // Return CD
                                            "前回ログインチェック処理でエラーが発生しました。" + Environment.NewLine +
                                            "システム管理者へ報告して下さい。" + Environment.NewLine + ex.ToString()); // Return Message
                return(entity);
            }

            #endregion

            #region システム設定取得

            try
            {
                sb.Length = 0;
                sb.Append("SELECT ST.*" + Environment.NewLine);
                sb.Append("  FROM SYS_M_SETTING AS ST" + Environment.NewLine);
                sb.Append(" WHERE ST.DELETE_FLG = 0 " + Environment.NewLine);
                sb.Append("   AND ST.DISPLAY_FLG = 1 " + Environment.NewLine);
                sb.Append("   AND ST.COMPANY_ID = " + companyId.ToString() + Environment.NewLine);
                dt = CommonUtl.gMySqlDt.GetDataTable(sb.ToString());

                if (dt.DefaultView.Count > 0)
                {
                    accountBeginPeriod = ExCast.zCStr(dt.DefaultView[0]["ACCOUNT_BEGIN_PERIOD"]);
                    accountEndPeriod   = ExCast.zCStr(dt.DefaultView[0]["ACCOUNT_END_PERIOD"]);
                    databaseString     = ExCast.zCStr(dt.DefaultView[0]["DATABESE_SETTING"]);
                    databaseProvider   = ExCast.zCStr(dt.DefaultView[0]["DATABESE_PROVIDER"]);
                    groupDisplayNm     = ExCast.zCStr(dt.DefaultView[0]["GROUP_DISPLAY_NAME"]);
                    evidenceSaveFlg    = ExCast.zCInt(dt.DefaultView[0]["EVIDENCE_SAVE_FLG"]);
                    idFigureSlipNo     = ExCast.zCInt(dt.DefaultView[0]["ID_FIGURE_SLIP_NO"]);
                    idFigureCustomer   = ExCast.zCInt(dt.DefaultView[0]["ID_FIGURE_CUSTOMER"]);
                    idFigurePurchase   = ExCast.zCInt(dt.DefaultView[0]["ID_FIGURE_PURCHASE"]);
                    idFigureGoods      = ExCast.zCInt(dt.DefaultView[0]["ID_FIGURE_GOODS"]);
                    reportSizeUser     = ExCast.zCInt(dt.DefaultView[0]["REPORT_SAVE_SIZE_USER"]);
                    reportSizeAll      = ExCast.zCInt(dt.DefaultView[0]["REPORT_SAVE_SIZE_ALL"]);
                    demoFlg            = ExCast.zCInt(dt.DefaultView[0]["DEMO_FLG"]);
                    sysVer             = ExCast.zCStr(dt.DefaultView[0]["SYSTEM_VER"]);
                }
                else
                {
                    entity = new EntitySysLogin((int)EntitySysLogin.geLoginReturn.Failure,   // Return CD
                                                "システム設定データが存在しません。" + Environment.NewLine +
                                                "システム管理者へ報告して下さい。");                         // Return Message
                    return(entity);
                }
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".Login(Get System Setting)", ex);
                entity = new EntitySysLogin((int)EntitySysLogin.geLoginReturn.Error,                   // Return CD
                                            "システム設定の取得処理でエラーが発生しました。" + Environment.NewLine +
                                            "システム管理者へ報告して下さい。" + Environment.NewLine + ex.ToString()); // Return Message
                return(entity);
            }

            #endregion

            #region  別データベース接続確認

            try
            {
                db = new ExMySQLData(databaseString);
                db.DbOpen();
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".Login(DB Connect)", ex);
                entity = new EntitySysLogin((int)EntitySysLogin.geLoginReturn.Error,                // Return CD
                                            "個別データベースの接続に失敗しました。" + Environment.NewLine +
                                            "システム管理者へ報告して下さい。" + Environment.NewLine + ex.Message); // Return Message
                return(entity);
            }

            #endregion

            #region 担当者名取得

            try
            {
                sb.Length = 0;
                sb.Append("SELECT PS.* " + Environment.NewLine);
                sb.Append("  FROM M_PERSON AS PS" + Environment.NewLine);
                sb.Append(" WHERE PS.COMPANY_ID = " + companyId.ToString() + Environment.NewLine);
                sb.Append("   AND PS.ID = " + personId.ToString() + Environment.NewLine);
                sb.Append("   AND PS.DELETE_FLG = 0" + Environment.NewLine);
                sb.Append("   AND PS.DISPLAY_FLG = 1" + Environment.NewLine);
                dt = CommonUtl.gMySqlDt.GetDataTable(sb.ToString());

                if (dt.DefaultView.Count > 0)
                {
                    personNm = ExCast.zCStr(dt.DefaultView[0]["NAME"]);
                }
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".Login(Get Person)", ex);
                entity = new EntitySysLogin((int)EntitySysLogin.geLoginReturn.Error,                   // Return CD
                                            "担当者名の取得処理でエラーが発生しました。" + Environment.NewLine +
                                            "システム管理者へ報告して下さい。" + Environment.NewLine + ex.ToString()); // Return Message
                return(entity);
            }

            #endregion

            #region ログイン履歴登録情報設定

            string random   = "";
            string ipAdress = "";
            string date     = "";
            string time     = "";
            try
            {
                //ランダム文字列取得
                random = ExRandomString.GetRandomString();

                // IP取得
                OperationContext              context    = OperationContext.Current;
                MessageProperties             properties = context.IncomingMessageProperties;
                RemoteEndpointMessageProperty endpoint   = properties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;
                ipAdress = endpoint.Address.ToString();

                // 日時取得
                DateTime now = DateTime.Now;
                date = now.ToString("yyyy/MM/dd");
                time = now.ToString("HH:mm:ss");
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".Login(Get History Inf)", ex);
                entity = new EntitySysLogin((int)EntitySysLogin.geLoginReturn.Error,        // Return CD
                                                      "ログイン履歴情報の設定に失敗しました。" + Environment.NewLine +
                                                      "システム管理者へ報告して下さい。" + Environment.NewLine +
                                               ex.ToString());                                                   // Return Message
                return(entity);
            }

            #endregion

            #region セッション情報設定

            try
            {
                if (ExSession.AddSessionInf(userId, random, db, ref message) == false)
                {
                    entity = new EntitySysLogin((int)EntitySysLogin.geLoginReturn.Warmn,     // Return CD
                                                "セッション情報の設定に失敗しました。" + Environment.NewLine +
                                                "システム管理者へ報告して下さい。" + Environment.NewLine +
                                                message);                                                           // Return Message
                }
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".Login(Set Session Inf)", ex);
                entity = new EntitySysLogin((int)EntitySysLogin.geLoginReturn.Error,        // Return CD
                                                      "セッション情報の設定に失敗しました。" + Environment.NewLine +
                                                      "システム管理者へ報告して下さい。" + Environment.NewLine +
                                               ex.ToString());                                                   // Return Message
                return(entity);
            }

            #endregion

            if (confirmFlg == 1)
            {
                #region ログオフ処理

                try
                {
                    // 前回ログイン有り
                    if (ExCast.zCStr(HttpContext.Current.Session[ExSession.USER_ID]) != "")
                    {
                        // 前回セッションとログインIDが違う場合
                        if (ExCast.zCInt(HttpContext.Current.Session[ExSession.USER_ID]) != userId)
                        {
                            // ログオフする
                            if (pvtLogoff(ExCast.zCStr(HttpContext.Current.Session[ExSession.IP_ADRESS]),
                                          ExCast.zCStr(HttpContext.Current.Session[ExSession.USER_ID]),
                                          ExCast.zCStr(HttpContext.Current.Session[ExSession.SESSION_RANDOM_STR]),
                                          ExCast.zCStr(HttpContext.Current.Session[ExSession.PERSON_ID])) == false)
                            {
                                entity = new EntitySysLogin((int)EntitySysLogin.geLoginReturn.Error,      // Return CD
                                                            "ログオフ処理に失敗しました。" + Environment.NewLine +
                                                            "システム管理者へ報告して下さい。" + CommonUtl.gstrErrMsg);   // Return Message
                                return(entity);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    CommonUtl.ExLogger.Error(CLASS_NM + ".Login(Logoff)", ex);
                    entity = new EntitySysLogin((int)EntitySysLogin.geLoginReturn.Error,        // Return CD
                                                "ログオフに失敗しました。" + Environment.NewLine +
                                                "システム管理者へ報告して下さい。" + Environment.NewLine +
                                                ex.ToString());                                                        // Return Message
                    return(entity);
                }


                #endregion

                #region ログイン履歴登録

                try
                {
                    #region System Databese Open

                    try
                    {
                        sysdb = new ExMySQLData();
                        sysdb.DbOpen();
                    }
                    catch (Exception ex)
                    {
                        CommonUtl.ExLogger.Error(CLASS_NM + ".Login(DbOpen)", ex);
                        entity = new EntitySysLogin((int)EntitySysLogin.geLoginReturn.Error,     // Return CD
                                                    "ログイン履歴の登録に失敗しました。(DbOpen)" + Environment.NewLine +
                                                    "システム管理者へ報告して下さい。" + Environment.NewLine +
                                                    ex.ToString());                                                     // Return Message
                        return(entity);
                    }

                    #endregion

                    #region BeginTransaction

                    try
                    {
                        sysdb.ExBeginTransaction();
                    }
                    catch (Exception ex)
                    {
                        sysdb.ExRollbackTransaction();
                        CommonUtl.ExLogger.Error(CLASS_NM + ".Login(BeginTransaction)", ex);
                        entity = new EntitySysLogin((int)EntitySysLogin.geLoginReturn.Error,     // Return CD
                                                    "ログイン履歴の登録に失敗しました。(BeginTransaction)" + Environment.NewLine +
                                                    "システム管理者へ報告して下さい。" + Environment.NewLine +
                                                    ex.ToString());                                                     // Return Message
                        return(entity);
                    }

                    #endregion

                    #region Insert

                    sb.Length = 0;
                    sb.Append("INSERT INTO SYS_H_USER_LOGIN_HISTORY " + Environment.NewLine);
                    sb.Append("       (USER_ID" + Environment.NewLine);
                    sb.Append("       ,LOGIN_DIVISION" + Environment.NewLine);
                    sb.Append("       ,LOGIN_DATE" + Environment.NewLine);
                    sb.Append("       ,LOGIN_TIME" + Environment.NewLine);
                    sb.Append("       ,SESSION_STRING" + Environment.NewLine);
                    sb.Append("       ,IP_ADRESS" + 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("VALUES (" + userId + Environment.NewLine);                     // USER_ID
                    sb.Append("       ,1" + Environment.NewLine);                             // LOGIN_DIVISION
                    sb.Append("       ," + ExEscape.zRepStr(date) + Environment.NewLine);     // LOGIN_DATE
                    sb.Append("       ," + ExEscape.zRepStr(time) + Environment.NewLine);     // LOGIN_TIME
                    sb.Append("       ," + ExEscape.zRepStr(random) + Environment.NewLine);   // SESSION_STRING
                    sb.Append("       ," + ExEscape.zRepStr(ipAdress) + Environment.NewLine); // IP_ADRESS
                    sb.Append(CommonUtl.GetInsSQLCommonColums(CommonUtl.UpdKbn.Ins,
                                                              "SYSTEM",
                                                              "",
                                                              ExCast.zCInt(personId),
                                                              "0",
                                                              ExCast.zCStr(ipAdress),
                                                              ExCast.zCStr(userId)));
                    sb.Append(")");

                    sysdb.ExecuteSQL(sb.ToString(), false);

                    #endregion

                    #region CommitTransaction

                    try
                    {
                        sysdb.ExCommitTransaction();
                    }
                    catch (Exception ex)
                    {
                        CommonUtl.gMySqlDt.ExRollbackTransaction();
                        CommonUtl.ExLogger.Error(CLASS_NM + ".Login(CommitTransaction)", ex);
                        entity = new EntitySysLogin((int)EntitySysLogin.geLoginReturn.Error,     // Return CD
                                                    "ログイン履歴の登録に失敗しました。(BeginTransaction)" + Environment.NewLine +
                                                    "システム管理者へ報告して下さい。" + Environment.NewLine +
                                                    ex.ToString());                                                     // Return Message
                        return(entity);
                    }

                    #endregion

                    #region System Database Close

                    try
                    {
                        sysdb.DbClose();
                    }
                    catch (Exception ex)
                    {
                        sysdb.ExRollbackTransaction();
                        CommonUtl.ExLogger.Error(CLASS_NM + ".Login(DbClose)", ex);
                        entity = new EntitySysLogin((int)EntitySysLogin.geLoginReturn.Error,     // Return CD
                                                    "ログイン履歴の登録に失敗しました。(DbClose)" + Environment.NewLine +
                                                    "システム管理者へ報告して下さい。" + Environment.NewLine +
                                                    ex.ToString());                                                     // Return Message
                        return(entity);
                    }
                    finally
                    {
                        sysdb = null;
                    }

                    #endregion

                    #region セッションの保持

                    // セッションの保持
                    HttpContext.Current.Session[ExSession.COMPANY_ID]                        = companyId;
                    HttpContext.Current.Session[ExSession.GROUP_ID]                          = groupId;
                    HttpContext.Current.Session[ExSession.USER_ID]                           = userId;
                    HttpContext.Current.Session[ExSession.USER_NM]                           = userNm;
                    HttpContext.Current.Session[ExSession.PERSON_ID]                         = personId;
                    HttpContext.Current.Session[ExSession.DEFAULT_PERSON_ID]                 = personId;
                    HttpContext.Current.Session[ExSession.SESSION_RANDOM_STR]                = random;
                    HttpContext.Current.Session[ExSession.IP_ADRESS]                         = ipAdress;
                    HttpContext.Current.Session[ExSession.DB_CONNECTION_STR]                 = databaseString;
                    HttpContext.Current.Session[ExSession.DATA_CLASS]                        = db;
                    HttpContext.Current.Session[ExSession.EVIDENCE_SAVE_FLG]                 = evidenceSaveFlg;
                    HttpContext.Current.Session[ExSession.ACCOUNT_BEGIN_PERIOD]              = accountBeginPeriod;
                    HttpContext.Current.Session[ExSession.ACCOUNT_END_PERIOD]                = accountEndPeriod;
                    HttpContext.Current.Session[ExSession.ID_FIGURE_SLIP_NO]                 = idFigureSlipNo;
                    HttpContext.Current.Session[ExSession.ID_FIGURE_CUSTOMER]                = idFigureCustomer;
                    HttpContext.Current.Session[ExSession.ID_FIGURE_PURCHASE]                = idFigurePurchase;
                    HttpContext.Current.Session[ExSession.ID_FIGURE_GOODS]                   = idFigureGoods;
                    HttpContext.Current.Session[ExSession.REPORT_SAVE_SIZE_USER]             = reportSizeUser;
                    HttpContext.Current.Session[ExSession.REPORT_SAVE_SIZE_ALL]              = reportSizeAll;
                    HttpContext.Current.Session[ExSession.GROUP_DISPLAY_NAME]                = groupDisplayNm;
                    HttpContext.Current.Session[ExSession.ESTIMATE_APPROVAL_FLG]             = estimateApprovalFlg;
                    HttpContext.Current.Session[ExSession.RECEIPT_ACCOUNT_INVOICE_PRINT_FLG] = invoicePrintFlg;

                    #endregion
                }
                catch (Exception ex)
                {
                    sysdb.ExRollbackTransaction();
                    CommonUtl.ExLogger.Error(CLASS_NM + ".Login(Add History)", ex);
                    entity = new EntitySysLogin((int)EntitySysLogin.geLoginReturn.Error,     // Return CD
                                                "ログイン履歴の登録に失敗しました。" + Environment.NewLine +
                                                "システム管理者へ報告して下さい。" + Environment.NewLine +
                                                ex.ToString());                                                     // Return Message
                    return(entity);
                }

                #endregion
            }
            else
            {
                #region セッションの保持

                // セッションの保持
                HttpContext.Current.Session[ExSession.COMPANY_ID]                        = companyId;
                HttpContext.Current.Session[ExSession.GROUP_ID]                          = groupId;
                HttpContext.Current.Session[ExSession.USER_ID]                           = userId;
                HttpContext.Current.Session[ExSession.USER_NM]                           = userNm;
                HttpContext.Current.Session[ExSession.PERSON_ID]                         = personId;
                HttpContext.Current.Session[ExSession.DEFAULT_PERSON_ID]                 = personId;
                HttpContext.Current.Session[ExSession.SESSION_RANDOM_STR]                = random;
                HttpContext.Current.Session[ExSession.IP_ADRESS]                         = ipAdress;
                HttpContext.Current.Session[ExSession.DB_CONNECTION_STR]                 = databaseString;
                HttpContext.Current.Session[ExSession.DATA_CLASS]                        = db;
                HttpContext.Current.Session[ExSession.EVIDENCE_SAVE_FLG]                 = evidenceSaveFlg;
                HttpContext.Current.Session[ExSession.ACCOUNT_BEGIN_PERIOD]              = accountBeginPeriod;
                HttpContext.Current.Session[ExSession.ACCOUNT_END_PERIOD]                = accountEndPeriod;
                HttpContext.Current.Session[ExSession.ID_FIGURE_SLIP_NO]                 = idFigureSlipNo;
                HttpContext.Current.Session[ExSession.ID_FIGURE_CUSTOMER]                = idFigureCustomer;
                HttpContext.Current.Session[ExSession.ID_FIGURE_PURCHASE]                = idFigurePurchase;
                HttpContext.Current.Session[ExSession.ID_FIGURE_GOODS]                   = idFigureGoods;
                HttpContext.Current.Session[ExSession.REPORT_SAVE_SIZE_USER]             = reportSizeUser;
                HttpContext.Current.Session[ExSession.REPORT_SAVE_SIZE_ALL]              = reportSizeAll;
                HttpContext.Current.Session[ExSession.GROUP_DISPLAY_NAME]                = groupDisplayNm;
                HttpContext.Current.Session[ExSession.ESTIMATE_APPROVAL_FLG]             = estimateApprovalFlg;
                HttpContext.Current.Session[ExSession.RECEIPT_ACCOUNT_INVOICE_PRINT_FLG] = invoicePrintFlg;

                #endregion
            }

            entity = new EntitySysLogin((int)EntitySysLogin.geLoginReturn.Normal,    // Return CD
                                        "",                                          // Return Message
                                        companyId,                                   // Company ID
                                        companyNm,                                   // Company Name
                                        groupId,                                     // Group ID
                                        groupNm,                                     // Group Name
                                        personId,                                    // Default Person ID
                                        personNm,                                    // Default Person Name
                                        groupDisplayNm,                              // Group Display Name
                                        evidenceSaveFlg,                             // Evidence Flg
                                        idFigureSlipNo,                              //
                                        idFigureCustomer,                            //
                                        idFigurePurchase,                            //
                                        idFigureGoods,                               //
                                        random);                                     // Session String
            entity.user_id = userId;
            entity.user_nm = userNm;
            entity.estimate_approval_flg             = estimateApprovalFlg;
            entity.receipt_account_invoice_print_flg = invoicePrintFlg;
            entity.demo_flg = demoFlg;
            entity.sys_ver  = sysVer;

            return(entity);
        }
        public static void gAddEvidence(int saveFlg, string companyId, string userId, string ipAdress, string sessionString, string pgId, DataPgEvidence.geOperationType type, string memo)
        {
            if (saveFlg != 1)
            {
                return;
            }

            StringBuilder sb = new StringBuilder();
            DataTable     dt;

            ExMySQLData db = ExSession.GetSessionDb(ExCast.zCInt(userId), sessionString);

            // 日時取得
            string   date        = "";
            string   time        = "";
            int      millisecond = 0;
            DateTime now         = DateTime.Now;

            date        = now.ToString("yyyy/MM/dd");
            time        = now.ToString("HH:mm:ss");
            millisecond = now.Millisecond;

            // PG実行履歴登録
            try
            {
                sb.Length = 0;
                sb.Append("INSERT INTO H_PG_EXEC_HISTORY " + Environment.NewLine);
                sb.Append("       (COMPANY_ID" + Environment.NewLine);
                sb.Append("       ,USER_ID" + Environment.NewLine);
                sb.Append("       ,PG_ID" + Environment.NewLine);
                sb.Append("       ,OPERATION_DATE" + Environment.NewLine);
                sb.Append("       ,OPERATION_TIME" + Environment.NewLine);
                sb.Append("       ,OPERATION_MILLISECOND" + Environment.NewLine);
                sb.Append("       ,OPERATION_TYPE" + Environment.NewLine);
                sb.Append("       ,PG_NAME" + Environment.NewLine);
                sb.Append("       ,OPERATION_TYPE_NAME" + 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_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_DATE" + Environment.NewLine);
                sb.Append("       ,UPDATE_TIME" + Environment.NewLine);
                sb.Append(")" + Environment.NewLine);
                sb.Append("VALUES (" + companyId + Environment.NewLine);                                                   // COMPANY_ID
                sb.Append("       ," + userId + Environment.NewLine);                                                      // USER_ID
                sb.Append("       ," + ExEscape.zRepStr(pgId) + Environment.NewLine);                                      // PG_ID
                sb.Append("       ," + ExEscape.zRepStr(date) + Environment.NewLine);                                      // OPERATION_DATE
                sb.Append("       ," + ExEscape.zRepStr(time) + Environment.NewLine);                                      // OPERATION_TIME
                sb.Append("       ," + millisecond.ToString() + Environment.NewLine);                                      // OPERATION_MILLISECOND
                sb.Append("       ," + (int)type + Environment.NewLine);                                                   // OPERATION_TYPE
                sb.Append("       ," + ExEscape.zRepStr(DataPgEvidence.GetPgName(pgId)) + Environment.NewLine);            // PG_NAME
                sb.Append("       ," + ExEscape.zRepStr(DataPgEvidence.GetOperationTypeName(type)) + Environment.NewLine); // OPERATION_TYPE_NAME
                sb.Append("       ," + ExEscape.zRepStr(memo) + Environment.NewLine);                                      // MEMO
                sb.Append("       ,0" + Environment.NewLine);                                                              // UPDATE_FLG
                sb.Append("       ,0" + Environment.NewLine);                                                              // DELETE_FLG
                sb.Append("       ,'SYSTEM'" + Environment.NewLine);                                                       // CREATE_PG_ID
                sb.Append("       ," + ExEscape.zRepStr(ipAdress) + Environment.NewLine);                                  // CREATE_ADRESS
                sb.Append("       ," + ExEscape.zRepStr(userId) + Environment.NewLine);                                    // CREATE_USER_ID
                sb.Append("       ," + ExEscape.zRepStr(date) + Environment.NewLine);                                      // CREATE_DATE
                sb.Append("       ," + ExEscape.zRepStr(time) + Environment.NewLine);                                      // CREATE_TIME
                sb.Append("       ,'SYSTEM'" + Environment.NewLine);                                                       // UPDATE_PG_ID
                sb.Append("       ," + ExEscape.zRepStr(ipAdress) + Environment.NewLine);                                  // UPDATE_ADRESS
                sb.Append("       ," + ExEscape.zRepStr(userId) + Environment.NewLine);                                    // UPDATE_USER_ID
                sb.Append("       ," + ExEscape.zRepStr(date) + Environment.NewLine);                                      // UPDATE_DATE
                sb.Append("       ," + ExEscape.zRepStr(time) + Environment.NewLine);                                      // UPDATE_TIME
                sb.Append(")");

                if (db.ExecuteSQL(sb.ToString(), true) == false)
                {
                    CommonUtl.ExLogger.Error(CLASS_NM + ".gAddEvidence(ExecuteSQL) : " + Environment.NewLine + ExSession.GetSessionDb(ExCast.zCInt(userId), sessionString).errMessage);
                    return;
                }

                switch (type)
                {
                case DataPgEvidence.geOperationType.Start:
                case DataPgEvidence.geOperationType.End:
                    if (pgId == DataPgEvidence.PGName.System)
                    {
                        DataPgLock.DelLockPg(companyId, userId, "", "", ipAdress, true, db);
                    }
                    else
                    {
                        DataPgLock.DelLockPg(companyId, userId, pgId, "", ipAdress, true, db);
                    }
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".gAddEvidence(Insert)", ex);
                db.ExRollbackTransaction();
            }
        }
Пример #30
0
        private bool pvtLogoff(string ipAdress, string userId, string sessionString, string personId)
        {
            #region Field

            string        date = "";
            string        time = "";
            DataTable     dt;
            ExMySQLData   sysdb = null;
            StringBuilder sb    = new StringBuilder();

            #endregion

            #region Init

            // 日時取得
            DateTime now = DateTime.Now;
            date = now.ToString("yyyy/MM/dd");
            time = now.ToString("HH:mm:ss");

            #endregion

            #region System Databese Open

            try
            {
                sysdb = new ExMySQLData();
                sysdb.DbOpen();
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".pvtLogoff(DbOpen)", ex);
                CommonUtl.gstrErrMsg = CLASS_NM + ".pvtLogoff(DbOpen)" + Environment.NewLine + ex.Message;
                return(false);
            }

            #endregion

            #region BeginTransaction

            try
            {
                sysdb.ExBeginTransaction();
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".pvtLogoff(BeginTransaction)", ex);
                CommonUtl.gstrErrMsg = CLASS_NM + ".pvtLogoff(BeginTransaction)" + Environment.NewLine + ex.Message;
                return(false);
            }

            #endregion

            #region Insert

            // ログイン履歴登録
            try
            {
                sb.Length = 0;
                sb.Append("INSERT INTO SYS_H_USER_LOGIN_HISTORY " + Environment.NewLine);
                sb.Append("       (USER_ID" + Environment.NewLine);
                sb.Append("       ,LOGIN_DIVISION" + Environment.NewLine);
                sb.Append("       ,LOGIN_DATE" + Environment.NewLine);
                sb.Append("       ,LOGIN_TIME" + Environment.NewLine);
                sb.Append("       ,SESSION_STRING" + Environment.NewLine);
                sb.Append("       ,IP_ADRESS" + 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("VALUES (" + userId + Environment.NewLine);                          // USER_ID
                sb.Append("       ,2" + Environment.NewLine);                                  // LOGIN_DIVISION
                sb.Append("       ," + ExEscape.zRepStr(date) + Environment.NewLine);          // LOGIN_DATE
                sb.Append("       ," + ExEscape.zRepStr(time) + Environment.NewLine);          // LOGIN_TIME
                sb.Append("       ," + ExEscape.zRepStr(sessionString) + Environment.NewLine); // SESSION_STRING
                sb.Append("       ," + ExEscape.zRepStr(ipAdress) + Environment.NewLine);      // IP_ADRESS
                sb.Append(CommonUtl.GetInsSQLCommonColums(CommonUtl.UpdKbn.Ins,
                                                          "SYSTEM",
                                                          "",
                                                          ExCast.zCInt(personId),
                                                          "0",
                                                          ipAdress,
                                                          userId));
                sb.Append(")");

                sysdb.ExecuteSQL(sb.ToString(), false);
            }
            catch (Exception ex)
            {
                sysdb.ExRollbackTransaction();
                CommonUtl.ExLogger.Error(CLASS_NM + ".pvtLogoff(Insert)", ex);
                CommonUtl.gstrErrMsg = CLASS_NM + ".pvtLogoff(Insert)" + Environment.NewLine + ex.Message;
                return(false);
            }

            #endregion

            #region CommitTransaction

            try
            {
                sysdb.ExCommitTransaction();
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".pvtLogoff(CommitTransaction)", ex);
                CommonUtl.gstrErrMsg = CLASS_NM + ".pvtLogoff(CommitTransaction)" + Environment.NewLine + ex.Message;
                return(false);
            }

            #endregion

            #region System Database Close

            try
            {
                sysdb.DbClose();
            }
            catch (Exception ex)
            {
                sysdb.ExRollbackTransaction();
                CommonUtl.ExLogger.Error(CLASS_NM + ".pvtLogoff(DbClose)", ex);
                CommonUtl.gstrErrMsg = CLASS_NM + ".pvtLogoff(DbClose)" + Environment.NewLine + ex.Message;
                return(false);
            }
            finally
            {
                sysdb = null;
            }

            #endregion

            // グローバルセッション情報削除
            try
            {
                if (ExSession.DelSessionInf(ExCast.zCInt(HttpContext.Current.Session[ExSession.USER_ID])) == false)
                {
                    return(false);
                }
                return(true);
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".pvtLogoff(Delete Session)", ex);
                CommonUtl.gstrErrMsg = CLASS_NM + ".pvtLogoff(Delete Session)" + Environment.NewLine + ex.Message;
                return(false);
            }
        }