public Result ShowPopupModal(System.Windows.Forms.Form parent, models.db.Row row, models.Context aContext) { bindedRow = row; context = aContext; rowDirty = false; Result result = Result.None; popup = new views.popup.DenpyouInfoPopup(); popup.SetDatabase(context.KaikeiDatabase); popup.StartPosition = System.Windows.Forms.FormStartPosition.Manual; popup.SetRowData(row); popup.Location = new System.Drawing.Point( Math.Max(parent.Left + (parent.Width - popup.Width) / 2, 0), Math.Max(parent.Top + (parent.Height - popup.Height) / 2, 0)); popup.UpdateValue += UpdateValue; popup.FormClosing += delegate(object sender, FormClosingEventArgs args) { if (rowDirty) { if (bindedRow.GetLong("id", -1) == -1) { bindedRow.Table.Insert(bindedRow); result = Result.Inserted; bindedRow = bindedRow.Table.LastInsertedRow(); } else { bindedRow.Table.Update(bindedRow); result = Result.Updated; } (bindedRow.Table as models.db.tables.KaikeiDenpyouMeisai).UpdateMeisaiGroup(bindedRow, ""); } }; popup.RemoveButtonClicked += delegate() { if (bindedRow.GetLong("id", -1) == -1) { helper.MsgBox.Err(KaikeiSystemBody.Properties.Resources.MsgFailedToRemoveRow); } else { bindedRow.Table.Delete(bindedRow); (bindedRow.Table as models.db.tables.KaikeiDenpyouMeisai).DeleteMeisaiGroup(bindedRow); result = Result.Deleted; popup.Close(); } }; popup.ShowDialog(); popup.Dispose(); return(result); }
public System.Windows.Forms.DialogResult ShowDialog(Form owner, models.Context context) { cmbJigyou.InitRowsWithMTKamokuKubunWithParent(context.KaikeiDatabase.MTKamokuKubun, (int)models.constants.MTKamokuKubunHierarchy.Daikubun); cmbTaisyaku.InitRowsWithMTKamokuKubunWithParent(context.KaikeiDatabase.MTKamokuKubun, (int)models.constants.MTKamokuKubunHierarchy.Daikubun); cmbShikin.InitRowsWithMTKamokuKubunWithParent(context.KaikeiDatabase.MTKamokuKubun, (int)models.constants.MTKamokuKubunHierarchy.Daikubun); this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; this.Location = new System.Drawing.Point( owner.Location.X + (owner.Size.Width - this.Size.Width) / 2, owner.Location.Y + (owner.Size.Height - this.Size.Height) / 2 ); ShowDialog(owner); return(dialogResult); }
public void ShowDialog(models.Context context, DateTime?startDate, DateTime?endDate, string kamokuCode, int kaikeiKubun) { Context = context; mototyou = new models.query.KanjouMototyou(context.KaikeiDatabase); form.SetDatabase(Context.KaikeiDatabase); form.ClearControls(Context.Setting.GetStr("before_gengou", "R")); form.StartDate = startDate; form.EndDate = endDate; form.TargetKamokuCode = kamokuCode; form.TargetKaikeiKubun = kaikeiKubun; form.ShowDialog(); }
private static void insertMeisaiRow(models.Context context, int koteiShisanId, long kaisuu, long shiyouTsukisuu, long syoukyakuhi, DateTime gensyoubi, long kisyuTyouboKagaku, long genkaSyoukyakuRuikeigaku) { string countCondition = "where kotei_shisan_bangou = " + koteiShisanId + " and kaisuu = " + kaisuu; if (context.KaikeiDatabase.GenkaSyoukyakuMeisai.RowCount(countCondition) == 0) { models.db.Row meisaiRow = context.KaikeiDatabase.GenkaSyoukyakuMeisai.NewRow(); meisaiRow.Table.SetColumnValue(meisaiRow, "kotei_shisan_bangou", koteiShisanId); meisaiRow.Table.SetColumnValue(meisaiRow, "kaisuu", kaisuu); meisaiRow.Table.SetColumnValue(meisaiRow, "tsukisuu", shiyouTsukisuu); meisaiRow.Table.SetColumnValue(meisaiRow, "kisyu_tyoubo_kagaku", kisyuTyouboKagaku); meisaiRow.Table.SetColumnValue(meisaiRow, "touki_genka_syoukyaku_kagaku", syoukyakuhi); meisaiRow.Table.SetColumnValue(meisaiRow, "genka_syoukyaku_ruikeigaku", genkaSyoukyakuRuikeigaku); meisaiRow.Table.SetColumnValue(meisaiRow, "kimatsu_tyoubo_kagaku", kisyuTyouboKagaku - syoukyakuhi); meisaiRow.Table.SetColumnValue(meisaiRow, "gensyoubi", gensyoubi); meisaiRow.Table.SetColumnValue(meisaiRow, "denpyou_hakkou", false); meisaiRow.Table.Insert(meisaiRow); } }
public void ShowPopupModal(System.Windows.Forms.Form parent, models.Context aContext) { context = aContext; popup = new views.popup.KanjouMototyouPrinntPopup(); popup.SetDatabase(context.KaikeiDatabase); popup.SetGengou(context.Setting.GetStr("before_gengou", "")); popup.StartPosition = System.Windows.Forms.FormStartPosition.Manual; popup.Location = new System.Drawing.Point( Math.Max(parent.Left + (parent.Width - popup.Width) / 2, 0), Math.Max(parent.Top + (parent.Height - popup.Height) / 2, 0)); popup.CloseButtonClicked += delegate() { popup.Close(); }; popup.PrintButtonClicked += PrintButtonClicked; focusController = new misc.FocusController(popup); popup.ShowDialog(); popup.Dispose(); popup = null; }
// 償却 public static bool CreateGenkaSyoukyakuMeisai(models.Context context, int koteiShisanId) { models.db.Row koteiShisanRow = context.KaikeiDatabase.MTKoteiShisan.GetRowById(koteiShisanId); if (koteiShisanRow == null) { return(false); } DateTime?syutokubi = koteiShisanRow.GetDate("syutoku_nenngappi"); long syutokuKakaku = koteiShisanRow.GetLong("syutoku_kakaku", -1); long taiyouNensuu = koteiShisanRow.GetLong("taiyou_nennsuu", -1); double syoukyakuritsu = koteiShisanRow.GetDouble("syoukyaku_ritsu", -1); double zanzonWariai = koteiShisanRow.GetDouble("zanzon_wariai", -1); if (syutokubi == null || syutokuKakaku < 0 || taiyouNensuu < 0 || syoukyakuritsu < 0 || zanzonWariai < 0) { return(false); } long zanzonKagaku = (long)Math.Round(syutokuKakaku * zanzonWariai / 100); DateTime gensyoubi = helper.Converter.DateTimeToNenndoKimatsubi(syutokubi.Value); long ruikeiSyoukyakuhi = 0; long ruikeiShiyouTsukisuu = 0; long kaisuu = 1; while (ruikeiShiyouTsukisuu < taiyouNensuu * 12) { long shiyouTsukisuu; if (ruikeiShiyouTsukisuu == 0) { shiyouTsukisuu = syutokubi.Value.Month >= 4 ? 15 - syutokubi.Value.Month : 3 - syutokubi.Value.Month; if (context.Setting.GetInt("kounyuutsuki_syoukyaku", 0) != 0) { shiyouTsukisuu++; } if (shiyouTsukisuu == 0) { gensyoubi = gensyoubi.AddYears(1); shiyouTsukisuu = 12; } } else if (taiyouNensuu * 12 - ruikeiShiyouTsukisuu < 12) { shiyouTsukisuu = taiyouNensuu * 12 - ruikeiShiyouTsukisuu; } else { shiyouTsukisuu = 12; } long syoukyakuhi = TeigakuhouGenkaSyoukyakuhi(syutokuKakaku, zanzonWariai, shiyouTsukisuu, syoukyakuritsu); long kisyuTyouboKagaku = syutokuKakaku - ruikeiSyoukyakuhi; ruikeiShiyouTsukisuu += shiyouTsukisuu; if (kisyuTyouboKagaku - syoukyakuhi < zanzonKagaku) // 償却残額が残存価額を下回る { syoukyakuhi = kisyuTyouboKagaku - zanzonKagaku; ruikeiSyoukyakuhi += syoukyakuhi; insertMeisaiRow(context, koteiShisanId, kaisuu, shiyouTsukisuu, syoukyakuhi, gensyoubi, kisyuTyouboKagaku, ruikeiSyoukyakuhi); break; } if (ruikeiShiyouTsukisuu == taiyouNensuu * 12 && // 最終年 kisyuTyouboKagaku - syoukyakuhi != zanzonKagaku) // 残存価額の調整が必要 { if (shiyouTsukisuu == 12) // 年跨ぎ { ruikeiSyoukyakuhi += syoukyakuhi; insertMeisaiRow(context, koteiShisanId, kaisuu, shiyouTsukisuu, syoukyakuhi, gensyoubi, kisyuTyouboKagaku, ruikeiSyoukyakuhi); shiyouTsukisuu = 1; kaisuu++; gensyoubi = gensyoubi.AddYears(1); kisyuTyouboKagaku = kisyuTyouboKagaku - syoukyakuhi; syoukyakuhi = kisyuTyouboKagaku - zanzonKagaku; ruikeiSyoukyakuhi += syoukyakuhi; insertMeisaiRow(context, koteiShisanId, kaisuu, shiyouTsukisuu, syoukyakuhi, gensyoubi, kisyuTyouboKagaku, ruikeiSyoukyakuhi); } else { shiyouTsukisuu += 1; syoukyakuhi = kisyuTyouboKagaku - zanzonKagaku; ruikeiSyoukyakuhi += syoukyakuhi; insertMeisaiRow(context, koteiShisanId, kaisuu, shiyouTsukisuu, syoukyakuhi, gensyoubi, kisyuTyouboKagaku, ruikeiSyoukyakuhi); } } else { ruikeiSyoukyakuhi += syoukyakuhi; insertMeisaiRow(context, koteiShisanId, kaisuu, shiyouTsukisuu, syoukyakuhi, gensyoubi, kisyuTyouboKagaku, ruikeiSyoukyakuhi); } kaisuu++; gensyoubi = gensyoubi.AddYears(1); } return(true); }