プロジェクト

全般

プロフィール

リビジョン 323

堀内ほぼ7年前に追加

管理マスタ:フォーマット変更(期末日を持つようにした)
日次処理:期末更新修正
会社情報入力系修正
工事情報入力:請求完了時入力ロック修正
掲示板入力:返信時書込み者バグ修正
期首・期末関連項目修正

差分を表示:

branches/src/DataCheckExcute/DataCheckExcute/Common/Process/ClsSystemOnceExecute.cs
1149 1149
        private bool UpDateSystemMaster()
1150 1150
        {
1151 1151
            IOMSystem SystemDB = new IOMSystem();
1152
            IOMBizPeriodHistory BizHisDB = new IOMBizPeriodHistory();
1152 1153
            try
1153 1154
            {
1154 1155
                SystemDB.connect(); SystemDB.beginTran();
1156
                BizHisDB.connect(); BizHisDB.beginTran();
1157

  
1155 1158
                StringBuilder strSQL = new StringBuilder();
1156

  
1157 1159
                // 営業期更新
1158
                strSQL.Append("Select SystemCode, BusinessPeriod, BusinessBeginningDate From systemmaster");
1159
                strSQL.Append(" Where DATE_FORMAT(NOW(), '%m/%d') = BusinessBeginningDate");
1160
                ArrayList arList = new ArrayList();
1161
                if (SystemDB.ExecuteReader(strSQL.ToString(), ref arList, false) && arList.Count > 0)
1160
                strSQL.Append(" Where DATE(NOW()) = DATE (BusinessCompDate)");
1161
                List<SystemMaster> SystemList = new List<SystemMaster>();
1162
                SystemDB.SelectAction(strSQL.ToString(), ref SystemList, false);
1163
                if (SystemList.Count > 0)
1162 1164
                {
1163
                    object[] objRec = (object[])arList[0];
1164
                    int syscode = CommonMotions.cnvInt(objRec[0]);
1165
                    int BusinessPeriod = CommonMotions.cnvInt(objRec[1]);
1166
                    if (!SystemDB.UpdateFeild(syscode, (int)IOMSystem.SystemColumn.BUSINESSPERIOD, ++BusinessPeriod, false))
1165
                    SystemMaster BizSysRec = SystemList[0];
1166
                    strSQL.Clear();
1167
                    strSQL.AppendFormat(" Where SystemCode = {0}", BizSysRec.SystemCode);
1168

  
1169
                    BizSysRec.BusinessPeriod++;
1170
                    BizSysRec.BusinessBeginDate = BizSysRec.BusinessCompDate.AddDays(1);
1171
                    BizSysRec.BusinessCompDate = BizSysRec.BusinessCompDate.AddYears(1);
1172
                    if (!SystemDB.UpdateAction(strSQL.ToString(), BizSysRec, false))
1167 1173
                    {
1168 1174
                        SystemDB.rollback();
1169 1175
                        return false;
1170 1176
                    }
1177

  
1178
                    /// 運営期履歴情報登録
1179
                    if (!BizPeriodHistoryDataEntry(BizHisDB, BizSysRec, (int)BizPeriodHistory.PeriodFlagDef.BizPeriod))
1180
                    {
1181
                        SystemDB.rollback();
1182
                        BizHisDB.rollback();
1183
                        return false;
1184
                    }
1171 1185
                }
1172 1186

  
1173 1187
                // 工事年度更新
1174 1188
                strSQL.Clear();
1175
                strSQL.Append("Select SystemCode, ConstructionYear, ConstructionBeginningDate From systemmaster");
1176
                strSQL.Append(" Where DATE_FORMAT(NOW(), '%m/%d') = ConstructionBeginningDate");
1177
                arList.Clear();
1178
                if (SystemDB.ExecuteReader(strSQL.ToString(), ref arList, false) && arList.Count > 0)
1189
                strSQL.Append(" Where DATE(NOW()) = DATE (ConstrCompDate)");
1190
                SystemList.Clear();
1191
                SystemDB.SelectAction(strSQL.ToString(), ref SystemList, false);
1192
                if (SystemList.Count > 0)
1179 1193
                {
1180
                    object[] objRec = (object[])arList[0];
1181
                    int syscode = CommonMotions.cnvInt(objRec[0]);
1182
                    int ConstrBeginDate = CommonMotions.cnvInt(objRec[1]);
1183
                    if (!SystemDB.UpdateFeild(syscode, (int)IOMSystem.SystemColumn.ConstructionYear, ++ConstrBeginDate, false))
1194
                    SystemMaster ConstrSysRec = SystemList[0];
1195
                    strSQL.Clear();
1196
                    strSQL.AppendFormat(" Where SystemCode = {0}", ConstrSysRec.SystemCode);
1197

  
1198
                    ConstrSysRec.ConstrYear++;
1199
                    ConstrSysRec.ConstrBeginDate = ConstrSysRec.ConstrCompDate.AddDays(1);
1200
                    ConstrSysRec.ConstrCompDate = ConstrSysRec.ConstrCompDate.AddYears(1);
1201
                    if (!SystemDB.UpdateAction(strSQL.ToString(), ConstrSysRec, false))
1184 1202
                    {
1185 1203
                        SystemDB.rollback();
1204
                        BizHisDB.rollback();
1186 1205
                        return false;
1187 1206
                    }
1207

  
1208

  
1209
                    /// 運営期履歴情報登録
1210
                    if (!BizPeriodHistoryDataEntry(BizHisDB, ConstrSysRec, (int)BizPeriodHistory.PeriodFlagDef.ConstrYear))
1211
                    {
1212
                        SystemDB.rollback();
1213
                        BizHisDB.rollback();
1214
                        return false;
1215
                    }
1188 1216
                }
1189 1217

  
1190 1218
                SystemDB.commit();
1219
                BizHisDB.commit();
1191 1220
                return true;
1192 1221
            }
1193 1222
            catch (Exception ex)
......
1198 1227
            finally
1199 1228
            {
1200 1229
                SystemDB.close(); SystemDB = null;
1230
                BizHisDB.close(); BizHisDB = null;
1201 1231
            }
1202 1232
        }
1203 1233
        #endregion
1234

  
1235
        #region 運営期履歴情報登録
1236
        /// <summary>
1237
        /// 運営期履歴情報登録
1238
        /// </summary>
1239
        /// <returns></returns>
1240
        private bool BizPeriodHistoryDataEntry(IOMBizPeriodHistory BizHisDB, SystemMaster SysRec, int nPeriodFlag)
1241
        {
1242
            try
1243
            {
1244

  
1245
                int nData = 0;
1246
                DateTime[] dtData = new DateTime[2];
1247
                StringBuilder strSQL = new StringBuilder();
1248
                for (int ix = 0; ix < 2; ix++)
1249
                {
1250
                    switch (nPeriodFlag)
1251
                    {
1252
                        case (int)BizPeriodHistory.PeriodFlagDef.BizPeriod:
1253
                            if (ix == 0)
1254
                            {
1255
                                nData = SysRec.BusinessPeriod;
1256
                                dtData[0] = SysRec.BusinessBeginDate;
1257
                                dtData[1] = SysRec.BusinessCompDate;
1258
                            }
1259
                            else
1260
                            {
1261
                                nData = SysRec.BusinessPeriod + 1;
1262
                                dtData[0] = SysRec.BusinessCompDate.AddDays(1);
1263
                                dtData[1] = SysRec.BusinessCompDate.AddYears(1);
1264
                            }
1265
                            break;
1266
                        case (int)BizPeriodHistory.PeriodFlagDef.ConstrYear:
1267
                            if (ix == 0)
1268
                            {
1269
                                nData = SysRec.ConstrYear;
1270
                                dtData[0] = SysRec.ConstrBeginDate;
1271
                                dtData[1] = SysRec.ConstrCompDate;
1272
                            }
1273
                            else
1274
                            {
1275
                                nData = SysRec.ConstrYear + 1;
1276
                                dtData[0] = SysRec.ConstrCompDate.AddDays(1);
1277
                                dtData[1] = SysRec.ConstrCompDate.AddYears(1);
1278
                            }
1279
                            break;
1280
                    }
1281

  
1282
                    strSQL.Clear();
1283
                    strSQL.Append(BizHisDB.CreatePrimarykeyString(nData, nPeriodFlag));
1284
                    List<BizPeriodHistory> BizHisList = new List<BizPeriodHistory>();
1285
                    if (!BizHisDB.SelectAction(strSQL.ToString(), ref BizHisList))
1286
                    {
1287
                        return false;
1288
                    }
1289

  
1290
                    BizPeriodHistory BizHisRec = new BizPeriodHistory();
1291
                    BizHisRec.PeriodYear = nData;               // 営業期数・工事年度
1292
                    BizHisRec.PeriodFlag = nPeriodFlag;         // 営業期数・工事年度フラグ
1293

  
1294
                    BizHisRec.BeginDate = dtData[0];            // 期首日
1295
                    BizHisRec.CompleteDate = dtData[1];         // 期末日
1296

  
1297
                    if (BizHisList.Count < 1)
1298
                    {
1299
                        // データがない場合
1300
                        // データ登録
1301
                        if (!BizHisDB.InsertAction(BizHisRec))
1302
                        {
1303
                            return false;
1304
                        }
1305
                    }
1306
                    else
1307
                    {
1308
                        // データがある場合
1309
                        // データ更新
1310
                        if (!BizHisDB.UpdateAction(strSQL.ToString(), BizHisRec))
1311
                        {
1312
                            return false;
1313
                        }
1314
                    }
1315
                }
1316

  
1317
                return true;
1318
            }
1319
            catch (System.Exception ex)
1320
            {
1321
                logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
1322
                return false;
1323
            }
1324
        }
1325
        #endregion
1204 1326
    }
1205 1327
}
branches/src/DataCheckExcute/DataCheckExcute/DataCheckExcute.csproj
103 103
    <Compile Include="..\..\ProcessManagement\ProcessManagement\DataModel\BillingPaymentSummary.cs">
104 104
      <Link>DataModel\BillingPaymentSummary.cs</Link>
105 105
    </Compile>
106
    <Compile Include="..\..\ProcessManagement\ProcessManagement\DataModel\BizPeriodHistory.cs">
107
      <Link>DataModel\BizPeriodHistory.cs</Link>
108
    </Compile>
106 109
    <Compile Include="..\..\ProcessManagement\ProcessManagement\DataModel\BusinessTypeMaster.cs">
107 110
      <Link>DataModel\BusinessTypeMaster.cs</Link>
108 111
    </Compile>
......
250 253
    <Compile Include="..\..\ProcessManagement\ProcessManagement\DataModel\ExpensesMaster.cs">
251 254
      <Link>DataModel\ExpensesMaster.cs</Link>
252 255
    </Compile>
256
    <Compile Include="..\..\ProcessManagement\ProcessManagement\DataModel\GridCellStyleMember.cs">
257
      <Link>DataModel\GridCellStyleMember.cs</Link>
258
    </Compile>
253 259
    <Compile Include="..\..\ProcessManagement\ProcessManagement\DataModel\HolidayCalenderMaster.cs">
254 260
      <Link>DataModel\HolidayCalenderMaster.cs</Link>
255 261
    </Compile>
......
550 556
    <Compile Include="..\..\ProcessManagement\ProcessManagement\DB\IOAccess\IOMaterialTypes.cs">
551 557
      <Link>DB\IOAccess\IOMaterialTypes.cs</Link>
552 558
    </Compile>
559
    <Compile Include="..\..\ProcessManagement\ProcessManagement\DB\IOAccess\IOMBizPeriodHistory.cs">
560
      <Link>DB\IOAccess\IOMBizPeriodHistory.cs</Link>
561
    </Compile>
553 562
    <Compile Include="..\..\ProcessManagement\ProcessManagement\DB\IOAccess\IOMBusinessType.cs">
554 563
      <Link>DB\IOAccess\IOMBusinessType.cs</Link>
555 564
    </Compile>
branches/src/ProcessManagement/ProcessManagement/Common/CommonMotions.cs
1630 1630
        }
1631 1631
        #endregion
1632 1632

  
1633
        #region 日付より年を取得する
1634
        /// <summary>
1635
        /// 日付より年を取得する
1636
        /// </summary>
1637
        /// <returns></returns>
1638
        public static int DateToPeriodYear(DateTime TargetDate)
1639
        {
1640
            try
1641
            {
1642
                // 今の年を取得する
1643
                int iYear = DateTime.Now.Year;
1644
                // 今年の期首日を取得する
1645
                DateTime BeginninDate = DateTime.Parse(iYear.ToString() + "/" + CommonMotions.SystemMasterData.BusinessBeginningDate);
1646
                // 日付を今年の期首日と比較して小さい場合は今の年より-1して期首年を求める
1647
                if (TargetDate.Date < BeginninDate.Date)
1648
                    --iYear;
1649

  
1650
                return iYear;
1651
            }
1652
            catch (Exception ex)
1653
            {
1654
                logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
1655
                return 0;
1656
            }
1657
        }
1658
        #endregion
1659

  
1660 1633
        #region 期数から期の年を取得する
1661 1634
        /// <summary>
1662 1635
        /// 期数から期の年を取得する
......
1665 1638
        /// <returns></returns>
1666 1639
        public static int PeriodCountToYear(int PeriodCount)
1667 1640
        {
1641
            IOMBizPeriodHistory BizHisDB = new IOMBizPeriodHistory();
1668 1642
            try
1669 1643
            {
1670 1644
                // 今の年を取得する
1671 1645
                int iYear = DateTime.Now.Year;
1672
                // 今年の期首日を取得する
1673
                DateTime BeginninDate = DateTime.Parse(iYear.ToString() + "/" + CommonMotions.SystemMasterData.BusinessBeginningDate);
1674
                // 今日を今年の期首日と比較して小さい場合は今の年より-1して期首年を求める
1675
                if (DateTime.Now.Date < BeginninDate.Date)
1676
                    --iYear;
1677 1646

  
1678
                // 管理マスタの期数と比較して年を計算する
1679
                if (PeriodCount < CommonMotions.SystemMasterData.BusinessPeriod)
1680
                {
1681
                    iYear -= (CommonMotions.SystemMasterData.BusinessPeriod - PeriodCount);
1682
                }
1683
                else if (PeriodCount > CommonMotions.SystemMasterData.BusinessPeriod)
1684
                {
1685
                    iYear += (PeriodCount - CommonMotions.SystemMasterData.BusinessPeriod);
1686
                }
1647
                StringBuilder strSQL = new StringBuilder();
1648
                BizPeriodHistory BizHisRec = new BizPeriodHistory();
1687 1649

  
1650
                // 営業期
1651
                strSQL.Append(BizHisDB.CreatePrimarykeyString(PeriodCount, (int)BizPeriodHistory.PeriodFlagDef.BizPeriod));
1652

  
1653
                // 運営期履歴情報読込
1654
                if (!BizHisDB.SelectAction(strSQL.ToString(), ref BizHisRec)) return iYear;
1655

  
1656
                iYear = BizHisRec.BeginDate.Year;
1657

  
1688 1658
                return iYear;
1689 1659
            }
1690 1660
            catch (Exception ex)
......
1692 1662
                logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
1693 1663
                return 0;
1694 1664
            }
1665
            finally
1666
            {
1667
                BizHisDB.close(); BizHisDB = null;
1668
            }
1695 1669
        }
1696 1670
        #endregion
1697 1671

  
......
1738 1712
            if (m_systemMaster.ConstructionNoBase == (int)SystemMaster.ConstrNoBaseDef.BusinessPeriod)
1739 1713
                nRetVal = m_systemMaster.BusinessPeriod;
1740 1714
            else
1741
                nRetVal = m_systemMaster.ConstructionYear;
1715
                nRetVal = m_systemMaster.ConstrYear;
1742 1716
            try
1743 1717
            {
1744 1718

  
......
1902 1876
                diffwork = Period - CommonMotions.SystemMasterData.BusinessPeriod;
1903 1877

  
1904 1878
                // 期首月を取得する
1905
                strwork = CommonMotions.SystemMasterData.BusinessBeginningDate;
1906
                strwork = strwork.Substring(0, strwork.IndexOf("/"));
1879
                Beginning = CommonMotions.SystemMasterData.BusinessBeginDate.Month;
1907 1880

  
1908
                // 期首月を数値変換
1909
                Beginning = CommonMotions.cnvInt(strwork);
1910

  
1911 1881
                // 年数を求める
1912 1882
                DateTime dateWork = DateTime.Now;
1913 1883
                int nowMounth = DateTime.Now.Month;
......
2255 2225
                    diffwork = years - CommonMotions.SystemMasterData.BusinessPeriod;
2256 2226

  
2257 2227
                    // 期首月を取得する
2258
                    strwork = CommonMotions.SystemMasterData.BusinessBeginningDate;
2259
                    strwork = strwork.Substring(0, strwork.IndexOf("/"));
2228
                    Beginning = CommonMotions.SystemMasterData.BusinessBeginDate.Month;
2260 2229
                }
2261 2230
                else
2262 2231
                {   // ----- 営業年度ベースの時
2263 2232

  
2264 2233
                    // 現在期との差分を求める
2265
                    diffwork = years - CommonMotions.SystemMasterData.ConstructionYear;
2234
                    diffwork = years - CommonMotions.SystemMasterData.ConstrYear;
2266 2235

  
2267 2236
                    // 期首月を取得する
2268
                    strwork = CommonMotions.SystemMasterData.ConstructionBeginningDate;
2269
                    strwork = strwork.Substring(0, strwork.IndexOf("/"));
2237
                    Beginning = CommonMotions.SystemMasterData.ConstrBeginDate.Month;
2270 2238
                }
2271 2239

  
2272
                // 期首月を数値変換
2273
                Beginning = CommonMotions.cnvInt(strwork);
2274

  
2275 2240
                // 年数を求める
2276 2241
                DateTime dateWork = DateTime.Now;
2277 2242
                int nowMounth = DateTime.Now.Month;
......
2300 2265
        /// <param name="bPeriod"></param>
2301 2266
        /// <param name="Mounth"></param>
2302 2267
        /// <param name="Days"></param>
2303
        public static void GetBeginningMonthDay(bool bPeriod, ref int Mounth, ref int Days)
2268
        public static void GetNowBeginMonthDay(bool bPeriod, ref int Mounth, ref int Days)
2304 2269
        {
2305 2270
            try
2306 2271
            {
2307
                string strwork = string.Empty;
2308 2272
                if (bPeriod)
2309 2273
                {   // 営業期
2310
                    strwork = CommonMotions.SystemMasterData.BusinessBeginningDate;
2274
                    Mounth = CommonMotions.SystemMasterData.BusinessBeginDate.Month;
2275
                    Days = CommonMotions.SystemMasterData.BusinessBeginDate.Day;
2311 2276
                }
2312 2277
                else
2313 2278
                {   // 工事年度
2314
                    strwork = CommonMotions.SystemMasterData.ConstructionBeginningDate;
2279
                    Mounth = CommonMotions.SystemMasterData.ConstrBeginDate.Month;
2280
                    Days = CommonMotions.SystemMasterData.ConstrBeginDate.Day;
2315 2281
                }
2316
                string[] strArray = strwork.Split('/');
2317
                Mounth = CommonMotions.cnvInt(strArray[0]);
2318
                Days = CommonMotions.cnvInt(strArray[1]);
2319

  
2320 2282
            }
2321 2283
            catch (System.Exception ex)
2322 2284
            {
......
2335 2297
        /// <returns></returns>
2336 2298
        public static DateTime GetOpeningEndDate(int nYear, bool bOpen = true, bool bPeriod = true)
2337 2299
        {
2300
            IOMBizPeriodHistory BizHisDB = new IOMBizPeriodHistory();
2338 2301
            try
2339 2302
            {
2340
                DateTime dtRet = DateTime.Today;
2303
                DateTime dtRet = DateTime.Now.Date;
2341 2304

  
2342
                string strwork = string.Empty;
2343
                int TargetYear = DateTime.Today.Year;
2305
                StringBuilder strSQL = new StringBuilder();
2306
                BizPeriodHistory BizHisRec = new BizPeriodHistory();
2344 2307

  
2345 2308
                if (bPeriod)
2346 2309
                {   // 営業期
2347
                    strwork = CommonMotions.SystemMasterData.BusinessBeginningDate;
2348
                    TargetYear = BusinessPeriodToConstructionYears(nYear);
2310
                    strSQL.Append(BizHisDB.CreatePrimarykeyString(nYear, (int)BizPeriodHistory.PeriodFlagDef.BizPeriod));
2349 2311
                }
2350 2312
                else
2351 2313
                {   // 工事年度
2352
                    strwork = CommonMotions.SystemMasterData.ConstructionBeginningDate;
2353
                    TargetYear = nYear;
2314
                    strSQL.Append(BizHisDB.CreatePrimarykeyString(nYear, (int)BizPeriodHistory.PeriodFlagDef.ConstrYear));
2354 2315
                }
2355
                // 月・日分割
2356
                string[] DateArray = strwork.Split('/');
2357 2316

  
2358
                // 年月日作成
2359
                dtRet = new DateTime(TargetYear, int.Parse(DateArray[0]), int.Parse(DateArray[1]));
2317
                // 運営期履歴情報読込
2318
                if (!BizHisDB.SelectAction(strSQL.ToString(), ref BizHisRec)) return dtRet;
2360 2319

  
2361
                // 期末取得時
2362
                if (!bOpen)
2320
                if (bOpen)
2363 2321
                {
2364
                    dtRet = dtRet.AddYears(1).AddDays(-1);
2322
                    // 期首取得時
2323
                    dtRet = BizHisRec.BeginDate;
2365 2324
                }
2325
                else
2326
                {
2327
                    // 期末取得時
2328
                    dtRet = BizHisRec.CompleteDate;
2329
                }
2366 2330

  
2367 2331
                return dtRet;
2368 2332
            }
......
2371 2335
                logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
2372 2336
                return DateTime.Today;
2373 2337
            }
2338
            finally
2339
            {
2340
                BizHisDB.close(); BizHisDB = null;
2341
            }
2374 2342
        }
2375 2343
        #endregion
2376 2344

  
branches/src/ProcessManagement/ProcessManagement/Common/CommonVersion.cs
14 14
        /// <summary>
15 15
        /// 本体バージョン
16 16
        /// </summary>
17
        public static int s_SystemVersion = 146;
17
        public static int s_SystemVersion = 148;
18 18

  
19 19
        /// <summary>
20 20
        /// コピー・環境バージョン
branches/src/ProcessManagement/ProcessManagement/Common/Process/ClsSystemOnceExecute.cs
1158 1158
        private bool UpDateSystemMaster()
1159 1159
        {
1160 1160
            IOMSystem SystemDB = new IOMSystem();
1161
            IOMBizPeriodHistory BizHisDB = new IOMBizPeriodHistory();
1161 1162
            try
1162 1163
            {
1163 1164
                SystemDB.connect(); SystemDB.beginTran();
1165
                BizHisDB.connect(); BizHisDB.beginTran();
1166

  
1164 1167
                StringBuilder strSQL = new StringBuilder();
1165

  
1166 1168
                // 営業期更新
1167
                strSQL.Append("Select SystemCode, BusinessPeriod, BusinessBeginningDate From systemmaster");
1168
                strSQL.Append(" Where DATE_FORMAT(NOW(), '%m/%d') = BusinessBeginningDate");
1169
                ArrayList arList = new ArrayList();
1170
                if (SystemDB.ExecuteReader(strSQL.ToString(), ref arList, false) && arList.Count > 0)
1169
                strSQL.Append(" Where DATE(NOW()) = DATE (BusinessCompDate)");
1170
                List<SystemMaster> SystemList = new List<SystemMaster>();
1171
                SystemDB.SelectAction(strSQL.ToString(), ref SystemList, false);
1172
                if (SystemList.Count > 0)
1171 1173
                {
1172
                    object[] objRec = (object[])arList[0];
1173
                    int syscode = CommonMotions.cnvInt(objRec[0]);
1174
                    int BusinessPeriod = CommonMotions.cnvInt(objRec[1]);
1175
                    if (!SystemDB.UpdateFeild(syscode, (int)IOMSystem.SystemColumn.BUSINESSPERIOD, ++BusinessPeriod, false))
1174
                    SystemMaster BizSysRec = SystemList[0];
1175
                    strSQL.Clear();
1176
                    strSQL.AppendFormat(" Where SystemCode = {0}", BizSysRec.SystemCode);
1177

  
1178
                    BizSysRec.BusinessPeriod++;
1179
                    BizSysRec.BusinessBeginDate = BizSysRec.BusinessCompDate.AddDays(1);
1180
                    BizSysRec.BusinessCompDate = BizSysRec.BusinessCompDate.AddYears(1);
1181
                    if (!SystemDB.UpdateAction(strSQL.ToString(), BizSysRec, false))
1176 1182
                    {
1177 1183
                        SystemDB.rollback();
1178 1184
                        return false;
1179 1185
                    }
1186

  
1187
                    /// 運営期履歴情報登録
1188
                    if (!BizPeriodHistoryDataEntry(BizHisDB, BizSysRec, (int)BizPeriodHistory.PeriodFlagDef.BizPeriod))
1189
                    {
1190
                        SystemDB.rollback();
1191
                        BizHisDB.rollback();
1192
                        return false;
1193
                    }
1180 1194
                }
1181 1195

  
1182 1196
                // 工事年度更新
1183 1197
                strSQL.Clear();
1184
                strSQL.Append("Select SystemCode, ConstructionYear, ConstructionBeginningDate From systemmaster");
1185
                strSQL.Append(" Where DATE_FORMAT(NOW(), '%m/%d') = ConstructionBeginningDate");
1186
                arList.Clear();
1187
                if (SystemDB.ExecuteReader(strSQL.ToString(), ref arList, false) && arList.Count > 0)
1198
                strSQL.Append(" Where DATE(NOW()) = DATE (ConstrCompDate)");
1199
                SystemList.Clear();
1200
                SystemDB.SelectAction(strSQL.ToString(), ref SystemList, false);
1201
                if (SystemList.Count > 0)
1188 1202
                {
1189
                    object[] objRec = (object[])arList[0];
1190
                    int syscode = CommonMotions.cnvInt(objRec[0]);
1191
                    int ConstrBeginDate = CommonMotions.cnvInt(objRec[1]);
1192
                    if (!SystemDB.UpdateFeild(syscode, (int)IOMSystem.SystemColumn.ConstructionYear, ++ConstrBeginDate, false))
1203
                    SystemMaster ConstrSysRec = SystemList[0];
1204
                    strSQL.Clear();
1205
                    strSQL.AppendFormat(" Where SystemCode = {0}", ConstrSysRec.SystemCode);
1206

  
1207
                    ConstrSysRec.ConstrYear++;
1208
                    ConstrSysRec.ConstrBeginDate = ConstrSysRec.ConstrCompDate.AddDays(1);
1209
                    ConstrSysRec.ConstrCompDate = ConstrSysRec.ConstrCompDate.AddYears(1);
1210
                    if (!SystemDB.UpdateAction(strSQL.ToString(), ConstrSysRec, false))
1193 1211
                    {
1194 1212
                        SystemDB.rollback();
1213
                        BizHisDB.rollback();
1195 1214
                        return false;
1196 1215
                    }
1216

  
1217

  
1218
                    /// 運営期履歴情報登録
1219
                    if (!BizPeriodHistoryDataEntry(BizHisDB, ConstrSysRec, (int)BizPeriodHistory.PeriodFlagDef.ConstrYear))
1220
                    {
1221
                        SystemDB.rollback();
1222
                        BizHisDB.rollback();
1223
                        return false;
1224
                    }
1197 1225
                }
1198 1226

  
1199 1227
                SystemDB.commit();
1228
                BizHisDB.commit();
1200 1229
                return true;
1201 1230
            }
1202 1231
            catch (Exception ex)
......
1207 1236
            finally
1208 1237
            {
1209 1238
                SystemDB.close(); SystemDB = null;
1239
                BizHisDB.close(); BizHisDB = null;
1210 1240
            }
1211 1241
        }
1212 1242
        #endregion
1243

  
1244
        #region 運営期履歴情報登録
1245
        /// <summary>
1246
        /// 運営期履歴情報登録
1247
        /// </summary>
1248
        /// <returns></returns>
1249
        private bool BizPeriodHistoryDataEntry(IOMBizPeriodHistory BizHisDB, SystemMaster SysRec, int nPeriodFlag)
1250
        {
1251
            try
1252
            {
1253

  
1254
                int nData = 0;
1255
                DateTime[] dtData = new DateTime[2];
1256
                StringBuilder strSQL = new StringBuilder();
1257
                for (int ix = 0; ix < 2; ix++)
1258
                {
1259
                    switch (nPeriodFlag)
1260
                    {
1261
                        case (int)BizPeriodHistory.PeriodFlagDef.BizPeriod:
1262
                            if (ix == 0)
1263
                            {
1264
                                nData = SysRec.BusinessPeriod;
1265
                                dtData[0] = SysRec.BusinessBeginDate;
1266
                                dtData[1] = SysRec.BusinessCompDate;
1267
                            }
1268
                            else
1269
                            {
1270
                                nData = SysRec.BusinessPeriod + 1;
1271
                                dtData[0] = SysRec.BusinessCompDate.AddDays(1);
1272
                                dtData[1] = SysRec.BusinessCompDate.AddYears(1);
1273
                            }
1274
                            break;
1275
                        case (int)BizPeriodHistory.PeriodFlagDef.ConstrYear:
1276
                            if (ix == 0)
1277
                            {
1278
                                nData = SysRec.ConstrYear;
1279
                                dtData[0] = SysRec.ConstrBeginDate;
1280
                                dtData[1] = SysRec.ConstrCompDate;
1281
                            }
1282
                            else
1283
                            {
1284
                                nData = SysRec.ConstrYear + 1;
1285
                                dtData[0] = SysRec.ConstrCompDate.AddDays(1);
1286
                                dtData[1] = SysRec.ConstrCompDate.AddYears(1);
1287
                            }
1288
                            break;
1289
                    }
1290

  
1291
                    strSQL.Clear();
1292
                    strSQL.Append(BizHisDB.CreatePrimarykeyString(nData, nPeriodFlag));
1293
                    List<BizPeriodHistory> BizHisList = new List<BizPeriodHistory>();
1294
                    if (!BizHisDB.SelectAction(strSQL.ToString(), ref BizHisList))
1295
                    {
1296
                        return false;
1297
                    }
1298

  
1299
                    BizPeriodHistory BizHisRec = new BizPeriodHistory();
1300
                    BizHisRec.PeriodYear = nData;               // 営業期数・工事年度
1301
                    BizHisRec.PeriodFlag = nPeriodFlag;         // 営業期数・工事年度フラグ
1302

  
1303
                    BizHisRec.BeginDate = dtData[0];            // 期首日
1304
                    BizHisRec.CompleteDate = dtData[1];         // 期末日
1305

  
1306
                    if (BizHisList.Count < 1)
1307
                    {
1308
                        // データがない場合
1309
                        // データ登録
1310
                        if (!BizHisDB.InsertAction(BizHisRec))
1311
                        {
1312
                            return false;
1313
                        }
1314
                    }
1315
                    else
1316
                    {
1317
                        // データがある場合
1318
                        // データ更新
1319
                        if (!BizHisDB.UpdateAction(strSQL.ToString(), BizHisRec))
1320
                        {
1321
                            return false;
1322
                        }
1323
                    }
1324
                }
1325

  
1326
                return true;
1327
            }
1328
            catch (System.Exception ex)
1329
            {
1330
                logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
1331
                return false;
1332
            }
1333
        }
1334
        #endregion
1213 1335
    }
1214 1336
}
branches/src/ProcessManagement/ProcessManagement/DB/IOAccess/IOConstructionBaseInfo.cs
973 973
                    diffwork = PeriodValue - CommonMotions.SystemMasterData.BusinessPeriod;
974 974

  
975 975
                    // 期首月を取得する
976
                    strwork = CommonMotions.SystemMasterData.BusinessBeginningDate;
977
                    strwork = strwork.Substring(0, strwork.IndexOf("/"));
976
                    Beginning = CommonMotions.SystemMasterData.BusinessBeginDate.Month;
978 977
                }
979 978
                else
980 979
                {   // ----- 営業年度ベースの時
981 980

  
982 981
                    // 現在期との差分を求める
983
                    diffwork = PeriodValue - CommonMotions.SystemMasterData.ConstructionYear;
982
                    diffwork = PeriodValue - CommonMotions.SystemMasterData.ConstrYear;
984 983

  
985 984
                    // 期首月を取得する
986
                    strwork = CommonMotions.SystemMasterData.ConstructionBeginningDate;
987
                    strwork = strwork.Substring(0, strwork.IndexOf("/"));
985
                    Beginning = CommonMotions.SystemMasterData.ConstrBeginDate.Month;
988 986
                }
989 987

  
990
                // 期首月を数値変換
991
                Beginning = CommonMotions.cnvInt(strwork);
992

  
993 988
                // 年数を求める
994 989
                DateTime dateWork = DateTime.Now;
995 990
                int nowMounth = DateTime.Now.Month;
branches/src/ProcessManagement/ProcessManagement/DB/IOAccess/IOMBizPeriodHistory.cs
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Data;
6
using System.Collections;
7

  
8
using log4net;
9
using MySql.Data.MySqlClient;           // Data Provider for MySql
10

  
11
using ProcessManagement.DB.MySql;
12
using ProcessManagement.DB.Core;
13
using ProcessManagement.DataModel;
14

  
15
using ProcessManagement.Common;
16

  
17
namespace ProcessManagement.DB.IOAccess
18
{
19
    /// <summary>
20
    /// 運営期履歴情報DBアクセス
21
    /// </summary>
22
    public class IOMBizPeriodHistory : MySqlProcess
23
    {
24
        #region 定義部
25
        /// <summary>
26
        /// log4netログを使用する
27
        /// </summary>
28
        private static readonly ILog logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
29
        #endregion
30

  
31
        #region 定数
32
        /// <summary>
33
        /// 運営期履歴情報フィールド並び
34
        /// </summary>
35
        public enum TableColumn
36
        {
37
            PeriodYear = 0,
38
            PeriodFlag,
39
            BeginDate,
40
            CompleteDate,
41
            EntryDate,
42
            UpdateDate
43
        }
44
        #endregion
45

  
46
        #region コンストラクタ
47
        /// <summary>
48
        /// コンストラクタ
49
        /// </summary>
50
        /// <param name="ConnectionString"></param>
51
        public IOMBizPeriodHistory()
52
            : base(DBCommon.Instance.DBConnectString)
53
        {
54
        }
55

  
56
        #endregion
57

  
58
        #region 運営期履歴情報検索文字作成
59
        /// <summary>
60
        /// 運営期履歴情報検索文字作成
61
        /// </summary>
62
        /// <param name="AddSQLString">検索条件SQL文字列</param>
63
        /// <param name="data">システムマスタデータ</param>
64
        /// <returns>true:成功 false:失敗</returns>
65
        private string CreateSelectSQL()
66
        {
67
            // SQL作成
68
            StringBuilder strcmd = new StringBuilder();
69
            strcmd.Append("SELECT");
70
            strcmd.Append(" PeriodYear");
71
            strcmd.Append(", PeriodFlag");
72
            strcmd.Append(", BeginDate");
73
            strcmd.Append(", CompleteDate");
74
            strcmd.Append(", DATE_FORMAT(EntryDate, '%Y/%m/%d %H:%i:%s')");
75
            strcmd.Append(", DATE_FORMAT(UpdateDate, '%Y/%m/%d %H:%i:%s')");
76
            strcmd.Append(" FROM BizPeriodHistory");
77

  
78
            return strcmd.ToString();
79
        }
80
        #endregion
81

  
82
        #region 運営期履歴情報検索(複数)
83
        /// <summary>
84
        /// 運営期履歴情報検索(複数)
85
        /// </summary>
86
        /// <param name="AddSQLString"></param>
87
        /// <param name="data"></param>
88
        /// <param name="bConnect"></param>
89
        /// <returns></returns>
90
        public bool SelectAction(string AddSQLString, ref List<BizPeriodHistory> data, bool bConnect = true)
91
        {
92
            // インターフェース
93
            StringBuilder strcmd = new StringBuilder();
94
            ArrayList arData = new ArrayList();
95

  
96
            try
97
            {
98
                // SQL作成
99
                strcmd.Append(CreateSelectSQL());
100
                strcmd.Append(AddSQLString);
101

  
102
                // SQL実行
103
                if (!ExecuteReader(strcmd.ToString(), ref arData, bConnect)) return false;
104

  
105
                // データセット
106
                foreach (object[] objwrk in arData)
107
                {
108
                    BizPeriodHistory work = new BizPeriodHistory();
109
                    Reader2Struct(objwrk, ref work);
110
                    data.Add(work);
111
                }
112

  
113
                return true;
114
            }
115
            catch (Exception ex)
116
            {
117
                logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd.ToString());
118
                return false;
119
            }
120
        }
121
        #endregion
122

  
123
        #region 運営期履歴情報検索(1件)
124
        /// <summary>
125
        /// 運営期履歴情報検索(1件)
126
        /// </summary>
127
        /// <param name="AddSQLString"></param>
128
        /// <param name="data"></param>
129
        /// <param name="bConnect"></param>
130
        /// <returns></returns>
131
        public bool SelectAction(string AddSQLString, ref BizPeriodHistory data, bool bConnect = true)
132
        {
133
            // インターフェース
134
            StringBuilder strcmd = new StringBuilder();
135
            ArrayList arData = new ArrayList();
136

  
137
            try
138
            {
139
                // SQL作成
140
                strcmd.Append(CreateSelectSQL());
141
                strcmd.Append(AddSQLString);
142

  
143
                // SQL実行
144
                if (!ExecuteReader(strcmd.ToString(), ref arData, bConnect)) return false;
145
                if (arData.Count == 0) return false;
146
                // データセット
147
                foreach (object[] objwrk in arData)
148
                {
149
                    Reader2Struct(objwrk, ref data);
150
                    break;
151
                }
152

  
153
                return true;
154
            }
155
            catch (Exception ex)
156
            {
157
                logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd.ToString());
158
                return false;
159
            }
160
        }
161
        #endregion
162

  
163
        #region 運営期履歴情報検索追加処理(1件)
164
        /// <summary>
165
        /// 運営期履歴情報検索追加
166
        /// </summary>
167
        /// <param name="data">運営期履歴情報検索データ</param>
168
        /// <returns>true:成功 false:失敗</returns>
169
        public bool InsertAction(BizPeriodHistory data, bool bConnect = true)
170
        {
171
            StringBuilder strcmd = new StringBuilder();
172
            try
173
            {
174
                strcmd.Append("INSERT INTO BizPeriodHistory");
175

  
176
                strcmd.Append("(");
177
                bool bFirst = true;
178
                foreach (var gender in Enum.GetValues(typeof(TableColumn)))
179
                {
180
                    if (!bFirst) strcmd.Append(" ,");
181
                    strcmd.Append(gender.ToString());
182
                    bFirst = false;
183
                }
184
                strcmd.Append(") VALUES (");
185

  
186
                strcmd.AppendFormat("  {0}", data.PeriodYear);
187
                strcmd.AppendFormat(", {0}", data.PeriodFlag);
188
                strcmd.AppendFormat(", STR_TO_DATE('{0}','%Y/%m/%d')", data.BeginDate.ToShortDateString());
189
                strcmd.AppendFormat(", STR_TO_DATE('{0}','%Y/%m/%d')", data.CompleteDate.ToShortDateString());
190

  
191
                strcmd.AppendFormat(", STR_TO_DATE('{0}','%Y/%m/%d %H:%i:%s')", data.EntryDate);
192
                strcmd.AppendFormat(", STR_TO_DATE('{0}','%Y/%m/%d %H:%i:%s')", data.UpdateDate);
193

  
194
                strcmd.Append(")");
195

  
196
                if (!ExecuteNonQuery(strcmd.ToString(), bConnect)) return false;
197

  
198
                return true;
199
            }
200
            catch (Exception ex)
201
            {
202
                logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd.ToString());
203
                return false;
204
            }
205
        }
206
        #endregion
207

  
208
        #region 運営期履歴情報追加(複数)
209
        /// <summary>
210
        /// 運営期履歴情報追加(複数)
211
        /// </summary>
212
        /// <param name="data">システムマスタデータ</param>
213
        /// <returns>true:成功 false:失敗</returns>
214
        public bool InsertAction(List<BizPeriodHistory> data, bool bConnect = true)
215
        {
216
            StringBuilder strcmd = new StringBuilder();
217
            try
218
            {
219
                bool bColFirst = true;
220
                strcmd.Append("INSERT INTO BizPeriodHistory");
221
                strcmd.Append(" (");
222
                foreach (var gender in Enum.GetValues(typeof(TableColumn)))
223
                {
224
                    if (!bColFirst) strcmd.Append(", ");
225
                    strcmd.Append(gender.ToString());
226
                    bColFirst = false;
227
                }
228
                strcmd.Append(") VALUES");
229

  
230
                bool bDataFirst = true;
231
                foreach (BizPeriodHistory work in data)
232
                {
233
                    if (bDataFirst) strcmd.Append(" (");
234
                    else strcmd.Append(", (");
235

  
236
                    strcmd.AppendFormat("  {0}", work.PeriodYear);
237
                    strcmd.AppendFormat(", {0}", work.PeriodFlag);
238
                    strcmd.AppendFormat(", STR_TO_DATE('{0}','%Y/%m/%d')", work.BeginDate.ToShortDateString());
239
                    strcmd.AppendFormat(", STR_TO_DATE('{0}','%Y/%m/%d')", work.CompleteDate.ToShortDateString());
240

  
241
                    strcmd.AppendFormat(", STR_TO_DATE('{0}','%Y/%m/%d %H:%i:%s')", work.EntryDate);
242
                    strcmd.AppendFormat(", STR_TO_DATE('{0}','%Y/%m/%d %H:%i:%s')", work.UpdateDate);
243
                    strcmd.Append(")");
244

  
245
                    bDataFirst = false;
246
                }
247

  
248
                if (!ExecuteNonQuery(strcmd.ToString(), false)) return false;
249
             
250
                return true;
251
            }
252
            catch (Exception ex)
253
            {
254
                logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd.ToString());
255
                return false;
256
            }
257
        }
258
        #endregion
259

  
260
        #region 運営期履歴情報更新
261
        /// <summary>
262
        /// 運営期履歴情報更新
263
        /// </summary>
264
        /// <param name="AddSQLString">更新条件SQL文字列</param>
265
        /// <param name="data">システムマスタデータ</param>
266
        /// <returns>true:成功 false:失敗</returns>
267
        public bool UpdateAction(string AddSQLString, BizPeriodHistory data, bool bConnect = true)
268
        {
269
            StringBuilder strcmd = new StringBuilder();
270
            try
271
            {
272

  
273
                strcmd.Append("UPDATE BizPeriodHistory");
274

  
275
                strcmd.Append(" SET");
276

  
277
                strcmd.AppendFormat(" PeriodYear = {0}", data.PeriodYear);
278
                strcmd.AppendFormat(", PeriodFlag = {0}", data.PeriodFlag);
279
                strcmd.AppendFormat(", BeginDate = STR_TO_DATE('{0}','%Y/%m/%d')", data.BeginDate.ToShortDateString());
280
                strcmd.AppendFormat(", CompleteDate = STR_TO_DATE('{0}','%Y/%m/%d')", data.CompleteDate.ToShortDateString());
281

  
282
                strcmd.Append(", UpdateDate = NOW()");
283
                strcmd.Append(AddSQLString);
284

  
285
                if (!ExecuteNonQuery(strcmd.ToString(), bConnect)) return false;
286

  
287
                return true;
288
            }
289
            catch (Exception ex)
290
            {
291
                logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd.ToString());
292
                return false;
293
            }
294
        }
295
        #endregion
296

  
297
        #region 1項目更新処理
298
        /// <summary>
299
        /// 1項目の更新を行う
300
        /// </summary>
301
        /// <returns></returns>
302
        public bool UpdateFeild(int SystemCode, int FeildNo, object value, bool bConnect = true)
303
        {
304
            StringBuilder strcmd = new StringBuilder();
305
            try
306
            {
307
                strcmd.Append("UPDATE BizPeriodHistory");
308

  
309
                strcmd.Append(" SET");
310
                switch (FeildNo)
311
                {
312
                    case (int)TableColumn.PeriodYear:
313
                        strcmd.AppendFormat(" PeriodYear = {0}", ((int)value).ToString());
314
                        break;
315
                    case (int)TableColumn.PeriodFlag:
316
                        strcmd.AppendFormat(" PeriodFlag = {0}", ((int)value).ToString());
317
                        break;
318
                    case (int)TableColumn.BeginDate:
319
                        strcmd.AppendFormat(" BeginDate = STR_TO_DATE('{0}','%Y/%m/%d')", ((DateTime)value).ToShortDateString());
320
                        break;
321
                    case (int)TableColumn.CompleteDate:
322
                        strcmd.AppendFormat(" CompleteDate = STR_TO_DATE('{0}','%Y/%m/%d')", ((DateTime)value).ToShortDateString());
323
                        break;
324
                }
325

  
326
                strcmd.Append(", UpdateDate = NOW()");
327
                strcmd.AppendFormat(" Where SystemCode = {0}", SystemCode);
328

  
329
                if (!ExecuteNonQuery(strcmd.ToString(), bConnect)) return false;
330

  
331
                return true;
332
            }
333
            catch (Exception ex)
334
            {
335
                logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd.ToString());
336
                return false;
337
            }
338
        }
339
        #endregion
340

  
341
        #region 運営期履歴情報削除
342
        /// <summary>
343
        /// 運営期履歴情報削除
344
        /// </summary>
345
        /// <param name="AddSQLString">削除条件SQL文字列</param>
346
        /// <param name="data">システムマスタデータ</param>
347
        /// <returns>true:成功 false:失敗</returns>
348
        public bool DeleteAction(string AddSQLString, bool bConnect = true)
349
        {
350
            // インターフェース
351
            StringBuilder strcmd = new StringBuilder();
352
            try
353
            {
354
                strcmd.AppendFormat("DELETE FROM BizPeriodHistory{0}", AddSQLString);
355

  
356
                if (!ExecuteNonQuery(strcmd.ToString(), bConnect)) return false;
357

  
358
                return true;
359
            }
360
            catch (Exception ex)
361
            {
362
                logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd.ToString());
363
                return false;
364
            }
365
        }
366
        #endregion
367

  
368
        #region 構造体へセットする
369
        /// <summary>
370
        /// 構造体へセットする
371
        /// </summary>
372
        /// <param name="wrk">構造体</param>
373
        public void Reader2Struct(object[] objwrk, ref BizPeriodHistory wrk)
374
        {
375
            try
376
            {
377
                // データ取得
378
                wrk.PeriodYear = int.Parse(objwrk[(int)TableColumn.PeriodYear].ToString());
379
                wrk.PeriodFlag = int.Parse(objwrk[(int)TableColumn.PeriodFlag].ToString());
380
                wrk.BeginDate = DateTime.Parse(objwrk[(int)TableColumn.BeginDate].ToString());
381
                wrk.CompleteDate = DateTime.Parse(objwrk[(int)TableColumn.CompleteDate].ToString());
382

  
383
                wrk.EntryDate = DateTime.Parse(objwrk[(int)TableColumn.EntryDate].ToString());
384
                wrk.UpdateDate = DateTime.Parse(objwrk[(int)TableColumn.UpdateDate].ToString());
385
            }
386
            catch (MySqlException myex)
387
            {
388
                logger.ErrorFormat("MySQLエラー:{0}:{1}", CommonMotions.GetMethodName(2), myex.Message);
389
            }
390
            catch (Exception ex)
391
            {
392
                logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(2), ex.Message);
393
            }
394
        }
395
        #endregion
396

  
397
        #region 検索キー文字列を作成
398
        /// <summary>
399
        /// 検索の文字列を返す
400
        /// </summary>
401
        /// <param name="ComponentCode"></param>
402
        /// <param name="DetailNo"></param>
403
        /// <returns></returns>
404
        public string CreatePrimarykeyString(int PeriodYear, int PeriodFlag = 0)
405
        {
406
            StringBuilder strWork = new StringBuilder();
407
            try
408
            {
409
                strWork.AppendFormat(" Where PeriodYear = {0}", PeriodYear);
410
                if (PeriodFlag > 0)
411
                {
412
                    strWork.AppendFormat(" And PeriodFlag = {0}", PeriodFlag);
413
                }
414

  
415
                return strWork.ToString();
416
            }
417
            catch (Exception ex)
418
            {
419
                logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strWork.ToString());
420
                return string.Empty;
421
            }
422
        }
423
        #endregion
424
    }
425
}
branches/src/ProcessManagement/ProcessManagement/DB/IOAccess/IOMSystem.cs
34 34
        /// </summary>
35 35
        public enum SystemColumn
36 36
        {
37
            SYSTEMCODE = 0,
38
            COMPANYNAME1,
39
            COMPANYNAME2,
40
            CEONAME,
41
            CEOPOSITIONNAME,
42
            ZIPCODE,
43
            ADDRESS1,
44
            ADDRESS2,
45
            ADDRESS3,
46
            PHONENUMBER,
47
            FAXNUMBER,
48
            HOMEPAGEURL,
49
            CONSTRUCTIONEXPENSES,
50
            OFFICEEXPENSES,
51
            OPERATINGEXPENSES,
52
            CONSUMPTIONTAX,
53
            COOPERATIONRATE,
54
            STATUTORYWELFARERATE,
37
            SystemCode = 0,
38
            CompanyName1,
39
            CompanyName2,
40
            CEOName,
41
            CEOPositionName,
42
            ZipCode,
43
            Address1,
44
            Address2,
45
            Address3,
46
            PhoneNumber,
47
            FaxNumber,
48
            HomePageURL,
49
            ConsumptionTax,
50
            CooperationRate,
51
            StatutoryWelfareRate,
55 52
            FuelPrice,
56 53
            AreaDistance,
57
            EXCELSAVEPATH,
58
            BUSINESSPERIOD,
59
            ConstructionYear,
60
            BusinessBeginningDate,
61
            ConstructionBeginningDate,
54
            ExcelSavePath,
55
            BusinessPeriod,
56
            ConstrYear,
57
            BusinessBeginDate,
58
            ConstrBeginDate,
59
            BusinessCompDate,
60
            ConstrCompDate,
62 61
            ConstructionNoBase,
63 62
            SloganString1,
64 63
            SloganString2,
......
93 92
            StringBuilder strcmd = new StringBuilder();
94 93
            strcmd.Append("SELECT");
95 94
            strcmd.Append(" SystemCode");
96
            strcmd.Append(", CompanyName1");
97
            strcmd.Append(", CompanyName2");
98
            strcmd.Append(", CEOName");
99
            strcmd.Append(", CEOPositionName");
100
            strcmd.Append(", ZipCode");
101
            strcmd.Append(", Address1");
102
            strcmd.Append(", Address2");
103
            strcmd.Append(", Address3");
104
            strcmd.Append(", PhoneNumber");
105
            strcmd.Append(", FaxNumber");
106
            strcmd.Append(", HomePageURL");
107
            strcmd.Append(", ConstructionExpenses");
108
            strcmd.Append(", OfficeExpenses");
109
            strcmd.Append(", OperatingExpenses");
110
            strcmd.Append(", ConsumptionTax");
111
            strcmd.Append(", CooperationRate");
112
            strcmd.Append(", StatutoryWelfareRate");
113
            strcmd.Append(", FuelPrice");
114
            strcmd.Append(", AreaDistance");
115
            strcmd.Append(", ExcelSavePath");
116
            strcmd.Append(", BusinessPeriod");
117
            strcmd.Append(", ConstructionYear");
118
            strcmd.Append(", BusinessBeginningDate");
119
            strcmd.Append(", ConstructionBeginningDate");
120
            strcmd.Append(", ConstructionNoBase");
121
            strcmd.Append(", SloganString1");
122
            strcmd.Append(", SloganString2");
123
            strcmd.Append(", SloganString3");
95
            strcmd.Append(",CompanyName1");
96
            strcmd.Append(",CompanyName2");
97
            strcmd.Append(",CEOName");
98
            strcmd.Append(",CEOPositionName");
99
            strcmd.Append(",ZipCode");
100
            strcmd.Append(",Address1");
101
            strcmd.Append(",Address2");
102
            strcmd.Append(",Address3");
103
            strcmd.Append(",PhoneNumber");
104
            strcmd.Append(",FaxNumber");
105
            strcmd.Append(",HomePageURL");
106
            strcmd.Append(",ConsumptionTax");
107
            strcmd.Append(",CooperationRate");
108
            strcmd.Append(",StatutoryWelfareRate");
109
            strcmd.Append(",FuelPrice");
110
            strcmd.Append(",AreaDistance");
111
            strcmd.Append(",ExcelSavePath");
112
            strcmd.Append(",BusinessPeriod");
113
            strcmd.Append(",ConstrYear");
114
            strcmd.Append(",BusinessBeginDate");
115
            strcmd.Append(",ConstrBeginDate");
116
            strcmd.Append(",BusinessCompDate");
117
            strcmd.Append(",ConstrCompDate");
118
            strcmd.Append(",ConstructionNoBase");
119
            strcmd.Append(",SloganString1");
120
            strcmd.Append(",SloganString2");
121
            strcmd.Append(",SloganString3");
124 122
            strcmd.Append(" ,DATE_FORMAT(EntryDate, '%Y/%m/%d %H:%i:%s')");
125 123
            strcmd.Append(" ,DATE_FORMAT(UpdateDate, '%Y/%m/%d %H:%i:%s')");
126 124
            strcmd.Append(" FROM SystemMaster");
......
210 208
        }
211 209
        #endregion
212 210

  
213
        #region システムマスタ追加
211
        #region システムマスタ追加(1件)
214 212
        /// <summary>
215
        /// システムマスタ追加
213
        /// システムマスタ追加(1件)
216 214
        /// </summary>
215
        public bool InsertAction(SystemMaster data, bool bConnect = true)
216
        {
217
            StringBuilder strcmd = new StringBuilder();
218
            try
219
            {
220
                strcmd.Append("INSERT INTO SystemMaster");
221

  
222
                strcmd.Append("(");
223
                bool bFirst = true;
224
                foreach (var gender in Enum.GetValues(typeof(SystemColumn)))
225
                {
226
                    if (!bFirst) strcmd.Append(" ,");
227
                    strcmd.Append(gender.ToString());
228
                    bFirst = false;
229
                }
230
                strcmd.Append(") VALUES (");
231

  
232
                strcmd.AppendFormat("  {0}", data.SystemCode);
233
                strcmd.AppendFormat(",'{0}'", data.CompanyName1);
234
                strcmd.AppendFormat(",'{0}'", data.CompanyName2);
235
                strcmd.AppendFormat(",'{0}'", data.CEOName);
236
                strcmd.AppendFormat(",'{0}'", data.CEOPositionName);
237
                strcmd.AppendFormat(",'{0}'", data.ZipCode);
238
                strcmd.AppendFormat(",'{0}'", data.Address1);
239
                strcmd.AppendFormat(",'{0}'", data.Address2);
240
                strcmd.AppendFormat(",'{0}'", data.Address3);
241
                strcmd.AppendFormat(",'{0}'", data.PhoneNumber);
242
                strcmd.AppendFormat(",'{0}'", data.FaxNumber);
243
                strcmd.AppendFormat(",'{0}'", data.HomePageURL);
244
                strcmd.AppendFormat(", {0}", data.ConsumptionTax);
245
                strcmd.AppendFormat(", {0}", data.CooperationRate);
246
                strcmd.AppendFormat(", {0}", data.StatutoryWelfareRate);
247
                strcmd.AppendFormat(", {0}", data.FuelPrice);
248
                strcmd.AppendFormat(", {0}", data.AreaDistance);
249
                strcmd.AppendFormat(",'{0}'", data.ExcelSavePath);
250

  
251
                strcmd.AppendFormat(", {0}", data.BusinessPeriod);
252
                strcmd.AppendFormat(", {0}", data.ConstrYear);
253
                strcmd.AppendFormat(",DATE('{0}')", data.BusinessBeginDate.ToShortDateString());
254
                strcmd.AppendFormat(",DATE('{0}')", data.ConstrBeginDate.ToShortDateString());
255
                strcmd.AppendFormat(",DATE('{0}')", data.BusinessCompDate.ToShortDateString());
256
                strcmd.AppendFormat(",DATE('{0}')", data.ConstrCompDate.ToShortDateString());
257
                strcmd.AppendFormat(", {0}", data.ConstructionNoBase);
258

  
259
                strcmd.AppendFormat(",'{0}'", data.SloganString1);
260
                strcmd.AppendFormat(",'{0}'", data.SloganString2);
261
                strcmd.AppendFormat(",'{0}'", data.SloganString3);
262

  
263
                strcmd.AppendFormat(", STR_TO_DATE('{0}','%Y/%m/%d %H:%i:%s')", data.EntryDate);
264
                strcmd.AppendFormat(", STR_TO_DATE('{0}','%Y/%m/%d %H:%i:%s')", data.UpdateDate);
265
                strcmd.Append(")");
266

  
267
                if (!ExecuteNonQuery(strcmd.ToString(), bConnect)) return false;
268

  
269
                return true;
270
            }
271
            catch (Exception ex)
272
            {
273
                logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd.ToString());
274
                return false;
275
            }
276
        }
277
        #endregion
278

  
279
        #region システムマスタ追加(複数)
280
        /// <summary>
281
        /// システムマスタ追加(複数)
282
        /// </summary>
217 283
        /// <param name="data">システムマスタデータ</param>
218 284
        /// <returns>true:成功 false:失敗</returns>
219 285
        public bool InsertAction(List<SystemMaster> data, bool bConnect = true)
......
250 316
                    strcmd.AppendFormat(",'{0}'", work.PhoneNumber);
251 317
                    strcmd.AppendFormat(",'{0}'", work.FaxNumber);
252 318
                    strcmd.AppendFormat(",'{0}'", work.HomePageURL);
253
                    strcmd.AppendFormat(", {0}", work.ConstructionExpenses);
254
                    strcmd.AppendFormat(", {0}", work.OfficeExpenses);
255
                    strcmd.AppendFormat(", {0}", work.OperatingExpenses);
256 319
                    strcmd.AppendFormat(", {0}", work.ConsumptionTax);
257 320
                    strcmd.AppendFormat(", {0}", work.CooperationRate);
258 321
                    strcmd.AppendFormat(", {0}", work.StatutoryWelfareRate);
......
261 324
                    strcmd.AppendFormat(",'{0}'", work.ExcelSavePath);
262 325

  
263 326
                    strcmd.AppendFormat(", {0}", work.BusinessPeriod);
264
                    strcmd.AppendFormat(", {0}", work.ConstructionYear);
265
                    strcmd.AppendFormat(",'{0}'", work.BusinessBeginningDate);
266
                    strcmd.AppendFormat(",'{0}'", work.ConstructionBeginningDate);
327
                    strcmd.AppendFormat(", {0}", work.ConstrYear);
328
                    strcmd.AppendFormat(",DATE('{0}')", work.BusinessBeginDate);
329
                    strcmd.AppendFormat(",DATE('{0}')", work.ConstrBeginDate);
330
                    strcmd.AppendFormat(",DATE('{0}')", work.BusinessCompDate);
331
                    strcmd.AppendFormat(",DATE('{0}')", work.ConstrCompDate);
267 332
                    strcmd.AppendFormat(", {0}", work.ConstructionNoBase);
268 333

  
269 334
                    strcmd.AppendFormat(",'{0}'", work.SloganString1);
......
318 383
                strcmd.AppendFormat(", PhoneNumber = '{0}'", data.PhoneNumber);
319 384
                strcmd.AppendFormat(", FaxNumber = '{0}'", data.FaxNumber);
320 385
                strcmd.AppendFormat(", HomePageURL = '{0}'", data.HomePageURL);
321
                strcmd.AppendFormat(", ConstructionExpenses = {0}", data.ConstructionExpenses);
322
                strcmd.AppendFormat(", OfficeExpenses = {0}", data.OfficeExpenses);
323
                strcmd.AppendFormat(", OperatingExpenses = {0}", data.OperatingExpenses);
324 386
                strcmd.AppendFormat(", ConsumptionTax = {0}", data.ConsumptionTax);
325 387
                strcmd.AppendFormat(", CooperationRate = {0}", data.CooperationRate);
326 388
                strcmd.AppendFormat(", StatutoryWelfareRate = {0}", data.StatutoryWelfareRate);
......
329 391
                strcmd.AppendFormat(", ExcelSavePath = '{0}'", data.ExcelSavePath);
330 392

  
331 393
                strcmd.AppendFormat(", BusinessPeriod = {0}", data.BusinessPeriod);
332
                strcmd.AppendFormat(", ConstructionYear = {0}", data.ConstructionYear);
333
                strcmd.AppendFormat(", BusinessBeginningDate = '{0}'", data.BusinessBeginningDate);
334
                strcmd.AppendFormat(", ConstructionBeginningDate = '{0}'", data.ConstructionBeginningDate);
394
                strcmd.AppendFormat(", ConstrYear = {0}", data.ConstrYear);
395
                strcmd.AppendFormat(", BusinessBeginDate = DATE('{0}')", data.BusinessBeginDate.ToShortDateString());
396
                strcmd.AppendFormat(", ConstrBeginDate = DATE('{0}')", data.ConstrBeginDate.ToShortDateString());
397
                strcmd.AppendFormat(", BusinessCompDate = DATE('{0}')", data.BusinessCompDate.ToShortDateString());
398
                strcmd.AppendFormat(", ConstrCompDate = DATE('{0}')", data.ConstrCompDate.ToShortDateString());
335 399
                strcmd.AppendFormat(", ConstructionNoBase = {0}", data.ConstructionNoBase);
336 400

  
337 401
                strcmd.AppendFormat(", SloganString1 = '{0}'", data.SloganString1);
......
368 432
                strcmd.Append(" SET");
369 433
                switch (FeildNo)
370 434
                {
371
                    case (int)SystemColumn.SYSTEMCODE:
435
                    case (int)SystemColumn.SystemCode:
372 436
                        strcmd.AppendFormat(" SystemCode = {0}", ((int)value).ToString());
373 437
                        break;
374
                    case (int)SystemColumn.COMPANYNAME1:
438
                    case (int)SystemColumn.CompanyName1:
375 439
                        strcmd.AppendFormat(" CompanyName1 = '{0}'", value.ToString());
376 440
                        break;
377
                    case (int)SystemColumn.COMPANYNAME2:
441
                    case (int)SystemColumn.CompanyName2:
378 442
                        strcmd.AppendFormat(" CompanyName2 = '{0}'", value.ToString());
379 443
                        break;
380
                    case (int)SystemColumn.CEONAME:
444
                    case (int)SystemColumn.CEOName:
381 445
                        strcmd.AppendFormat(" CeoName = '{0}'", value.ToString());
382 446
                        break;
383
                    case (int)SystemColumn.CEOPOSITIONNAME:
447
                    case (int)SystemColumn.CEOPositionName:
384 448
                        strcmd.AppendFormat(" CeoName = '{0}'", value.ToString());
385 449
                        break;
386
                    case (int)SystemColumn.ZIPCODE:
450
                    case (int)SystemColumn.ZipCode:
387 451
                        strcmd.AppendFormat(" CeoName = '{0}'", value.ToString());
388 452
                        break;
389
                    case (int)SystemColumn.ADDRESS1:
453
                    case (int)SystemColumn.Address1:
390 454
                        strcmd.AppendFormat(" Address1 = '{0}'", value.ToString());
391 455
                        break;
392
                    case (int)SystemColumn.ADDRESS2:
456
                    case (int)SystemColumn.Address2:
393 457
                        strcmd.AppendFormat(" Address2 = '{0}'", value.ToString());
394 458
                        break;
395
                    case (int)SystemColumn.ADDRESS3:
459
                    case (int)SystemColumn.Address3:
396 460
                        strcmd.AppendFormat(" Address3 = '{0}'", value.ToString());
397 461
                        break;
398
                    case (int)SystemColumn.PHONENUMBER:
462
                    case (int)SystemColumn.PhoneNumber:
399 463
                        strcmd.AppendFormat(" PhoneNumber = '{0}'", value.ToString());
400 464
                        break;
401
                    case (int)SystemColumn.FAXNUMBER:
465
                    case (int)SystemColumn.FaxNumber:
402 466
                        strcmd.AppendFormat(" FaxNumber = '{0}'", value.ToString());
403 467
                        break;
404
                    case (int)SystemColumn.HOMEPAGEURL:
468
                    case (int)SystemColumn.HomePageURL:
405 469
                        strcmd.AppendFormat(" HomePageURL = '{0}'", value.ToString());
406 470
                        break;
407
                    case (int)SystemColumn.CONSTRUCTIONEXPENSES:
408
                        strcmd.AppendFormat(" ConstructionExpenses = {0}", ((int)value).ToString());
409
                        break;
410
                    case (int)SystemColumn.OFFICEEXPENSES:
411
                        strcmd.AppendFormat(" OfficeExpenses = {0}", ((int)value).ToString());
412
                        break;
413
                    case (int)SystemColumn.OPERATINGEXPENSES:
414
                        strcmd.AppendFormat(" PperatingExpenses = {0}", ((int)value).ToString());
415
                        break;
416
                    case (int)SystemColumn.CONSUMPTIONTAX:
471
                    case (int)SystemColumn.ConsumptionTax:
417 472
                        strcmd.AppendFormat(" ConsumptionTax = {0}", ((int)value).ToString());
418 473
                        break;
419
                    case (int)SystemColumn.COOPERATIONRATE:
474
                    case (int)SystemColumn.CooperationRate:
420 475
                        strcmd.AppendFormat(" CooperationRate = {0}", ((int)value).ToString());
421 476
                        break;
422
                    case (int)SystemColumn.STATUTORYWELFARERATE:
477
                    case (int)SystemColumn.StatutoryWelfareRate:
423 478
                        strcmd.AppendFormat(" StatutoryWelfareRate = {0}", ((int)value).ToString());
424 479
                        break;
425 480
                    case (int)SystemColumn.FuelPrice:
......
428 483
                    case (int)SystemColumn.AreaDistance:
429 484
                        strcmd.AppendFormat(" AreaDistance = {0}", ((int)value).ToString());
430 485
                        break;
431
                    case (int)SystemColumn.EXCELSAVEPATH:
486
                    case (int)SystemColumn.ExcelSavePath:
432 487
                        strcmd.AppendFormat(" ExcelSavePath = '{0}'", value.ToString());
433 488
                        break;
434
                    case (int)SystemColumn.BUSINESSPERIOD:
489
                    case (int)SystemColumn.BusinessPeriod:
435 490
                        strcmd.AppendFormat(" BusinessPeriod = {0}", ((int)value).ToString());
436 491
                        break;
437
                    case (int)SystemColumn.ConstructionYear:
438
                        strcmd.AppendFormat(" ConstructionYear = {0}", ((int)value).ToString());
492
                    case (int)SystemColumn.ConstrYear:
493
                        strcmd.AppendFormat(" ConstrYear = {0}", ((int)value).ToString());
439 494
                        break;
440
                    case (int)SystemColumn.BusinessBeginningDate:
441
                        strcmd.AppendFormat(" BusinessBeginningDate = '{0}'", value.ToString());
495
                    case (int)SystemColumn.BusinessBeginDate:
496
                        strcmd.AppendFormat(" BusinessBeginDate = STR_TO_DATE('{0}', '%Y/%m/%d')", ((DateTime)value).ToShortDateString());
442 497
                        break;
443
                    case (int)SystemColumn.ConstructionBeginningDate:
444
                        strcmd.AppendFormat(" ConstructionBeginningDate = '{0}'", value.ToString());
498
                    case (int)SystemColumn.ConstrBeginDate:
499
                        strcmd.AppendFormat(" ConstrBeginDate = STR_TO_DATE('{0}', '%Y/%m/%d')", ((DateTime)value).ToShortDateString());
445 500
                        break;
501
                    case (int)SystemColumn.BusinessCompDate:
502
                        strcmd.AppendFormat(" BusinessCompDate = STR_TO_DATE('{0}', '%Y/%m/%d')", ((DateTime)value).ToShortDateString());
503
                        break;
504
                    case (int)SystemColumn.ConstrCompDate:
505
                        strcmd.AppendFormat(" ConstrCompDate = STR_TO_DATE('{0}', '%Y/%m/%d')", ((DateTime)value).ToShortDateString());
506
                        break;
446 507
                    case (int)SystemColumn.ConstructionNoBase:
447 508
                        strcmd.AppendFormat(" ConstructionNoBase = {0}", ((int)value).ToString());
448 509
                        break;
......
509 570
            try
510 571
            {
511 572
                // データ取得
512
                wrk.SystemCode = int.Parse(objwrk[(int)SystemColumn.SYSTEMCODE].ToString());
513
                wrk.CompanyName1 = objwrk[(int)SystemColumn.COMPANYNAME1].ToString();
514
                wrk.CompanyName2 = objwrk[(int)SystemColumn.COMPANYNAME2].ToString();
515
                wrk.CEOName = objwrk[(int)SystemColumn.CEONAME].ToString();
... 差分の行数が表示可能な上限を超えました。超過分は表示しません。

他の形式にエクスポート: Unified diff