Imports C1.Win.C1FlexGrid Public Class Frm_3_Mach Dim Dt As DataTable Dim isCopy As Boolean = False Dim Init As Boolean = False Dim SrcDrv As DataRowView Public Sub New() ' 디자이너에서 이 호출이 필요합니다. InitializeComponent() With fxNanBang .KeyActionEnter = C1.Win.C1FlexGrid.KeyActionEnum.None .KeyActionTab = C1.Win.C1FlexGrid.KeyActionEnum.None .SelectionMode = C1.Win.C1FlexGrid.SelectionModeEnum.Cell .ShowButtons = C1.Win.C1FlexGrid.ShowButtonsEnum.Always .DrawMode = C1.Win.C1FlexGrid.DrawModeEnum.OwnerDraw .AllowSorting = C1.Win.C1FlexGrid.AllowSortingEnum.None .ShowSortPosition = C1.Win.C1FlexGrid.ShowSortPositionEnum.None End With With fxNaengBang .KeyActionEnter = C1.Win.C1FlexGrid.KeyActionEnum.None .KeyActionTab = C1.Win.C1FlexGrid.KeyActionEnum.None .SelectionMode = C1.Win.C1FlexGrid.SelectionModeEnum.Cell .ShowButtons = C1.Win.C1FlexGrid.ShowButtonsEnum.Always .DrawMode = C1.Win.C1FlexGrid.DrawModeEnum.OwnerDraw .AllowSorting = C1.Win.C1FlexGrid.AllowSortingEnum.None .ShowSortPosition = C1.Win.C1FlexGrid.ShowSortPositionEnum.None End With With fxKogjo .KeyActionEnter = C1.Win.C1FlexGrid.KeyActionEnum.None .KeyActionTab = C1.Win.C1FlexGrid.KeyActionEnum.None .SelectionMode = C1.Win.C1FlexGrid.SelectionModeEnum.Cell .ShowButtons = C1.Win.C1FlexGrid.ShowButtonsEnum.Always .DrawMode = C1.Win.C1FlexGrid.DrawModeEnum.OwnerDraw .AllowSorting = C1.Win.C1FlexGrid.AllowSortingEnum.None .ShowSortPosition = C1.Win.C1FlexGrid.ShowSortPositionEnum.None End With With fxLight .KeyActionEnter = C1.Win.C1FlexGrid.KeyActionEnum.None .KeyActionTab = C1.Win.C1FlexGrid.KeyActionEnum.None .SelectionMode = C1.Win.C1FlexGrid.SelectionModeEnum.Cell .ShowButtons = C1.Win.C1FlexGrid.ShowButtonsEnum.Always .DrawMode = C1.Win.C1FlexGrid.DrawModeEnum.OwnerDraw .AllowSorting = C1.Win.C1FlexGrid.AllowSortingEnum.None .ShowSortPosition = C1.Win.C1FlexGrid.ShowSortPositionEnum.None End With With fxDanMal .KeyActionEnter = C1.Win.C1FlexGrid.KeyActionEnum.None .KeyActionTab = C1.Win.C1FlexGrid.KeyActionEnum.None .SelectionMode = C1.Win.C1FlexGrid.SelectionModeEnum.Cell .ShowButtons = C1.Win.C1FlexGrid.ShowButtonsEnum.Always .DrawMode = C1.Win.C1FlexGrid.DrawModeEnum.OwnerDraw .AllowSorting = C1.Win.C1FlexGrid.AllowSortingEnum.None .ShowSortPosition = C1.Win.C1FlexGrid.ShowSortPositionEnum.None End With AddHandler fxNanBang.KeyPress, AddressOf fgrid_KeyPress AddHandler fxNanBang.AfterEdit, AddressOf fgrid_AfterEdit AddHandler fxNanBang.BeforeEdit, AddressOf fgrid_BeginEditS AddHandler fxNanBang.OwnerDrawCell, AddressOf flexOwnerDrawCell AddHandler fxNaengBang.KeyPress, AddressOf fgrid_KeyPress AddHandler fxNaengBang.AfterEdit, AddressOf fgrid_AfterEdit AddHandler fxNaengBang.BeforeEdit, AddressOf fgrid_BeginEditS AddHandler fxNaengBang.OwnerDrawCell, AddressOf flexOwnerDrawCell AddHandler fxKogjo.KeyPress, AddressOf fgrid_KeyPress AddHandler fxKogjo.AfterEdit, AddressOf fgrid_AfterEdit AddHandler fxKogjo.BeforeEdit, AddressOf fgrid_BeginEditS AddHandler fxKogjo.OwnerDrawCell, AddressOf flexOwnerDrawCell AddHandler fxLight.KeyPress, AddressOf fgrid_KeyPress AddHandler fxLight.AfterEdit, AddressOf fgrid_AfterEdit AddHandler fxLight.BeforeEdit, AddressOf fgrid_BeginEditS AddHandler fxLight.OwnerDrawCell, AddressOf flexOwnerDrawCell AddHandler fxDanMal.KeyPress, AddressOf fgrid_KeyPress AddHandler fxDanMal.AfterEdit, AddressOf fgrid_AfterEdit AddHandler fxDanMal.BeforeEdit, AddressOf fgrid_BeginEditS AddHandler fxDanMal.OwnerDrawCell, AddressOf flexOwnerDrawCell End Sub #Region "FlexGRid Events" Private Sub fgrid_BeginEditS(sender As Object, e As C1.Win.C1FlexGrid.RowColEventArgs) Dim grid As C1.Win.C1FlexGrid.C1FlexGrid = DirectCast(sender, C1.Win.C1FlexGrid.C1FlexGrid) '//데이터입력전에 IME를 맞춘다. Select Case grid.Cols(e.Col).Name.ToLower() Case "연결된시스템" If sender Is fxNaengBang Then Make_냉방기기신재생_List(e.Col) ElseIf sender Is fxNanBang Then Make_난방기기신재생_List(e.Col) End If Case "name", "position", "dept", "bigo", "memo", "jname", "설명", "비고", "메모" grid.ImeMode = Windows.Forms.ImeMode.Hangul Case Else grid.ImeMode = Windows.Forms.ImeMode.Alpha End Select 'If sender Is fxNaengBang Then ' Make_냉방기기신재생_List(e.Col) 'ElseIf sender Is fxNanBang Then ' Make_난방기기신재생_List(e.Col) 'End If End Sub Private Sub fgrid_AfterEdit(sender As Object, e As C1.Win.C1FlexGrid.RowColEventArgs) Dim grid As C1.Win.C1FlexGrid.C1FlexGrid = DirectCast(sender, C1.Win.C1FlexGrid.C1FlexGrid) Dim data As Object = grid.GetData(e.Row, e.Col) '//난방 Dim cellstyle_gray As CellStyle = fxNanBang.Styles.Add(Nothing) cellstyle_gray.BackColor = Color.Red Dim cellstyle_whie As CellStyle = fxNanBang.Styles.Add(Nothing) cellstyle_whie.BackColor = Color.White '//냉방 Dim cellstyle_gray2 As CellStyle = fxNaengBang.Styles.Add(Nothing) cellstyle_gray2.BackColor = Color.Red Dim cellstyle_whie2 As CellStyle = fxNaengBang.Styles.Add(Nothing) cellstyle_whie2.BackColor = Color.White '//난방 If grid.Cols(e.Col).Name.ToLower() = "열생산기기방식" Then If data.ToString() = "히트펌프" Then fxNanBang.Cols("정격보일러효율").AllowEditing = False fxNanBang.Cols("정격보일러COP").AllowEditing = True Else If data.ToString() = "지역난방" Then fxNanBang.Cols("정격보일러효율").AllowEditing = False Else fxNanBang.Cols("정격보일러효율").AllowEditing = True End If fxNanBang.Cols("정격보일러COP").AllowEditing = False End If fxNanBang.Invalidate() End If '//냉방 If grid.Cols(e.Col).Name.ToLower() = "냉동기종류" Then If data.ToString() = "히트펌프" Then fxNaengBang.Cols("증발식건식냉각기").AllowEditing = False fxNaengBang.Cols("냉각수펌프동력").AllowEditing = False fxNaengBang.Cols("냉수펌프동력").AllowEditing = True Else fxNaengBang.Cols("증발식건식냉각기").AllowEditing = True fxNaengBang.Cols("냉각수펌프동력").AllowEditing = True fxNaengBang.Cols("냉수펌프동력").AllowEditing = True End If fxNaengBang.Invalidate() End If '//공조 If grid.Cols(e.Col).Name.ToLower() = "공조방식" Then If data.ToString() = "환기용" Then fxKogjo.Cols("설정치난방").AllowEditing = False fxKogjo.Cols("설정치냉방").AllowEditing = False Else fxKogjo.Cols("설정치난방").AllowEditing = True fxKogjo.Cols("설정치냉방").AllowEditing = True End If fxKogjo.Invalidate() ElseIf grid.Cols(e.Col).Name.ToLower() = "열교환기유형" Then '//170827 If data.ToString() = "열회수불가" OrElse data.ToString() = "0" Then fxKogjo.Cols("열회수율").AllowEditing = False fxKogjo.Cols("열회수율_냉방").AllowEditing = False Else fxKogjo.Cols("열회수율").AllowEditing = True fxKogjo.Cols("열회수율_냉방").AllowEditing = True End If End If If grid.Cols(e.Col).Name.ToLower() = "연결된시스템" Then If sender Is fxNaengBang Then b냉방기기신재생업데이트완료 = False ElseIf sender Is fxNanBang Then b난방기기신재생업데이트완료 = False End If End If Dim tagStr As String = grid.Tag.ToString() If tagStr = "light" Then If grid.Cols(e.Col).Name = "조명전력" OrElse grid.Cols(e.Col).Name = "대수" Then Dim 조명전력 As Integer = grid.GetData(e.Row, grid.Cols("조명전력").Index) Dim 대수 As Integer = grid.GetData(e.Row, grid.Cols("대수").Index) grid.SetData(e.Row, grid.Cols("조명전력합").Index, 조명전력 * 대수) ' ShowSubTotal_Light() Else If Not MoveCellRight(grid) Then MoveCellDown(grid, e.Col) End If ElseIf tagStr = "danmal" Then If grid.Cols(e.Col).Name = "팬동력" OrElse grid.Cols(e.Col).Name = "대수" Then Dim 팬동력 As Integer = grid.GetData(e.Row, grid.Cols("팬동력").Index) Dim 대수 As Integer = grid.GetData(e.Row, grid.Cols("대수").Index) grid.SetData(e.Row, grid.Cols("전력합").Index, 팬동력 * 대수) ' ShowSubTotal_Danmal() Else If Not MoveCellRight(grid) Then MoveCellDown(grid, e.Col) End If Else Select Case grid.Cols(e.Col).Name.ToLower() Case Else If Not MoveCellRight(grid) Then MoveCellDown(grid, e.Col) Exit Select End Select End If 'grid.AutoSizeCols() End Sub Private Function FindRowIndex(grid As C1.Win.C1FlexGrid.C1FlexGrid, IDX As Integer, Optional IDXField As String = "IDX") As Integer For i As Integer = 1 To grid.Rows.Count Dim oIDX As Integer = CInt(grid.GetData(i, grid.Cols(IDXField).Index)) If IDX = oIDX Then Return i End If Next Return -1 End Function Private Sub fgrid_KeyPress(sender As Object, e As KeyPressEventArgs) '일반선택상태일때 엔터키를 누른다면 If e.KeyChar = Chr(&HD) Then '엔터는 아래 혹은 우측으로 Dim grid As C1.Win.C1FlexGrid.C1FlexGrid = DirectCast(sender, C1.Win.C1FlexGrid.C1FlexGrid) e.Handled = True If Not MoveCellRight(grid) Then MoveCellDown(grid, grid.Cols("설명").Index) End If ElseIf e.KeyChar = Chr(&H8) Then '탭은 우측으로 Dim grid As C1.Win.C1FlexGrid.C1FlexGrid = DirectCast(sender, C1.Win.C1FlexGrid.C1FlexGrid) e.Handled = True MoveCellRight(grid) End If End Sub Private Function MoveCellDown(grid As C1.Win.C1FlexGrid.C1FlexGrid, Optional firstcol As Integer = -1) As [Boolean] Dim colidx As Integer = grid.CursorCell.c1 '현재 If firstcol > -1 Then colidx = firstcol End If Dim rowidx As Integer = grid.CursorCell.TopRow Dim newidx As Integer = rowidx + 1 '다음셀을 찾는다. If newidx < grid.Rows.Count Then grid.[Select](newidx, colidx) Return True Else '마지막줄이므로 처리하지않ㄴ든다. Return False End If End Function Private Function MoveCellRight(grid As C1.Win.C1FlexGrid.C1FlexGrid) As [Boolean] Dim colidx As Integer = grid.CursorCell.c1 '현재 Dim newidx As Integer = colidx + 1 Dim find As [Boolean] = False '다음셀을 찾는다. While True If newidx + 1 <= grid.Cols.Count Then If Not grid.Cols(newidx).IsVisible OrElse Not grid.Cols(newidx).AllowEditing Then newidx += 1 Continue While Else grid.[Select](grid.CursorCell.TopRow, newidx) find = True Exit While End If Else Exit While End If End While Return find End Function Sub flexOwnerDrawCell(sender As Object, e As C1.Win.C1FlexGrid.OwnerDrawCellEventArgs) Dim grid As C1.Win.C1FlexGrid.C1FlexGrid = sender If e.Row >= grid.Rows.Fixed AndAlso e.Col = grid.Cols.Fixed - 1 Then e.Text = (e.Row - grid.Rows.Fixed) + 1 End If If e.Row > 0 Then Select Case grid.Cols(e.Col).Name Case "정격보일러효율" '//난방 Dim valo As Object = grid.GetData(e.Row, grid.Cols("열생산기기방식").Index) If Not valo Is Nothing Then Dim vals As String = valo.ToString() If vals = "히트펌프" OrElse vals = "지역난방" Then e.Graphics.DrawString("X", Me.Font, Brushes.Red, e.Bounds.Left, e.Bounds.Top) e.Graphics.FillRectangle(Brushes.LightGray, e.Bounds) e.Handled = True End If End If Case "정격보일러COP" '//난방 Dim valo As Object = grid.GetData(e.Row, grid.Cols("열생산기기방식").Index) If Not valo Is Nothing Then Dim vals As String = valo.ToString() If vals <> "히트펌프" Then e.Graphics.DrawString("X", Me.Font, Brushes.Red, e.Bounds.Left, e.Bounds.Top) e.Graphics.FillRectangle(Brushes.LightGray, e.Bounds) e.Handled = True End If End If Case "냉각수펌프동력" Dim valo As Object = grid.GetData(e.Row, grid.Cols("냉동기종류").Index) If Not valo Is Nothing Then Dim vals As String = valo.ToString() If vals = "히트펌프" Then e.Graphics.DrawString("X", Me.Font, Brushes.Red, e.Bounds.Left, e.Bounds.Top) e.Graphics.FillRectangle(Brushes.LightGray, e.Bounds) e.Handled = True End If End If Case "증발식건식냉각기" '//난방 Dim valo As Object = grid.GetData(e.Row, grid.Cols("냉동기종류").Index) If Not valo Is Nothing Then Dim vals As String = valo.ToString() If vals = "히트펌프" Then e.Graphics.DrawString("X", Me.Font, Brushes.Red, e.Bounds.Left, e.Bounds.Top) e.Graphics.FillRectangle(Brushes.LightGray, e.Bounds) e.Handled = True End If End If Case "설정치난방", "설정치냉방" '//공조 170718 Dim valo As Object = grid.GetData(e.Row, grid.Cols("공조방식").Index) If Not valo Is Nothing Then Dim vals As String = valo.ToString() If vals = "환기용" Then e.Graphics.DrawString("X", Me.Font, Brushes.Red, e.Bounds.Left, e.Bounds.Top) e.Graphics.FillRectangle(Brushes.LightGray, e.Bounds) e.Handled = True End If End If Case "열회수율", "열회수율_냉방" '//공조 170827 Dim valo As Object = grid.GetData(e.Row, grid.Cols("열교환기유형").Index) If Not valo Is Nothing Then Dim vals As String = valo.ToString() If vals = "열회수불가" OrElse vals = "0" Then e.Graphics.DrawString("X", Me.Font, Brushes.Red, e.Bounds.Left, e.Bounds.Top) e.Graphics.FillRectangle(Brushes.LightGray, e.Bounds) e.Handled = True End If End If Case "냉동기종류" Dim valo As Object = grid.GetData(e.Row, grid.Cols("냉동기방식").Index) If Not valo Is Nothing Then Dim vals As String = valo.ToString() If vals = "흡수식" OrElse vals = "지역난방" Then e.Graphics.DrawString("X", Me.Font, Brushes.Red, e.Bounds.Left, e.Bounds.Top) e.Graphics.FillRectangle(Brushes.LightGray, e.Bounds) e.Handled = True End If End If End Select End If End Sub Private Sub RefreshCellFormat() ''//관리자는 색상을 파란색으로한다. 'If fxList.Styles("chi0") Is Nothing Then ' Dim newstyle As C1.Win.C1FlexGrid.CellStyle = fxList.Styles.Add("chi0") ' newstyle.ForeColor = Color.Blue 'End If 'If fxList.Styles("chi1") Is Nothing Then ' Dim newstyle As C1.Win.C1FlexGrid.CellStyle = fxList.Styles.Add("chi1") ' newstyle.ForeColor = Color.Black 'End If 'For i As Integer = 1 To Me.fxList.Rows.Count - 1 ' Dim obj_admin As Object = Me.fxList.GetData(i, Me.fxList.Cols("admin").Index) ' Dim admin As Boolean = False ' If Not obj_admin Is Nothing Then admin = CBool(obj_admin) ' If admin Then ' fxList.Rows(i).Style = fxList.Styles("chi0") ' Else ' fxList.Rows(i).Style = fxList.Styles("chi1") ' End If 'Next End Sub #End Region Sub EndEdit() Me.Validate() Me.fxDanMal.FinishEditing() Me.fxKogjo.FinishEditing() Me.fxLight.FinishEditing() Me.fxNaengBang.FinishEditing() Me.fxNanBang.FinishEditing() Me.bs_공조기기.EndEdit() Me.bs_난방기기.EndEdit() Me.bs_냉방기기.EndEdit() Me.bS_실내단말기.EndEdit() Me.bs_조명기기.EndEdit() End Sub Private Sub MdiMain_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed EndEdit() CEnergy.ARINCLASS.SaveLoad_FrmSetting(Me, Me.bs_난방기기.Position, True) End Sub Private Sub MdiMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load '//공유데이터셋에 연결한다. Me.bs_난방기기.DataSource = DSET1 Me.bs_냉방기기.DataSource = DSET1 Me.bs_공조기기.DataSource = DSET1 Me.bs_조명기기.DataSource = DSET1 Me.bS_실내단말기.DataSource = DSET1 Dt = DSET1.tbl_nanbangkiki AddHandler DSET1.tbl_nanbangkiki.TableNewRow, AddressOf AddNewDataRow_nanbangkiki '//난방기기 AddHandler DSET1.tbl_nangbangkiki.TableNewRow, AddressOf AddNewDataRow_nangbangkiki '//냉방기기 AddHandler DSET1.tbl_kongjo.TableNewRow, AddressOf AddNewDataRow_kongjo '//공조기기 AddHandler DSET1.tbl_light.TableNewRow, AddressOf AddNewDataRow_Light '//조명기기 AddHandler DSET1.tbl_danmal.TableNewRow, AddressOf AddNewDataRow_Danmal '//조명기기 AddHandler DSET1.tbl_nangbangkiki.ColumnChanged, AddressOf DataColumnChanged_light '//콤보컨트롤 바인딩 Binding_Zone() '//모든컨트롤의 cTrl_enter 를 추가합니다 'BindProperty(CType(Me.SplitContainer1.Panel2.Controls, Control.ControlCollection)) Me.Init = True Try Me.bs_난방기기.Position = CEnergy.ARINCLASS.Read_LastPos_Frm(Me) Catch ex As Exception Me.bs_난방기기.MoveFirst() End Try bs_CurrentChanged(sender, e) Validate_Control() '//제목줄 크기변경 fxDanMal.Rows()(0).HeightDisplay *= 2 fxDanMal.Rows()(0).StyleDisplay.WordWrap = True fxKogjo.Rows()(0).HeightDisplay *= 2 fxKogjo.Rows()(0).StyleDisplay.WordWrap = True fxLight.Rows()(0).HeightDisplay *= 2 fxLight.Rows()(0).StyleDisplay.WordWrap = True fxNaengBang.Rows()(0).HeightDisplay *= 2 fxNaengBang.Rows()(0).StyleDisplay.WordWrap = True fxNanBang.Rows()(0).HeightDisplay *= 2 fxNanBang.Rows()(0).StyleDisplay.WordWrap = True '//열너비 자동 ReadfGridColWidth(Me.Name, fxDanMal) ReadfGridColWidth(Me.Name, fxKogjo) ReadfGridColWidth(Me.Name, fxLight) ReadfGridColWidth(Me.Name, fxNaengBang) ReadfGridColWidth(Me.Name, fxNanBang) '//소계표시 'ShowSubTotal_Light() ' ShowSubTotal_Danmal() Me.Show() Application.DoEvents() End Sub #Region "Control_Enter" Private Sub BindProperty(ByVal Ctl As Control.ControlCollection) For Each C As Control In Ctl If C.Controls.Count > 1 Then BindProperty(C.Controls) Else If C.GetType.ToString.ToUpper.IndexOf("MYTB") <> -1 Then AddHandler CType(C, MyTb).KeyDown, AddressOf TextBOx_KeyDown ElseIf C.GetType.ToString.ToUpper.IndexOf("MYCMB") <> -1 Then AddHandler CType(C, MyCmb).KeyDown, AddressOf Cmd_KeyDown End If End If Next End Sub Private Sub TextBOx_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) If e.KeyCode = Keys.Enter AndAlso e.Control Then Try Dim Field As String = (CType(sender, MyTb).DataBindings.Item("text").BindingMemberInfo.BindingField) For Each Dr As DataRow In Dt.Select(Me.bs_난방기기.Filter, "") Dr(Field) = CType(sender, MyTb).Text Next Work_msg_timer("모든값이 변경되었습니다", 25) Catch ex As Exception End Try End If End Sub Private Sub Cmd_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) If e.KeyCode = Keys.Enter AndAlso e.Control Then Try Dim Field As String = (CType(sender, MyCmb).DataBindings.Item("selectedvalue").BindingMemberInfo.BindingField) For Each Dr As DataRow In Dt.Select(Me.bs_난방기기.Filter, "") Dr(Field) = CType(sender, MyCmb).SelectedValue Next Work_msg_timer("모든값이 변경되었습니다", 25) Catch ex As Exception End Try End If End Sub #End Region Public Overrides Function AcceptChanged() As Boolean Me.Validate() Me.fxDanMal.FinishEditing() Me.fxKogjo.FinishEditing() Me.fxLight.FinishEditing() Me.fxNaengBang.FinishEditing() Me.fxNanBang.FinishEditing() Me.bs_공조기기.EndEdit() Me.bs_난방기기.EndEdit() Me.bs_냉방기기.EndEdit() Me.bS_실내단말기.EndEdit() Me.bs_조명기기.EndEdit() DSET1.tbl_nanbangkiki.AcceptChanges() DSET1.tbl_nangbangkiki.AcceptChanges() DSET1.tbl_kongjo.AcceptChanges() DSET1.tbl_danmal.AcceptChanges() DSET1.tbl_light.AcceptChanges() 'ShowSubTotal_Danmal() 'ShowSubTotal_Light() Return MyBase.AcceptChanged() End Function Private Sub DataColumnChanged_light(sender As Object, e As System.Data.DataColumnChangeEventArgs) Select Case e.Column.ColumnName.ToLower Case "냉동기방식" Select Case e.ProposedValue Case "흡수식", "지역냉방" e.Row("냉동기종류") = "(없음)" fxNaengBang.Cols("냉동기종류").AllowEditing = False fxNaengBang.Invalidate() Case Else Try fxNaengBang.Cols("냉동기종류").AllowEditing = True fxNaengBang.Invalidate() Catch ex As Exception End Try End Select End Select End Sub Sub ShowSubTotal_Light() Dim grid As C1.Win.C1FlexGrid.C1FlexGrid = fxLight If grid.Styles("subtotal") Is Nothing Then grid.SubtotalPosition = C1.Win.C1FlexGrid.SubtotalPositionEnum.BelowData Dim style As C1.Win.C1FlexGrid.CellStyle = grid.Styles.Add("subtotoal") style.ForeColor = SystemColors.ControlDarkDark '//글자색 style.BackColor = Color.Gainsboro '//배경색 style.Font = New Font(Me.Font, FontStyle.Bold) End If grid.Subtotal(C1.Win.C1FlexGrid.AggregateEnum.Clear) If (grid.Rows.Count > 1) Then grid.Subtotal(C1.Win.C1FlexGrid.AggregateEnum.Sum, 0, -1, grid.Cols("조명전력합").Index, "조명전력합") grid.SetData(grid.Rows.Count - 1, 0, "합계") grid.Rows(grid.Rows.Count - 1).Style = fxLight.Styles("subtotoal") 'grid.AutoSizeCols() End If End Sub Sub ShowSubTotal_Danmal() Dim grid As C1.Win.C1FlexGrid.C1FlexGrid = fxDanMal If grid.Styles("subtotal") Is Nothing Then grid.SubtotalPosition = C1.Win.C1FlexGrid.SubtotalPositionEnum.BelowData Dim style As C1.Win.C1FlexGrid.CellStyle = grid.Styles.Add("subtotoal") style.ForeColor = SystemColors.ControlDarkDark style.BackColor = Color.Gainsboro style.Font = New Font(Me.Font, FontStyle.Bold) End If grid.Subtotal(C1.Win.C1FlexGrid.AggregateEnum.Clear) If (grid.Rows.Count > 1) Then grid.Subtotal(C1.Win.C1FlexGrid.AggregateEnum.Sum, 0, -1, grid.Cols("전력합").Index, "전력합") grid.SetData(grid.Rows.Count - 1, 0, "합계") '//제목줄을 합계로 변경한다. grid.Rows(grid.Rows.Count - 1).Style = fxDanMal.Styles("subtotoal") '//색상변경 'grid.AutoSizeCols() End If End Sub #Region "난방기기" Private Sub MdiMain_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown Select Case e.KeyCode Case Keys.F12 End Select End Sub Private Function GetMaxCode(ByVal dt As DataTable) As String Try Dim Dr As DataRow = dt.Select("", "code desc")(0) Return Format(CInt(Dr("code")) + 1, "0000") Catch ex As Exception Return "0001" End Try End Function Dim 이전목록 As String = "" Dim b난방기기신재생업데이트완료 As Boolean = False Sub Make_난방기기신재생_List(colindex As Integer) ' If b난방기기신재생업데이트완료 Then Return 'Dim bs연결된신재생_난방 As New BindingSource(DSET1, "tbl_new") With {.Filter = filter, .Sort = "code"} 'Dim cmd연결된신재생_난방 As New ComboBox With {.DataSource = bs연결된신재생_난방, .DisplayMember = "설명", .ValueMember = "code"} 'cmd연결된신재생_난방.DataBindings.Add(New Binding("SelectedValue", bs_난방기기, "연결된시스템")) 'fxNanBang.Cols("연결된시스템").Editor = cmd연결된신재생_난방 Dim filter As String = "code = '0' or 신재생냉난방구분 like '%난방%' or 신재생냉난방구분 like '%급탕%' " Dim sl As New System.Collections.SortedList() Dim 현재목록 As String = "" For Each dr As DS.tbl_newRow In DSET1.tbl_new.Select(filter, "code") sl.Add(dr.code, dr.설명) 현재목록 += dr.code + dr.설명 Next If 현재목록 <> 이전목록 Then 이전목록 = 현재목록 b난방기기신재생업데이트완료 = False fxNanBang.Cols(colindex).DataType = GetType(String) fxNanBang.Cols(colindex).DataMap = sl Console.WriteLine("Make_난방기기신재생_List") Else b난방기기신재생업데이트완료 = True End If End Sub Dim b냉방기기신재생업데이트완료 As Boolean = False Sub Make_냉방기기신재생_List(colindex As Integer) If b냉방기기신재생업데이트완료 Then Return Console.WriteLine("Make_냉방기기신재생_List") 'Dim bs연결된신재생_난방 As New BindingSource(DSET1, "tbl_new") With {.Filter = filter, .Sort = "code"} 'Dim cmd연결된신재생_난방 As New ComboBox With {.DataSource = bs연결된신재생_난방, .DisplayMember = "설명", .ValueMember = "code"} 'cmd연결된신재생_난방.DataBindings.Add(New Binding("SelectedValue", bs_난방기기, "연결된시스템")) 'fxNanBang.Cols("연결된시스템").Editor = cmd연결된신재생_난방 Dim filter As String = "code = '0' or 신재생냉난방구분 like '%냉%'" Dim sl As New System.Collections.SortedList() For Each dr As DS.tbl_newRow In DSET1.tbl_new.Select(filter, "code") sl.Add(dr.code, dr.설명) Next fxNaengBang.Cols(colindex).DataType = GetType(String) fxNaengBang.Cols(colindex).DataMap = sl b냉방기기신재생업데이트완료 = True End Sub Private Sub Binding_Zone() '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Dim cmd구분 As New ComboBox() With cmd구분.Items .Add("(없음)") .Add("난방용") .Add("급탕용") .Add("난방급탕용") End With fxNanBang.Cols("난방급탕구분").Editor = cmd구분 Dim cmd난방방식 As New ComboBox() With cmd난방방식.Items .Add("(없음)") .Add("보일러") .Add("지역난방") .Add("전기보일러") .Add("히트펌프") End With fxNanBang.Cols("열생산기기방식").Editor = cmd난방방식 '//난방기기(신재생) Make_난방기기신재생_List(fxNanBang.Cols("연결된시스템").Index) 'Dim filter As String = "code like '1%' or (code like '2%' and 지열냉난방구분 = '난방급탕용')" 'Dim bs연결된신재생_난방 As New BindingSource(DSET1, "tbl_new") With {.Filter = filter, .Sort = "code"} 'Dim cmd연결된신재생_난방 As New ComboBox With {.DataSource = bs연결된신재생_난방, .DisplayMember = "설명", .ValueMember = "code"} 'cmd연결된신재생_난방.DataBindings.Add(New Binding("SelectedValue", bs_난방기기, "연결된시스템")) 'fxNanBang.Cols("연결된시스템").Editor = cmd연결된신재생_난방 Dim cmd사용연료 As New ComboBox() With cmd사용연료.Items .Add("(없음)") .Add("난방유") .Add("천연가스") .Add("액화가스") .Add("전기") .Add("지역난방") End With fxNanBang.Cols("사용연료").Editor = cmd사용연료 '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Dim cmd냉방방식 As New ComboBox() With cmd냉방방식.Items .Add("압축식") .Add("흡수식") .Add("압축식(LNG)") .Add("지역냉방") End With cmd냉방방식.DropDownStyle = ComboBoxStyle.DropDownList fxNaengBang.Cols("냉동기방식").Editor = cmd냉방방식 Dim cmd냉동기종류 As New ComboBox() With cmd냉동기종류.Items .Add("(없음)") .Add("수냉식") .Add("공냉식") .Add("히트펌프") End With cmd냉동기종류.DropDownStyle = ComboBoxStyle.DropDownList fxNaengBang.Cols("냉동기종류").Editor = cmd냉동기종류 '//냉방기기(신재생) Make_냉방기기신재생_List(fxNaengBang.Cols("연결된시스템").Index) 'Filter = "code like '1%' or (code like '2%' and 지열냉난방구분 = '냉방용')" 'Dim bs연결된신재생_냉방 As New BindingSource(DSET1, "tbl_new") With {.Filter = filter, .Sort = "code"} 'Dim cmd연결된신재생_냉방 As New ComboBox With {.DataSource = bs연결된신재생_냉방, .DisplayMember = "설명", .ValueMember = "code"} 'fxNaengBang.Cols("연결된시스템").Editor = cmd연결된신재생_냉방 Dim sl연료 As New ComboBox With sl연료.Items .Add("(없음)") .Add("난방유") .Add("천연가스") .Add("액화가스") .Add("지역난방") .Add("지역냉방") .Add("전기") End With sl연료.DropDownStyle = ComboBoxStyle.DropDownList fxNaengBang.Cols("사용연료").Editor = sl연료 '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Dim cmd공조방식 As New ComboBox cmd공조방식.DropDownStyle = ComboBoxStyle.DropDownList With cmd공조방식.Items .Add("정풍량") .Add("변풍량") .Add("환기용") End With fxKogjo.Cols("공조방식").Editor = cmd공조방식 '//170827 (디자이너에서 콤보 설정함) 'Dim cmd열교환기유형 As New ComboBox 'cmd열교환기유형.DropDownStyle = ComboBoxStyle.DropDownList 'With cmd열교환기유형.Items ' .Add("열회수불가") ' .Add("현열교환") ' .Add("전열교환") 'End With 'fxKogjo.Cols("열교환기유형").Editor = cmd열교환기유형 '//조명기기종류 형광등;LED등;기타고효율등;일반등 ' Console.WriteLine("yk2") Dim sl As New Dictionary(Of String, String) '//170514 sl.Add("형광등", "형광등") sl.Add("LED등", "LED등") sl.Add("기타고효율등", "기타고효율등") sl.Add("일반등", "일반등") fxLight.Cols("조명종류").DataType = GetType(String) fxLight.Cols("조명종류").DataMap = sl Dim s2l As New Dictionary(Of String, String) '//170514 s2l.Add("증발식(개방형)", "증발식(개방형)") s2l.Add("증발식(폐쇄형)", "증발식(폐쇄형)") s2l.Add("건식", "건식") fxNaengBang.Cols("증발식건식냉각기").DataType = GetType(String) fxNaengBang.Cols("증발식건식냉각기").DataMap = s2l End Sub Private Sub AddNewDataRow_nanbangkiki(ByVal sender As Object, ByVal e As System.Data.DataTableNewRowEventArgs) e.Row.Item("code") = GetMaxCode(DSET1.tbl_nanbangkiki) End Sub Private Sub AddNewDataRow_nangbangkiki(ByVal sender As Object, ByVal e As System.Data.DataTableNewRowEventArgs) e.Row.Item("code") = GetMaxCode(DSET1.tbl_nangbangkiki) End Sub Private Sub AddNewDataRow_kongjo(ByVal sender As Object, ByVal e As System.Data.DataTableNewRowEventArgs) e.Row.Item("code") = GetMaxCode(DSET1.tbl_kongjo) End Sub Private Sub AddNewDataRow_Light(ByVal sender As Object, ByVal e As System.Data.DataTableNewRowEventArgs) e.Row.Item("code") = GetMaxCode(DSET1.tbl_light) End Sub Private Sub AddNewDataRow_Danmal(ByVal sender As Object, ByVal e As System.Data.DataTableNewRowEventArgs) e.Row.Item("code") = GetMaxCode(DSET1.tbl_danmal) End Sub #End Region Private Sub Validate_Control() If Not Init Then Return If isCopy Then Return End Sub Private Sub bs_CurrentChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bs_난방기기.CurrentChanged If Not Init Then Return Dim Drv As DataRowView = CType(bs_난방기기.Current, DataRowView) If Drv Is Nothing Then Return Dim 열생산기기방식 As String = "" If Not Drv("열생산기기방식") Is DBNull.Value Then 열생산기기방식 = Drv("열생산기기방식").ToString() End If If 열생산기기방식 = "히트펌프" Then fxNanBang.Cols("정격보일러효율").AllowEditing = False fxNanBang.Cols("정격보일러COP").AllowEditing = True Else If 열생산기기방식 = "지역난방" Then fxNanBang.Cols("정격보일러효율").AllowEditing = False Else fxNanBang.Cols("정격보일러효율").AllowEditing = True End If fxNanBang.Cols("정격보일러COP").AllowEditing = False End If Me.bs_난방기기.EndEdit() End Sub Private Sub Frm_V20091231_Zone_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseWheel If e.Delta < 0 Then If Me.bs_난방기기.Position < Me.bs_난방기기.Count Then Me.bs_난방기기.Position += 1 Else If Me.bs_난방기기.Position > 0 Then Me.bs_난방기기.Position -= 1 End If Me.Validate() My.Application.DoEvents() End Sub Private Sub bs_CurrentItemChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles bs_난방기기.CurrentItemChanged, bs_공조기기.CurrentItemChanged, bs_냉방기기.CurrentItemChanged Try Me.bs_난방기기.EndEdit() Catch ex As Exception End Try Try Me.bS_실내단말기.EndEdit() Catch ex As Exception End Try Try Me.bs_공조기기.EndEdit() Catch ex As Exception End Try Try Me.bs_냉방기기.EndEdit() Catch ex As Exception End Try Try Me.bs_조명기기.EndEdit() Catch ex As Exception End Try Dim drv As DataRowView = Me.bs_냉방기기.Current If Not drv Is Nothing Then Dim 냉동기종류 As String = "" If Not drv("냉동기종류") Is DBNull.Value Then 냉동기종류 = drv("냉동기종류").ToString() End If If 냉동기종류 = "히트펌프" Then fxNaengBang.Cols("증발식건식냉각기").AllowEditing = False fxNaengBang.Cols("냉각수펌프동력").AllowEditing = False fxNaengBang.Cols("냉수펌프동력").AllowEditing = True Else fxNaengBang.Cols("증발식건식냉각기").AllowEditing = True fxNaengBang.Cols("냉각수펌프동력").AllowEditing = True fxNaengBang.Cols("냉수펌프동력").AllowEditing = True End If End If End Sub Private Sub bt_add_light_Click(sender As Object, e As EventArgs) bs_난방기기.AddNew() End Sub Private Sub C1Button2_Click(sender As Object, e As EventArgs) If bs_난방기기.Count > 0 Then bs_난방기기.RemoveCurrent() End Sub Private Sub C1Button3_Click(sender As Object, e As EventArgs) bs_냉방기기.AddNew() End Sub Private Sub C1Button1_Click(sender As Object, e As EventArgs) If bs_냉방기기.Count > 0 Then bs_냉방기기.RemoveCurrent() End Sub Private Sub C1Button5_Click(sender As Object, e As EventArgs) bs_공조기기.AddNew() End Sub Private Sub C1Button4_Click(sender As Object, e As EventArgs) If bs_공조기기.Count > 0 Then bs_공조기기.RemoveCurrent() End Sub Private Sub C1Button7_Click(sender As Object, e As EventArgs) bs_조명기기.AddNew() End Sub Private Sub C1Button6_Click(sender As Object, e As EventArgs) If bs_조명기기.Count > 0 Then bs_조명기기.RemoveCurrent() End Sub Private Sub C1Button9_Click(sender As Object, e As EventArgs) bS_실내단말기.AddNew() End Sub Private Sub C1Button8_Click(sender As Object, e As EventArgs) If bS_실내단말기.Count > 0 Then bS_실내단말기.RemoveCurrent() End Sub Private Sub RibbonButton1_Click(sender As Object, e As EventArgs) Handles RibbonButton1.Click AcceptChanged() End Sub Private Sub btAdd_Click(sender As Object, e As EventArgs) Handles btAdd.Click EndEdit() If C1DockingTab1.SelectedIndex = 0 Then Me.bs_난방기기.AddNew() ElseIf C1DockingTab1.SelectedIndex = 1 Then Me.bs_냉방기기.AddNew() ElseIf C1DockingTab1.SelectedIndex = 2 Then Me.bs_공조기기.AddNew() ElseIf C1DockingTab1.SelectedIndex = 3 Then Me.bs_조명기기.AddNew() 'ShowSubTotal_Light() Else Me.bS_실내단말기.AddNew() 'ShowSubTotal_Danmal() End If End Sub Private Sub btDel_Click(sender As Object, e As EventArgs) Handles btDel.Click EndEdit() If C1DockingTab1.SelectedIndex = 0 Then Dbbase.DelCrow(Me.bs_난방기기, True) ElseIf C1DockingTab1.SelectedIndex = 1 Then Dbbase.DelCrow(Me.bs_냉방기기, True) ElseIf C1DockingTab1.SelectedIndex = 2 Then Dbbase.DelCrow(Me.bs_공조기기, True) ElseIf C1DockingTab1.SelectedIndex = 3 Then Dbbase.DelCrow(Me.bs_조명기기, True) Else Dbbase.DelCrow(Me.bS_실내단말기, True) End If End Sub Private Sub fxDanMal_SelChange(sender As Object, e As EventArgs) Handles fxDanMal.SelChange End Sub Private Sub fxDanMal_BeforeFreezeRow(sender As Object, e As C1.Win.C1FlexGrid.RowColEventArgs) Handles fxDanMal.BeforeFreezeRow End Sub Private Sub fxDanMal_BeforeMouseDown(sender As Object, e As BeforeMouseDownEventArgs) Handles fxDanMal.BeforeMouseDown Dim hti As HitTestInfo = fxDanMal.HitTest(e.X, e.Y) If (hti.Column = 0) Then '//줄헤더를 클릭했다 '//해당줄 데이터를 모두 선택해준다. Dim cellrange As New CellRange() cellrange.c1 = 0 cellrange.c2 = fxDanMal.Cols.Count - 1 cellrange.r1 = 0 cellrange.r2 = hti.Row fxDanMal.SelectionMode = SelectionModeEnum.CellRange fxDanMal.Select(cellrange, True) End If Console.WriteLine(String.Format("fxDanMal_SelChange : {0},{1}", hti.Row, hti.Column)) End Sub Private Sub 열너비자동조정ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 열너비자동조정ToolStripMenuItem.Click Dim MenuItem As ToolStripMenuItem = sender If Not MenuItem Is Nothing Then Dim cMenu As ContextMenuStrip = MenuItem.Owner If Not cMenu Is Nothing Then Dim grid As C1.Win.C1FlexGrid.C1FlexGrid = cMenu.SourceControl grid.AutoSizeCols() End If End If End Sub Private Sub 열너비저장ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 열너비저장ToolStripMenuItem.Click Dim MenuItem As ToolStripMenuItem = sender If Not MenuItem Is Nothing Then Dim cMenu As ContextMenuStrip = MenuItem.Owner If Not cMenu Is Nothing Then Dim grid As C1.Win.C1FlexGrid.C1FlexGrid = cMenu.SourceControl SavefGridColWidth(Me.Name, grid) End If End If End Sub Private Sub 열너비초기화ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 열너비초기화ToolStripMenuItem.Click Dim MenuItem As ToolStripMenuItem = sender If Not MenuItem Is Nothing Then Dim cMenu As ContextMenuStrip = MenuItem.Owner If Not cMenu Is Nothing Then Dim grid As C1.Win.C1FlexGrid.C1FlexGrid = cMenu.SourceControl '//모든데이터의 열너비를 초기화한다. ClearfGridColWidth(grid) End If End If End Sub Private Sub fxLight_Click(sender As Object, e As EventArgs) Handles fxLight.Click End Sub End Class