duheng
2025-02-07 c5136b7517998a076f1bd2e4abdda01decae8b6f
WinFrmUI/IStation.WinFrmUI.Basic/basic/electricprice/AddElectricDlg.cs
@@ -21,16 +21,14 @@
        }
        private BindingList<ElecPriceHourSetting> _allBindingList = null; //这就是输入进去立马就获取到的值
        public event Func<Model.ElecPriceMonthSetting, bool> ReloadDataEvent;
        public void SetBindingData()
        {
            _allBindingList = new BindingList<Model.ElecPriceHourSetting>();
            this.bindingSource1.DataSource = _allBindingList;
        }
        //验证
        private bool verify()
@@ -46,13 +44,13 @@
                this.dxErrorProvider1.SetError(this.txtEndMonth, "必填项");
                return false;
            }
            var AllHour =_allBindingList;
            var hour = AllHour.OrderBy(x => x.EndHour).ToList();
            var AllHour = _allBindingList;
            var hour = AllHour.OrderBy(x => x.EndHour).ToList();
            var HourCount = hour.Count;
            if (hour.First().StartHour != 0 || hour.Last().EndHour != 24)
            {
                  XtraMessageBox.Show("开始时间和结束时间有误");
                  return false;
                XtraMessageBox.Show("开始时间和结束时间有误");
                return false;
            }
            for (int x = 0; x < hour.Count - 1; x++)
            {
@@ -71,8 +69,7 @@
                }
            }
            return true;
    }
        }
        //确定
        private void btnOk_Click(object sender, EventArgs e)
@@ -90,12 +87,12 @@
                MessageBox.Show("输入有误");
                return;
            }
            if (Startmonth > 11)
            {
                MessageBox.Show("开始月小于12");
                return;
            }
            /*            if (Startmonth > 11)
                        {
                            MessageBox.Show("开始月小于12");
                            return;
                        }
                        */
            Eleprice.StartMonth = Startmonth;
            int Endmonth = 0;
            if (!int.TryParse(this.txtEndMonth.Text, out Endmonth))
@@ -109,11 +106,11 @@
                MessageBox.Show("请输入不小于1且不大于12的数字");
                return;
            }
            if (Startmonth >=Endmonth)
            {
                MessageBox.Show("开始月不能小于或等于结束月");
                return;
            }
            /*   if (Startmonth >=Endmonth)
               {
                   MessageBox.Show("开始月不能小于或等于结束月");
                   return;
               }*/
            Eleprice.EndMonth = Endmonth;
            Eleprice.HourList = _allBindingList.ToList();        //把绑定列表的值赋给hourlist
            var isok = this.ReloadDataEvent.Invoke(Eleprice);
@@ -126,6 +123,7 @@
            this.DialogResult = System.Windows.Forms.DialogResult.OK;       //确定ok,然后关闭
            this.Close();
        }
        //行删除
        private void gridView2_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
        {
@@ -138,5 +136,4 @@
                _allBindingList.Remove(row);
        }
    }
}
}