|
private void changColumn ()
{
Ranch
// Create a DataTable object, including columns DataTable dataTable = new DataTable ("FunctionArea");
string [] arrstrFunctionalArea = new string [] {"No.", "id", "jsid", "unit name", "name", "post salary", "pay scale salary", "reserved salary", "housing "Aid", "Aided Wage", "Supplement One", "Supplement Two", "Supplement Three", "Performance Wage", "Supplemental Difference", "Telephone Fee", "Festival Allowance", "Amount Due", "House Provident Fund "," Meals "," Deduction 1 "," Deduction 2 "," Actual Amount "};
DataColumn dtCol = null;
// Create String column
for (int i = 0; i <arrstrFunctionalArea.Length; i ++)
{
dtCol = new DataColumn (arrstrFunctionalArea [i]);
dtCol.DataType = Type.GetType ("System.String");
dtCol.DefaultValue = "";
dataTable.Columns.Add (dtCol);
}
// Bind the table to the DataGrid
dataGrid.DataSource = dataTable;
Ranch
// Load DataGridTableStyle style for DataGrid
if (! dataGrid.TableStyles.Contains ("FunctionArea"))
{
DataGridTableStyle dgdtblStyle = new DataGridTableStyle ();
dgdtblStyle.MappingName = dataTable.TableName;
dataGrid.TableStyles.Add (dgdtblStyle);
dgdtblStyle.RowHeadersVisible = false;
dgdtblStyle.HeaderBackColor = Color.LightSteelBlue;
dgdtblStyle.AllowSorting = false;
dgdtblStyle.HeaderBackColor = Color.FromArgb (8,36,107);
dgdtblStyle.RowHeadersVisible = false;
dgdtblStyle.HeaderForeColor = Color.White;
dgdtblStyle.HeaderFont = new System.Drawing.Font ("Microsoft Sans Serif", 9F,
System.Drawing.FontStyle.Bold,
System.Drawing.GraphicsUnit.Point, ((System.Byte) (0)));
dgdtblStyle.GridLineColor = Color.DarkGray;
dgdtblStyle.PreferredRowHeight = 22;
dataGrid.BackgroundColor = Color.White;
// Set the width of the column
GridColumnStylesCollection colStyle = dataGrid.TableStyles [0] .GridColumnStyles;
colStyle [0] .Width = 30;
colStyle [1] .Width = 0;
colStyle [2] .Width = 0;
colStyle [3] .Width = 70;
colStyle [4] .Width = 35;
for (int j = 4; j <= 22; j ++)
colStyle [j] .Width = 50;
DataTable dt = data.GetDataTable ("select id as sequence number, jsid as unit number, dpname as unit name,"
+ "name as name, gw as post salary, xj as salary salary, bl as reserved salary,"
+ "zf as housing subsidy, bz as supplementary salary, ba as supplement one, bb as supplement two,"
+ "bc as supplement three, jx as performance salary, bch as supplement, dh as telephone fee,"
+ "jb as holiday subsidy, gw + xj + bl + zf + bz + ba + bb + bc + jx + bch + dh + jb as claim amount, kzf as housing provident fund, khs as food expenses, ka as deduction , "
+ "kb as deduction for two, claim amount -kzf-khs-ka-kb as actual amount from ryinfo");
string s = dt.Rows [0] [0] .ToString ();
for (int i = 0; i <dt.Rows.Count; i ++)
{
DataRow myDataRow = dataTable.NewRow ();
myDataRow [0] = i + 1;
for (int j = 0; j <22; j ++)
myDataRow [j + 1] = dt.Rows [i] [j];
dataTable.Rows.Add (myDataRow);
}
}
} |
|