private void butSaveTableLayout_Click(object sender, EventArgs e) { try { List <ModelTableLayoutPanel> listModel = new List <ModelTableLayoutPanel>(); for (int i = 0; i < gridViewTableLayoutPanel.RowCount; i++) { var model = new ModelTableLayoutPanel(); model.Id = int.Parse(gridViewTableLayoutPanel.GetRowCellValue(i, "Id").ToString()); model.ColumnInt = int.Parse(gridViewTableLayoutPanel.GetRowCellValue(i, "ColumnInt").ToString()); model.RowInt = int.Parse(gridViewTableLayoutPanel.GetRowCellValue(i, "RowInt").ToString()); model.IsShow = bool.Parse(gridViewTableLayoutPanel.GetRowCellValue(i, "IsShow").ToString()); model.SizePercent = float.Parse(gridViewTableLayoutPanel.GetRowCellValue(i, "SizePercent").ToString()); model.TableLayoutPanelName = gridViewTableLayoutPanel.GetRowCellValue(i, "TableLayoutPanelName").ToString(); model.TableType = tableType; listModel.Add(model); } lcdConfigDAO.SaveTableLayoutPanelConfig(listModel); LoadDataTableLayoutPanel(); } catch (Exception ex) { MessageBox.Show("Lỗi: " + ex.Message, "Đã xảy ra lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public List <ModelTableLayoutPanel> GetTableLayoutPanelConfig(int tableType) { DataTable dt = new DataTable(); string sql = "select Id, ColumnInt, RowInt, TableLayoutPanelName, SizePercent, IsShow from ShowLCD_TableLayoutPanel where TableType=" + tableType; List <ModelTableLayoutPanel> listModel = new List <ModelTableLayoutPanel>(); try { dt = dbclass.TruyVan_TraVe_DataTable(sql); if (dt != null && dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { var model = new ModelTableLayoutPanel(); model.Id = int.Parse(row["Id"].ToString()); if (!string.IsNullOrEmpty(row["ColumnInt"].ToString())) { model.ColumnInt = int.Parse(row["ColumnInt"].ToString()); } if (!string.IsNullOrEmpty(row["RowInt"].ToString())) { model.RowInt = int.Parse(row["RowInt"].ToString()); } model.TableLayoutPanelName = row["TableLayoutPanelName"].ToString(); if (!string.IsNullOrEmpty(row["SizePercent"].ToString())) { model.SizePercent = float.Parse(row["SizePercent"].ToString()); } model.IsShow = bool.Parse(row["IsShow"].ToString()); listModel.Add(model); } } } catch (Exception ex) { MessageBox.Show("Lỗi không thể lấy thông tin cấu hình TableLayoutPanel của LCD: " + ex.Message, "Lỗi truy vấn CSDL", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(listModel); }