Namespace Nlisclient.sstform
{
//<summary>
//<para> program name: SST Template Preview Form </para>
// <list type= "table";
//<listheader>
//<term> author </term><term> date </term> <term> version </term><term> change description </term>
//<item>
//<term></term> <term>2014-03-3</term><term>V1.0</term><term> create </term>
//</item>
//</listheader>
//</list>
//</summary>
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;//Pricing table (parent)
DataTable Dtitemr = null;//(sub)
DataTable dtitemp = null;//Claim Form (sub)
int rowp = 0;
int rows = 0;//number of rows
String levelrow = "";//the number of rows per row
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<string, string> dica = new dictionary<string, string> ();
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<string, string> DICR = new dictionary<string, string> ();
DICR = Clientr.search (1, Int32.MaxValue, "Rewardstandardstatus=1");
Dtitemr = NLISClient.UIBase.Helper.TableHelper.DeserializationTable (dicr["table"]);
dictionary<string, string> DICP = new dictionary<string, string> ();
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 < panel. RowCount; 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 < DtItemA.Rows.Count; 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 ();//Ordinal column
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 ();//service item;
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 ();//price of remuneration;
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 to add a table for the standard of remuneration
if (Level1. Length > 0)
{
DataGridView dgv_r = new DataGridView ();
Dgv_r.autogeneratecolumns = false;
Dgv_r.height = * 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 ();//Standard
DC1. Name = Dgv_r.name + "_rewardstandarditem";
DC1. ReadOnly = true;
DC1. Width = 200;
DGV_R.COLUMNS.ADD (DC1);
Datagridviewtextboxcolumn DC2 = new Datagridviewtextboxcolumn ();//Percentage
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 < Level1. Length; 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 = * 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 ();//Standard
DC1. Name = Dgv_r.name + "_rewardstandarditem";
DC1. ReadOnly = true;
DC1. Width = 200;
DGV_R.COLUMNS.ADD (DC1);
Datagridviewtextboxcolumn DC2 = new Datagridviewtextboxcolumn ();//Percentage
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 ();//claim pricing;
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 Add Table claim criteria
if (level2. Length > 0)
{
DataGridView dgv_p = new DataGridView ();
Dgv_p.autogeneratecolumns = false;
Dgv_p.height = * 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 ();//Project
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 ();//Budget
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 < Level2. Length; 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 = * 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 ();//Project
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 ();//Budget
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 < DtItemA.Rows.Count; 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);
}
}
}