DataRelation

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>";

        }
    }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值