public partial class DataRelationTest : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
HRM.HRM hrm = new HRM.HRM();
string[] SQLS = new string[3];
SQLS[0]="Select dbo.fDivOrgid(workorgid) orgid,b.seq,b.deptcode,b.brevitycode,indirect,count(*) empqty "+
" from CORPEMPLOYEE A,VDEPT B "+
" where dbo.fDivOrgid(a.workorgid)=b.id "+
" and empstatus='E0F061BA-6C05-4019-81D1-5AFC295FAC15' "+
"group by dbo.fDivOrgid(workorgid),b.seq,b.deptcode,b.brevitycode,indirect "+
"order by b.seq,b.deptcode,indirect ";
SQLS[1]="Select dbo.fDivOrgid(a.orgid) orgid,otid,otpaytype,otreason,b.indirect,c.name reasondesc,sum(ottime) ottime "+
" from CORPOVERTIME A,CORPEMPLOYEE B,CORPCODE C "+
" where a.wdate>='2008/10/01' and wdate<='2008/10/29' "+
" and a.eid=b.id and a.otreason=c.id "+
" group by dbo.fDivOrgid(a.orgid),otid,otpaytype,otreason,b.indirect,c.name";
SQLS[2]="Select dbo.fDivOrgid(workorgid),indirect,sum(early+late)/count(*) "+
" from VDailyWorktime "+
" where wdate>='2008/10/01' and wdate<='2008/10/29' "+
" group by dbo.fDivOrgid(workorgid),indirect";
DataSet DS= hrm.ExecuteBatchQuery(SQLS);
DataRelation OTrelation = new DataRelation("drDiv", DS.Tables[0].Columns["orgid"], DS.Tables[1].Columns["orgid"], false);
DS.Relations.Add(OTrelation);
foreach (DataRow Divrow in DS.Tables[0].Rows)
{
DataRow[] rows = DS.Tables[1].Select("orgid='" + Divrow["orgid"].ToString() + "' and indirect='"+Divrow["indirect"].ToString() +"' ");
forLoop(rows);
}
}
private void forLoop(DataRow[] rows)
{
double payot1 = 0;
double payot2 = 0;
double payot3 = 0;
string otreason = "";
foreach (DataRow row in rows)
{
if (row["otid"].ToString().ToUpper() == "C4BC77C0-7300-427A-9932-037A1EE3F8A0") //加班1
payot1 += Convert.ToDouble(row["ottime"].ToString());
else if (row["otid"].ToString().ToUpper() == "494643D3-7F9F-49CB-8D56-5A140058C74E") //加班2
payot2 += Convert.ToDouble(row["ottime"].ToString());
else if (row["otid"].ToString().ToUpper() == "67AB5A76-F9EC-4127-8D31-5AB56E3006FB") //加班3
payot3 += Convert.ToDouble(row["ottime"].ToString());
otreason = otreason+row["reasondesc"].ToString() + " : " + row["ottime"].ToString() + "<br>";
}
}
}