From 54c59d3864521285b26d36cc6c3ac9c8c83b49a3 Mon Sep 17 00:00:00 2001
From: ningshuxia <ningshuxia0927@outlook.com>
Date: 星期五, 09 五月 2025 09:56:01 +0800
Subject: [PATCH] 主界面修改

---
 WinFrmUI/PBS.WinFrmUI/03-elecPrice/ElecPriceMgr.cs |   34 ++++++++++++++++++++++++++++------
 1 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/WinFrmUI/PBS.WinFrmUI/03-elecPrice/ElecPriceMgr.cs b/WinFrmUI/PBS.WinFrmUI/03-elecPrice/ElecPriceMgr.cs
index 86565d4..835daab 100644
--- a/WinFrmUI/PBS.WinFrmUI/03-elecPrice/ElecPriceMgr.cs
+++ b/WinFrmUI/PBS.WinFrmUI/03-elecPrice/ElecPriceMgr.cs
@@ -60,11 +60,12 @@
                         }
                     }
                 }
-                else
-                {
-                    _elecPrice.Settings = new Vmo.ElecPriceSetting();
-                    _elecPrice.Settings.MonthList = new List<Vmo.ElecPriceMonthSetting> { new Vmo.ElecPriceMonthSetting() };
-                }
+            }
+            else
+            {
+                _elecPrice = new Vmo.ElecPriceVmo();
+                _elecPrice.Settings = new Vmo.ElecPriceSetting();
+                _elecPrice.Settings.MonthList = new List<Vmo.ElecPriceMonthSetting>();
             }
             this.elecPriceViewModelBindingSource.DataSource = _allBindingList;
             this.elecPriceViewModelBindingSource.ResetBindings(false);
@@ -80,6 +81,27 @@
             {
                 var bll = new BLL.ElecPrice();
                 _elecPrice.Settings.MonthList.Add(price);
+                if (_elecPrice.ID == 0)
+                {
+                    var id = await bll.Insert(_elecPrice);
+                    if (id > 0)
+                    {
+                        _elecPrice.ID = id;
+                        foreach (var item in price.HourList)
+                        {
+                            this._allBindingList.Add(new ElecPriceViewModel
+                            {
+                                BelongName = $"{price.StartMonth}~{price.EndMonth}(鏈�)",
+                                StartHour = item.StartHour,
+                                EndHour = item.EndHour,
+                                Price = item.Price
+                            });
+                        }
+                        this.elecPriceViewModelBindingSource.ResetBindings(false);
+                        return true;
+                    }
+                    return false;
+                }
                 var bol = await bll.Update(_elecPrice);
                 if (bol)
                 {
@@ -119,7 +141,7 @@
                 var isok = await bll.Update(_elecPrice);
                 if (isok)
                 {
-                   this.SetBindingData();
+                    this.SetBindingData();
                     return true;
                 }
                 return false;

--
Gitblit v1.9.3