Example #1
0
        public static void UpdateSlipNo(string companyId,
                                        string groupId,
                                        ExMySQLData db,
                                        geSlipKbn kbn,
                                        string accountPeriod,
                                        long no,
                                        long id)
        {
            StringBuilder sb;

            try
            {
                sb = new StringBuilder();

                sb.Append("UPDATE M_SLIP_MANAGEMENT " + Environment.NewLine);
                sb.Append("   SET ID = " + id.ToString() + Environment.NewLine);
                // 追加時
                if (no != 0)
                {
                    sb.Append("      ,NO = " + no.ToString() + Environment.NewLine);
                }
                sb.Append(" WHERE COMPANY_ID = " + companyId + Environment.NewLine);
                sb.Append("   AND GROUP_ID = " + groupId + Environment.NewLine);
                sb.Append("   AND SLIP_DIVISION = " + ((int)kbn).ToString() + Environment.NewLine);
                sb.Append("   AND YEAR = " + ExCast.zCInt(accountPeriod).ToString() + Environment.NewLine);
                sb.Append("   AND DELETE_FLG = 0 " + Environment.NewLine);

                db.ExecuteSQL(sb.ToString(), false);
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateSlipNo", ex);
                no = 0;
                id = 0;
                throw;
            }
        }
Example #2
0
        /// <summary>
        /// 伝票番号取得
        /// </summary>
        /// <param name="companyId">会社ID</param>
        /// <param name="groupId">グループID</param>
        /// <param name="db"></param>
        /// <param name="kbn">伝票区分</param>
        /// <param name="accountPeriod">会計年</param>
        /// <param name="no">伝票番号</param>
        /// <param name="id">伝票ID</param>
        /// <param name="ipAdress"></param>
        /// <param name="userId"></param>
        public static void GetSlipNo(string companyId,
                                     string groupId,
                                     ExMySQLData db,
                                     geSlipKbn kbn,
                                     string accountPeriod,
                                     ref long no,
                                     out long id,
                                     string ipAdress,
                                     string userId)
        {
            StringBuilder sb;
            DataTable     dt;

            bool exist = false;

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

                // 存在確認
                sb.Append("SELECT SM.* " + Environment.NewLine);
                sb.Append("  FROM M_SLIP_MANAGEMENT AS SM" + Environment.NewLine);
                sb.Append(" WHERE SM.COMPANY_ID = " + companyId + Environment.NewLine);
                sb.Append("   AND SM.GROUP_ID = " + groupId + Environment.NewLine);
                sb.Append("   AND SM.SLIP_DIVISION = " + ((int)kbn).ToString() + Environment.NewLine);
                sb.Append("   AND SM.YEAR = " + ExCast.zCInt(accountPeriod).ToString() + Environment.NewLine);
                sb.Append("   AND SM.DELETE_FLG = 0 " + Environment.NewLine);
                sb.Append(" LIMIT 0, 1" + Environment.NewLine);
                sb.Append(" FOR UPDATE");
                dt = db.GetDataTable(sb.ToString());

                if (dt.DefaultView.Count > 0)
                {
                    id = ExCast.zCLng(dt.DefaultView[0]["ID"]) + 1;
                    // 自動採番追加時
                    if (no == 0)
                    {
                        no = ExCast.zCLng(dt.DefaultView[0]["NO"]) + 1;
                    }
                }
                else
                {
                    if (no == 0)
                    {
                        no = 1;
                    }
                    id = 1;

                    sb.Length = 0;
                    sb.Append("INSERT INTO M_SLIP_MANAGEMENT " + Environment.NewLine);
                    sb.Append("       ( COMPANY_ID" + Environment.NewLine);
                    sb.Append("       , GROUP_ID" + Environment.NewLine);
                    sb.Append("       , SLIP_DIVISION" + Environment.NewLine);
                    sb.Append("       , YEAR" + Environment.NewLine);
                    sb.Append("       , ID" + Environment.NewLine);
                    sb.Append("       , NO" + 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("       ," + groupId + Environment.NewLine);                          // GROUP_ID
                    sb.Append("       ," + ((int)kbn).ToString() + Environment.NewLine);            // SLIP_DIVISION
                    sb.Append("       ," + ExCast.zCInt(accountPeriod) + Environment.NewLine);      // YEAR
                    sb.Append("       ," + id.ToString() + Environment.NewLine);                    // ID
                    sb.Append("       ," + no.ToString() + Environment.NewLine);                    // NO
                    sb.Append(CommonUtl.GetInsSQLCommonColums(CommonUtl.UpdKbn.Ins, "OrderInp", "T_ORDER_H", 9999, "0", ipAdress, userId));
                    sb.Append(")" + Environment.NewLine);

                    db.ExecuteSQL(sb.ToString(), false);
                }
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".GetSlipNo", ex);
                no = 0;
                id = 0;
                throw;
            }
        }
        /// <summary>
        /// 伝票番号取得
        /// </summary>
        /// <param name="companyId">会社ID</param>
        /// <param name="groupId">グループID</param>
        /// <param name="db"></param>
        /// <param name="kbn">伝票区分</param>
        /// <param name="accountPeriod">会計年</param>
        /// <param name="no">伝票番号</param>
        /// <param name="id">伝票ID</param>
        /// <param name="ipAdress"></param>
        /// <param name="userId"></param>
        public static void GetSlipNo(string companyId, 
                                     string groupId, 
                                     ExMySQLData db, 
                                     geSlipKbn kbn, 
                                     string accountPeriod, 
                                     ref long no,
                                     out long id, 
                                     string ipAdress, 
                                     string userId)
        {
            StringBuilder sb;
            DataTable dt;

            bool exist = false;

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

                // 存在確認
                sb.Append("SELECT SM.* " + Environment.NewLine);
                sb.Append("  FROM M_SLIP_MANAGEMENT AS SM" + Environment.NewLine);
                sb.Append(" WHERE SM.COMPANY_ID = " + companyId + Environment.NewLine);
                sb.Append("   AND SM.GROUP_ID = " + groupId + Environment.NewLine);
                sb.Append("   AND SM.SLIP_DIVISION = " + ((int)kbn).ToString() + Environment.NewLine);
                sb.Append("   AND SM.YEAR = " + ExCast.zCInt(accountPeriod).ToString() + Environment.NewLine);
                sb.Append("   AND SM.DELETE_FLG = 0 " + Environment.NewLine);
                sb.Append(" LIMIT 0, 1" + Environment.NewLine);
                sb.Append(" FOR UPDATE");
                dt = db.GetDataTable(sb.ToString());

                if (dt.DefaultView.Count > 0)
                {
                    id = ExCast.zCLng(dt.DefaultView[0]["ID"]) + 1;
                    // 自動採番追加時
                    if (no == 0)
                    {
                        no = ExCast.zCLng(dt.DefaultView[0]["NO"]) + 1;
                    }
                }
                else
                {
                    if (no == 0) no = 1;
                    id = 1;

                    sb.Length = 0;
                    sb.Append("INSERT INTO M_SLIP_MANAGEMENT " + Environment.NewLine);
                    sb.Append("       ( COMPANY_ID" + Environment.NewLine);
                    sb.Append("       , GROUP_ID" + Environment.NewLine);
                    sb.Append("       , SLIP_DIVISION" + Environment.NewLine);
                    sb.Append("       , YEAR" + Environment.NewLine);
                    sb.Append("       , ID" + Environment.NewLine);
                    sb.Append("       , NO" + 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("       ," + groupId + Environment.NewLine);                          // GROUP_ID
                    sb.Append("       ," + ((int)kbn).ToString() + Environment.NewLine);            // SLIP_DIVISION
                    sb.Append("       ," + ExCast.zCInt(accountPeriod) + Environment.NewLine);      // YEAR
                    sb.Append("       ," + id.ToString() + Environment.NewLine);                    // ID
                    sb.Append("       ," + no.ToString() + Environment.NewLine);                    // NO
                    sb.Append(CommonUtl.GetInsSQLCommonColums(CommonUtl.UpdKbn.Ins, "OrderInp", "T_ORDER_H", 9999, "0", ipAdress, userId));
                    sb.Append(")" + Environment.NewLine);

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

            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".GetSlipNo", ex);
                no = 0;
                id = 0;
                throw;
            }
        }
        public static void UpdateSlipNo(string companyId,
                                        string groupId,
                                        ExMySQLData db,
                                        geSlipKbn kbn,
                                        string accountPeriod,
                                        long no,
                                        long id)
        {
            StringBuilder sb;

            try
            {
                sb = new StringBuilder();

                sb.Append("UPDATE M_SLIP_MANAGEMENT " + Environment.NewLine);
                sb.Append("   SET ID = " + id.ToString() + Environment.NewLine);
                // 追加時
                if (no != 0)
                {
                    sb.Append("      ,NO = " + no.ToString() + Environment.NewLine);
                }
                sb.Append(" WHERE COMPANY_ID = " + companyId + Environment.NewLine);
                sb.Append("   AND GROUP_ID = " + groupId + Environment.NewLine);
                sb.Append("   AND SLIP_DIVISION = " + ((int)kbn).ToString() + Environment.NewLine);
                sb.Append("   AND YEAR = " + ExCast.zCInt(accountPeriod).ToString() + Environment.NewLine);
                sb.Append("   AND DELETE_FLG = 0 " + Environment.NewLine);

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

            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateSlipNo", ex);
                no = 0;
                id = 0;
                throw;
            }
        }