Beispiel #1
0
        public List <ModelLabelArea> GetLabelAreaConfig(int tableType)
        {
            DataTable             dt        = new DataTable();
            string                sql       = "select Id, Font, Size, Bold, Italic, Color, Position, TableLayoutPanelName from ShowLCD_LabelArea where TableType=" + tableType;
            List <ModelLabelArea> listModel = new List <ModelLabelArea>();

            try
            {
                dt = dbclass.TruyVan_TraVe_DataTable(sql);
                if (dt != null && dt.Rows.Count > 0)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        var model = new ModelLabelArea();
                        model.Id                   = int.Parse(row["Id"].ToString());
                        model.Font                 = row["Font"].ToString();
                        model.Size                 = float.Parse(row["Size"].ToString());
                        model.Bold                 = bool.Parse(row["Bold"].ToString());
                        model.Italic               = bool.Parse(row["Italic"].ToString());
                        model.Color                = row["Color"].ToString();
                        model.Position             = int.Parse(row["Position"].ToString());
                        model.TableLayoutPanelName = row["TableLayoutPanelName"].ToString();
                        listModel.Add(model);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi không thể lấy thông tin cấu hình Panel của LCD: " + ex.Message, "Lỗi truy vấn CSDL", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(listModel);
        }
 private void butSaveLabelArea_Click(object sender, EventArgs e)
 {
     try
     {
         List <ModelLabelArea> listModel = new List <ModelLabelArea>();
         for (int i = 0; i < gridViewLabelArea.RowCount; i++)
         {
             var model = new ModelLabelArea();
             model.Id                   = int.Parse(gridViewLabelArea.GetRowCellValue(i, "Id").ToString());
             model.Italic               = bool.Parse(gridViewLabelArea.GetRowCellValue(i, "Italic").ToString());
             model.Bold                 = bool.Parse(gridViewLabelArea.GetRowCellValue(i, "Bold").ToString());
             model.Color                = gridViewLabelArea.GetRowCellValue(i, "Color").ToString();
             model.Font                 = gridViewLabelArea.GetRowCellValue(i, "Font").ToString();
             model.Position             = int.Parse(gridViewLabelArea.GetRowCellValue(i, "Position").ToString());
             model.Size                 = float.Parse(gridViewLabelArea.GetRowCellValue(i, "Size").ToString());
             model.TableLayoutPanelName = gridViewLabelArea.GetRowCellValue(i, "TableLayoutPanelName").ToString();
             model.TableType            = tableType;
             listModel.Add(model);
         }
         lcdConfigDAO.SaveLabelAreaConfig(listModel);
         LoadDataLabelArea();
     }
     catch (Exception ex)
     {
         MessageBox.Show("Lỗi: " + ex.Message, "Đã xảy ra lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }