1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- using ComponentFactory.Krypton.Toolkit;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace NXWMS
- {
- /// <summary>
- /// 通用工具
- /// </summary>
- public static class CommonUtil
- {
- /// <summary>
- /// 设定控件组中所有字段值等于Row
- /// </summary>
- /// <param name="container"></param>
- /// <param name="dataView"></param>
- /// <param name="row"></param>
- public static void GetGroupControls(TableLayoutPanel container, DataGridView dataView, DataGridViewRow row)
- {
- foreach (Control c in container.Controls)
- {
- if (c.Tag != null)
- {
- if (c.Tag.GetType().Name == "String")
- {
- if (dataView.Columns.Contains(c.Tag.ToString()))
- {
- switch (c.GetType().Name)
- {
- case "KryptonCheckBox":
- var kryptonCheckBox = (c as KryptonCheckBox);
- kryptonCheckBox.Checked = (row.Cells[c.Tag.ToString()].Value == null ? "" : row.Cells[c.Tag.ToString()].Value.ToString()) == "1" ? true : false;
- break;
- case "CheckBox":
- var checkbox = (c as KryptonCheckBox);
- checkbox.Checked = (row.Cells[c.Tag.ToString()].Value == null ? "" : row.Cells[c.Tag.ToString()].Value.ToString()) == "1" ? true : false;
- break;
- case "KryptonComboBox":
- case "ComboBox":
- case "KryptonTextBox":
- case "TextBox":
- default:
- c.Text = row.Cells[c.Tag.ToString()].Value == null ? "" : row.Cells[c.Tag.ToString()].Value.ToString();
- break;
- }
- }
- }
- }
- }
- }
- /// <summary>
- /// 设定控件组中所有字段值等于空
- /// </summary>
- /// <param name="container"></param>
- /// <param name="dataView"></param>
- public static void SetGroupControlsEmpty(TableLayoutPanel container, DataGridView dataView)
- {
- foreach (Control c in container.Controls)
- {
- if (c.Tag != null)
- {
- if (c.Tag.GetType().Name == "String")
- {
- if (dataView.Columns.Contains(c.Tag.ToString()))
- {
- c.Text = "";
- }
- }
- }
- }
- }
- }
- }
|