Пример #1
0
    //protected bool loadObject()
    //{
    //    obj = new EPayrollGroup();
    //    bool isNew = WebFormWorkers.loadKeys(db, obj, DecryptedRequest);
    //    if (!db.select(dbConn, obj))
    //        return false;

    //    Hashtable values = new Hashtable();
    //    db.populate(obj, values);
    //    binding.toControl(values);

    //    if (CurPayPeriodID <= 0)
    //    {
    //        CurPayPeriodID = obj.CurrentPayPeriodID;
    //    }

    //    if (obj.CurrentPayPeriodID > 0)
    //        panelBankFileInfo.Visible = true;
    //    else
    //        panelBankFileInfo.Visible = false;


    //    return true;
    //}



    public DataView payBatchloadData(ListInfo info, DBManager db, Repeater repeater)
    {
        DateTime dtPeriodFr = new DateTime(), dtPeriodTo = new DateTime();

        if (DateTime.TryParse(PayPeriodFr.Value, out dtPeriodFr) && DateTime.TryParse(PayPeriodTo.Value, out dtPeriodTo))
        {
            DBFilter filter = payBatchSBinding.createFilter();

            //if (info != null && info.orderby != null && !info.orderby.Equals(""))
            //    filter.add(info.orderby, info.order);

            string select = "pg.PayGroupCode, pg.PayGroupDesc, pp.PayPeriodFr, pp.PayPeriodTo, pb.* ";
            string from   = "from [" + EPayrollGroup.db.dbclass.tableName + "] pg, [" + EPayrollPeriod.db.dbclass.tableName + "] pp, [" + EPayrollBatch.db.dbclass.tableName + "] pb ";

            filter.add(new MatchField("pg.PayGroupID", "pp.PayGroupID"));
            filter.add(new Match("pp.PayPeriodFr", ">=", dtPeriodFr));
            filter.add(new Match("pp.PayPeriodTo", "<=", dtPeriodTo));


            DBFilter empPayrollFilter = new DBFilter();
            //empPayrollFilter.add(new MatchField("pb.payBatchID", "ep.payBatchID"));
            empPayrollFilter.add(new Match("ep.EmpPayStatus", "C"));
            empPayrollFilter.add(new MatchField("ep.PayPeriodID", "pp.PayPeriodID"));

            DBFilter payRecordFilter = new DBFilter();
            //payRecordFilter.add(new MatchField("ep.EmpPayrollID", "pr.EmpPayrollID"));

            //Exists existsPayRec = new Exists(EPaymentRecord.db.dbclass.tableName + " pr", payRecordFilter);
            //empPayrollFilter.add(existsPayRec);

            //Exists exists = new Exists("EmpPayroll ep", empPayrollFilter);
            //        IN existsPayRec = new IN("ep.EmpPayrollID", "Select distinct pr.EmpPayrollID from (select EmpPayrollID,PayRecMethod from " + EPaymentRecord.db.dbclass.tableName + " group by EmpPayrollID, PayRecMethod) pr", payRecordFilter);
            IN existsPayRec = new IN("ep.EmpPayrollID", "Select distinct pr.EmpPayrollID from (select distinct EmpPayrollID,PayRecMethod from " + EPaymentRecord.db.dbclass.tableName + ") pr", payRecordFilter);
            empPayrollFilter.add(existsPayRec);

            IN exists = new IN("pb.payBatchID", "Select distinct ep.payBatchID from " + EEmpPayroll.db.dbclass.tableName + " ep", empPayrollFilter);


            filter.add(exists);
            DataTable table = WebUtils.GetDataTableFromSelectQueryWithFilter(dbConn, select, from, filter, payBatchInfo);

            if (table.Rows.Count != 0)
            {
                panelPayPeriod.Visible       = true;
                ReportExportControl1.Visible = true;
                ReportExportControl2.Visible = true;
            }
            else
            {
                panelPayPeriod.Visible       = false;
                ReportExportControl1.Visible = false;
                ReportExportControl2.Visible = false;
            }
            payBatchView = new DataView(table);

            PayBatchListFooter.Refresh();

            if (repeater != null)
            {
                repeater.DataSource = payBatchView;
                repeater.DataBind();
            }

            return(payBatchView);
        }
        else
        {
            panelPayPeriod.Visible       = false;
            ReportExportControl1.Visible = false;
            ReportExportControl2.Visible = false;
            return(null);
        }
    }
    public DataView payBatchloadData(ListInfo info, DBManager db, Repeater repeater)
    {
        DBFilter filter = payBatchSBinding.createFilter();

        //if (info != null && info.orderby != null && !info.orderby.Equals(""))
        //    filter.add(info.orderby, info.order);

        string select = "pg.PayGroupCode, pg.PayGroupDesc, pp.PayPeriodFr, pp.PayPeriodTo";
        string from   = "from [" + EPayrollGroup.db.dbclass.tableName + "] pg, [" + EPayrollPeriod.db.dbclass.tableName + "] pp";

        filter.add(new MatchField("pg.PayGroupID", "pp.PayGroupID"));
        // Start 0000069, KuangWei, 2014-08-28

        int m_payGroupID;

        if (int.TryParse(PayGroupID.SelectedValue, out m_payGroupID) && m_payGroupID > 0)
        {
            filter.add(new Match("pg.PayGroupID", m_payGroupID));
        }
        else
        {
            DBFilter m_payrollGroupUsersFilter = new DBFilter();
            m_payrollGroupUsersFilter.add(new Match("UserID", WebUtils.GetCurUser(Session).UserID));

            DBFilter m_payrollGroupFilter = new DBFilter();
            m_payrollGroupFilter.add(new Match("PayGroupIsPublic", true));

            OR m_OrPayGroupID = new OR();
            m_OrPayGroupID.add(new IN("pg.PayGroupID", "SELECT PayGroupID FROM PayrollGroupUsers", m_payrollGroupUsersFilter));
            m_OrPayGroupID.add(new IN("pg.PayGroupID", "SELECT PayGroupID FROM PayrollGroup", m_payrollGroupFilter));

            filter.add(m_OrPayGroupID);
        }


        // End 0000069, KuangWei, 2014-08-28

        if (PayrollStatus.SelectedValue.Equals("C"))
        {
            if (SkipProcessEndPeriod)
            {
                filter.add(new Match("pp.PayPeriodStatus", "<>", "E"));
            }
            else
            {
                DateTime dtPeriodFr = new DateTime(), dtPeriodTo = new DateTime();
                if (DateTime.TryParse(PayPeriodFr.Value, out dtPeriodFr))
                {
                    filter.add(new Match("pp.PayPeriodTo", ">=", dtPeriodFr));
                }

                if (DateTime.TryParse(PayPeriodTo.Value, out dtPeriodTo))
                {
                    filter.add(new Match("pp.PayPeriodFr", "<=", dtPeriodTo));
                }
                if (dtPeriodFr.Ticks.Equals(0) || dtPeriodTo.Ticks.Equals(0))
                {
                    filter.add(new Match("pp.PayPeriodID", "=", 0));
                }
            }
        }

        DBFilter empPayrollFilter = new DBFilter();

        //empPayrollFilter.add(new MatchField("pb.payBatchID", "ep.payBatchID"));
        empPayrollFilter.add(new Match("ep.EmpPayStatus", PayrollStatus.SelectedValue));


        empPayrollFilter.add(new MatchField("ep.PayPeriodID", "pp.PayPeriodID"));

        //DBFilter payRecordFilter = new DBFilter();
        ////payRecordFilter.add(new MatchField("ep.EmpPayrollID", "pr.EmpPayrollID"));

        //OR orPayMethodTerm = new OR();
        //orPayMethodTerm.add(new Match("PayRecMethod", "A"));

        //if (bankFileControl != null)
        //{
        //    if (bankFileControl.IsAllowChequePayment())
        //        orPayMethodTerm.add(new Match("PayRecMethod", "Q"));

        //}
        //payRecordFilter.add(orPayMethodTerm);
        ////Exists existsPayRec = new Exists(EPaymentRecord.db.dbclass.tableName + " pr", payRecordFilter);
        ////empPayrollFilter.add(existsPayRec);

        ////Exists exists = new Exists("EmpPayroll ep", empPayrollFilter);
        ////        IN existsPayRec = new IN("ep.EmpPayrollID", "Select distinct pr.EmpPayrollID from (select EmpPayrollID,PayRecMethod from " + EPaymentRecord.db.dbclass.tableName + " group by EmpPayrollID, PayRecMethod) pr", payRecordFilter);
        //IN existsPayRec = new IN("ep.EmpPayrollID", "Select distinct pr.EmpPayrollID from (select distinct EmpPayrollID,PayRecMethod from " + EPaymentRecord.db.dbclass.tableName + ") pr", payRecordFilter);
        //empPayrollFilter.add(existsPayRec);

        if (PayrollStatus.SelectedValue.Equals("C"))
        {
            select += " , pb.PayBatchID, pb.PayBatchConfirmDate, pb.PayBatchFileGenDate, pb.PayBatchValueDate, pb.PayBatchFileGenBy, pb.PayBatchRemark ";
            from   += ", [" + EPayrollBatch.db.dbclass.tableName + "] pb ";
            IN exists = new IN("pb.payBatchID", "Select distinct ep.payBatchID from " + EEmpPayroll.db.dbclass.tableName + " ep", empPayrollFilter);
            filter.add(exists);
        }
        else if (PayrollStatus.SelectedValue.Equals("T"))
        {
            select += " , pp.PayPeriodID, NULL AS PayBatchConfirmDate, NULL AS PayBatchFileGenDate, NULL AS PayBatchValueDate, NULL AS PayBatchFileGenBy, NULL AS PayBatchRemark ";
            IN exists = new IN("pp.PayPeriodID", "Select distinct ep.PayPeriodID from " + EEmpPayroll.db.dbclass.tableName + " ep", empPayrollFilter);
            filter.add(exists);
        }

        DataTable table = WebUtils.GetDataTableFromSelectQueryWithFilter(dbConn, select, from, filter, payBatchInfo);

        //if (table.Rows.Count != 0)
        //{
        //    panelPayPeriod.Visible = true;
        //    btnGenerate.Visible = true & IsAllowEdit;
        //    btnAutoPayList.Visible = true & IsAllowEdit;
        //    btnAutoPayListExcel.Visible = true & IsAllowEdit;
        //}
        //else
        //{
        //    panelPayPeriod.Visible = false;
        //    btnGenerate.Visible = false;
        //    btnAutoPayList.Visible = false;
        //}
        payBatchView = new DataView(table);

        PayBatchListFooter.Refresh();

        if (repeater != null)
        {
            repeater.DataSource = payBatchView;
            repeater.DataBind();
        }

        return(payBatchView);
    }