预览窗体模板

2020-11-24 15:37

阅读:749

标签:des   datagridview   style   class   tar   ext   

namespace NLISClient.SSTForm
{
///


/// 程序名称:SST模板预览窗体
///
///
/// 作者日期版本更改说明
///
/// 2014-03-3V1.0创建
///

///

///

///

public partial class RewardStandardPreForm : EjectEditBaseForm
{
WCFRewardAndPayService.RewardAndPayServiceClient client = new WCFRewardAndPayService.RewardAndPayServiceClient();
WCFRewardStandardService.RewardStandardServiceClient clientR = new WCFRewardStandardService.RewardStandardServiceClient();
WCFPayStandardService.PayStandardServiceClient clientP = new WCFPayStandardService.PayStandardServiceClient();

DataTable dtItemA = null;//定价表(父)
DataTable dtItemR = null;//索酬表(子)
DataTable dtItemP = null;//索赔表(子)
int rowP = 0;
int rows = 0;//行数
string LevelRow = "";//每一行的所占行数
string strWhere = "";

public RewardStandardPreForm(string ID)
{
InitializeComponent();
strWhere = " RewardAndPayPositionID=" + ID;
}

private void RewardStandardPreForm_Load(object sender, EventArgs e)
{
GetData();
if (dtItemA.Rows.Count == 0)
panel.Visible = false;
panel.Refresh();
if (dtItemA.Rows.Count > 0)
{
JSRows();
init();
}
panel.HorizontalScroll.Visible = false;
}

public void GetData()
{
Dictionary dicA = new Dictionary();
dicA = client.Search(1, Int32.MaxValue, "RewardAndPayStatus=1 and" + strWhere);
DataTable _dicA = NLISClient.UIBase.Helper.TableHelper.DeserializationTable(dicA["table"]);
DataView dv = _dicA.DefaultView;
dv.Sort = "PositionDepartmentID desc,RewardAndPayPositionID desc";
dtItemA = dv.ToTable();

Dictionary dicR = new Dictionary();
dicR = clientR.Search(1, Int32.MaxValue, "RewardStandardStatus=1");
dtItemR = NLISClient.UIBase.Helper.TableHelper.DeserializationTable(dicR["table"]);

Dictionary dicP = new Dictionary();
dicP = clientP.Search(1, Int32.MaxValue, "PayStandardStatus=1");
dtItemP = NLISClient.UIBase.Helper.TableHelper.DeserializationTable(dicP["table"]);

}

private void init()
{
if (dtItemA.Rows.Count > 0)
{
DataTable table = dtItemR;
this.panel.Controls.Clear();
panel.BorderStyle = BorderStyle.None;
panel.CellBorderStyle = TableLayoutPanelCellBorderStyle.Single;
panel.Refresh();
this.panel.RowCount = rows;
this.panel.RowStyles.Clear();
for (int i = 0; i {
string[] levelRow = LevelRow.Split(‘;‘);
this.panel.RowStyles.Add(new RowStyle(SizeType.Absolute, 23.1F * Convert.ToInt16(levelRow[i])));
}
int CurrentRow = -1;
for (int i = 0; i {
DataRow[] level1 = dtItemR.Select("RewardStandardRewardPriceID=" + dtItemA.Rows[i]["RewardAndPayID"]);
DataRow[] level2 = dtItemP.Select("PayStandardPayPriceID=" + dtItemA.Rows[i]["RewardAndPayID"]);

CurrentRow++;

Label label_X = new Label();
label_X.Text = (CurrentRow + 1).ToString();//序号列
label_X.Tag = dtItemA.Rows[i]["RewardAndPayID"].ToString();
label_X.TextAlign = ContentAlignment.MiddleCenter;
label_X.Anchor = ((AnchorStyles)((AnchorStyles.Left | AnchorStyles.Right)));
label_X.AutoSize = true;
label_X.TextAlign = ContentAlignment.MiddleCenter;
panel.Controls.Add(label_X, 0, CurrentRow);

Label label = new Label();
label.Text = dtItemA.Rows[i]["RewardAndPayItem"].ToString();//服务项目;
label.Tag = dtItemA.Rows[i]["RewardAndPayID"].ToString();
label.TextAlign = ContentAlignment.MiddleCenter;
label.Anchor = ((AnchorStyles)((AnchorStyles.Left | AnchorStyles.Right)));
label.AutoSize = true;
label.TextAlign = ContentAlignment.MiddleCenter;
panel.Controls.Add(label, 1, CurrentRow);

Label label_R = new Label();
label_R.Text = dtItemA.Rows[i]["RewardMoney"].ToString();//索酬定价;
label_R.Tag = dtItemA.Rows[i]["RewardAndPayID"].ToString();
label_R.TextAlign = ContentAlignment.MiddleCenter;
label_R.Anchor = ((AnchorStyles)((AnchorStyles.Left | AnchorStyles.Right)));
label_R.AutoSize = true;
label_R.TextAlign = ContentAlignment.MiddleCenter;
panel.Controls.Add(label_R, 2, CurrentRow);

#region 添加表格 索酬标准
if (level1.Length > 0)
{
DataGridView dgv_R = new DataGridView();
dgv_R.AutoGenerateColumns = false;
dgv_R.Height = 20 * level1.Length;
dgv_R.ScrollBars = ScrollBars.None;
dgv_R.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right;
dgv_R.AllowUserToResizeColumns = false;
dgv_R.AllowUserToResizeRows = false;
dgv_R.AllowUserToAddRows = false;
dgv_R.AllowUserToDeleteRows = false;
dgv_R.BackgroundColor = Color.White;
dgv_R.ColumnHeadersVisible = false;
dgv_R.RowsDefaultCellStyle.SelectionBackColor = Color.AliceBlue;
dgv_R.RowsDefaultCellStyle.SelectionForeColor = Color.Black;
dgv_R.RowHeadersVisible = false;
dgv_R.BorderStyle = BorderStyle.None;

DataGridViewTextBoxColumn dc1 = new DataGridViewTextBoxColumn();//标准
dc1.Name = dgv_R.Name + "_RewardStandardItem";
dc1.ReadOnly = true;
dc1.Width = 200;
dgv_R.Columns.Add(dc1);

DataGridViewTextBoxColumn dc2 = new DataGridViewTextBoxColumn();//百分比
dc2.Name = dgv_R.Name + "_RewardStandardPercent";
//dc2.Width = 126;
dc2.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dgv_R.Columns.Add(dc2);

dgv_R.Columns[dgv_R.Name + "_RewardStandardItem"].DataPropertyName = "RewardStandardItem";
dgv_R.Columns[dgv_R.Name + "_RewardStandardPercent"].DataPropertyName = "_RewardStandardPercent";
DataTable dt_R = dtItemR.Clone();
for (int j = 0; j {
dt_R.Rows.Add(level1[j].ItemArray);
}
dgv_R.DataSource = dt_R;
panel.Controls.Add(dgv_R, 3, CurrentRow);
dgv_R.Margin = new Padding(0, 0, 0, 0);
}
else
{
DataGridView dgv_R = new DataGridView();
dgv_R.AutoGenerateColumns = false;
dgv_R.Height = 20 * level1.Length;
dgv_R.ScrollBars = ScrollBars.None;
dgv_R.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right;
dgv_R.AllowUserToResizeColumns = false;
dgv_R.AllowUserToResizeRows = false;
dgv_R.AllowUserToAddRows = false;
dgv_R.AllowUserToDeleteRows = false;
dgv_R.BackgroundColor = Color.White;
dgv_R.ColumnHeadersVisible = false;
dgv_R.RowsDefaultCellStyle.SelectionBackColor = Color.AliceBlue;
dgv_R.RowsDefaultCellStyle.SelectionForeColor = Color.Black;
dgv_R.RowHeadersVisible = false;
dgv_R.BorderStyle = BorderStyle.None;

DataGridViewTextBoxColumn dc1 = new DataGridViewTextBoxColumn();//标准
dc1.Name = dgv_R.Name + "_RewardStandardItem";
dc1.ReadOnly = true;
dc1.Width = 200;
dgv_R.Columns.Add(dc1);

DataGridViewTextBoxColumn dc2 = new DataGridViewTextBoxColumn();//百分比
dc2.Name = dgv_R.Name + "_RewardStandardPercent";
//dc2.Width = 126;
dc2.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dgv_R.Columns.Add(dc2);

dgv_R.Columns[dgv_R.Name + "_RewardStandardItem"].DataPropertyName = "RewardStandardItem";
dgv_R.Columns[dgv_R.Name + "_RewardStandardPercent"].DataPropertyName = "_RewardStandardPercent";
DataTable dt_R = dtItemR.Clone();
dt_R.Rows.Add(dt_R.NewRow());
dgv_R.DataSource = dt_R;
panel.Controls.Add(dgv_R, 3, CurrentRow);
dgv_R.Margin = new Padding(0, 0, 0, 0);
}
#endregion

Label label_P = new Label();
label_P.Text = dtItemA.Rows[i]["PayMoney"].ToString();//索赔定价;
label_P.Tag = dtItemA.Rows[i]["RewardAndPayID"].ToString();
label_P.TextAlign = ContentAlignment.MiddleCenter;
label_P.Anchor = ((AnchorStyles)((AnchorStyles.Left | AnchorStyles.Right)));
label_P.AutoSize = true;
label_P.TextAlign = ContentAlignment.MiddleCenter;
panel.Controls.Add(label_P, 4, CurrentRow);

#region 添加表格 索赔标准
if (level2.Length > 0)
{
DataGridView dgv_P = new DataGridView();
dgv_P.AutoGenerateColumns = false;
dgv_P.Height = 20 * level1.Length;
dgv_P.ScrollBars = ScrollBars.None;
dgv_P.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right;
dgv_P.AllowUserToResizeColumns = false;
dgv_P.AllowUserToResizeRows = false;
dgv_P.AllowUserToAddRows = false;
dgv_P.AllowUserToDeleteRows = false;
dgv_P.BackgroundColor = Color.White;
dgv_P.ColumnHeadersVisible = false;
dgv_P.RowsDefaultCellStyle.SelectionBackColor = Color.AliceBlue;
dgv_P.RowsDefaultCellStyle.SelectionForeColor = Color.Black;
dgv_P.RowHeadersVisible = false;
dgv_P.BorderStyle = BorderStyle.None;

DataGridViewTextBoxColumn dc1_P = new DataGridViewTextBoxColumn();//项目
dc1_P.Name = dgv_P.Name + "_PayStandardItem";
dc1_P.ReadOnly = true;
dc1_P.Width = 201;
dgv_P.Columns.Add(dc1_P);

DataGridViewTextBoxColumn dc2_P = new DataGridViewTextBoxColumn();//预算
dc2_P.Name = dgv_P.Name + "_PayStandardPercent";
//dc2.Width = 126;
dc2_P.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dgv_P.Columns.Add(dc2_P);

dgv_P.Columns[dgv_P.Name + "_PayStandardItem"].DataPropertyName = "PayStandardItem";
dgv_P.Columns[dgv_P.Name + "_PayStandardPercent"].DataPropertyName = "_PayStandardPercent";
DataTable dt = dtItemP.Clone();
for (int j = 0; j {
dt.Rows.Add(level2[j].ItemArray);
}
dgv_P.DataSource = dt;
panel.Controls.Add(dgv_P, 5, CurrentRow);
dgv_P.Margin = new Padding(0, 0, 0, 0);
}
else
{
DataGridView dgv_P = new DataGridView();
dgv_P.AutoGenerateColumns = false;
dgv_P.Height = 20 * level1.Length;
dgv_P.ScrollBars = ScrollBars.None;
dgv_P.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right;
dgv_P.AllowUserToResizeColumns = false;
dgv_P.AllowUserToResizeRows = false;
dgv_P.AllowUserToAddRows = false;
dgv_P.AllowUserToDeleteRows = false;
dgv_P.BackgroundColor = Color.White;
dgv_P.ColumnHeadersVisible = false;
dgv_P.RowsDefaultCellStyle.SelectionBackColor = Color.AliceBlue;
dgv_P.RowsDefaultCellStyle.SelectionForeColor = Color.Black;
dgv_P.RowHeadersVisible = false;
dgv_P.BorderStyle = BorderStyle.None;

DataGridViewTextBoxColumn dc1_P = new DataGridViewTextBoxColumn();//项目
dc1_P.Name = dgv_P.Name + "_PayStandardItem";
dc1_P.ReadOnly = true;
dc1_P.Width = 201;
dgv_P.Columns.Add(dc1_P);

DataGridViewTextBoxColumn dc2_P = new DataGridViewTextBoxColumn();//预算
dc2_P.Name = dgv_P.Name + "_PayStandardPercent";
//dc2.Width = 126;
dc2_P.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dgv_P.Columns.Add(dc2_P);

dgv_P.Columns[dgv_P.Name + "_PayStandardItem"].DataPropertyName = "PayStandardItem";
dgv_P.Columns[dgv_P.Name + "_PayStandardPercent"].DataPropertyName = "_PayStandardPercent";
DataTable dt = dtItemP.Clone();
dt.Rows.Add(dt.NewRow());
dgv_P.DataSource = dt;
panel.Controls.Add(dgv_P, 5, CurrentRow);
dgv_P.Margin = new Padding(0, 0, 0, 0);
}
#endregion

}
}
}

private void JSRows()
{
if (dtItemR.Rows.Count > 0)
{
DataTable table = dtItemR;

for (int i = 0; i {
DataRow[] level1 = dtItemR.Select("RewardStandardRewardPriceID=" + dtItemA.Rows[i]["RewardAndPayID"]);
DataRow[] level2 = dtItemP.Select("PayStandardPayPriceID=" + dtItemA.Rows[i]["RewardAndPayID"]);
int row = 0;
if (level1.Length > 0 || level2.Length > 0)
{
row = (level1.Length > level2.Length ? level1.Length : level2.Length);
}
LevelRow = LevelRow + (row == 0 ? 1 : row) + ";";
rows++;
}

}
}

private void dgv_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
DataGridView dgv = sender as DataGridView;
MessageBox.Show(dgv.Name);
}
}
}

预览窗体模板,搜素材,soscw.com

预览窗体模板

标签:des   datagridview   style   class   tar   ext   

原文地址:http://www.cnblogs.com/eric-gms/p/3718799.html


评论


亲,登录后才可以留言!