当前位置: 首页>>代码示例>>C#>>正文


C# OleDbConnection.GetScalar方法代码示例

本文整理汇总了C#中System.Data.OleDb.OleDbConnection.GetScalar方法的典型用法代码示例。如果您正苦于以下问题:C# OleDbConnection.GetScalar方法的具体用法?C# OleDbConnection.GetScalar怎么用?C# OleDbConnection.GetScalar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Data.OleDb.OleDbConnection的用法示例。


在下文中一共展示了OleDbConnection.GetScalar方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetPaygroupOverheadAnalysisTable

        public static Env.TempDBFPointer GetPaygroupOverheadAnalysisTable(OleDbConnection con, IEnumerable<long> paygroups = null)
        {
            var hourly_methods = new int[] { 8, 9, 14, 15, 16 };
            var pcnt_methods = new int[] { 1, 2, 6 };
            var allowed_methods = hourly_methods.Concat(pcnt_methods).ToArray();

            var hourly_methods_list = string.Format("({0})", string.Join(",", hourly_methods.Select(m => m.ToString()).ToArray()));
            var pcnt_methods_list = string.Format("({0})", string.Join(",", pcnt_methods.Select(m => m.ToString()).ToArray()));
            var allowed_methods_list = string.Format("({0})", string.Join(",", allowed_methods.Select(m => m.ToString()).ToArray()));

            var anal = con.GetTempDBF();

            using (Env.TempDBFPointer
                paygrps = con.BuildRecnumTable(
                    paygroups == null
                        ? GetAllPaygroups(con)
                        : paygroups),
                tmpanal = con.GetTempDBF()
            )
            {
                // con.ExecuteNonQuery("select recnum as paygrp, 0000000000.0000 as overhead1 from {0} into table {1}", paygrps, anal);
                con.ExecuteNonQuery("create table {0} (paygrp n(15) not null, clcnum n(15) not null, overhead1 n(15,4) not null)", tmpanal);

                // build our list of clcs to find values for
                // - first grab paygroup specific benefits
                con.ExecuteNonQuery("insert into {0}"
                    + " select p.recnum, b.dednum as clcnum, b.dedrte as overhead1"
                        + " from {1} p"
                        + " join benfit b on b.paygrp = p.recnum"
                        + " join payded on payded.recnum = b.dednum"
                        + " where payded.clctyp = 3"
                        + " and payded.benovr > 0"
                        + " and payded.clcmth in {2}"
                        , tmpanal, paygrps, allowed_methods_list);

                // now grab our non paygrp specific rates
                con.ExecuteNonQuery("insert into {0}"
                    + " select p.recnum, payded.recnum as clcnum, payded.dftrte as overhead1"
                        + " from {1} p"
                        + " join payded on payded.clctyp = 3 and payded.clcmth in {2} and payded.benovr = 0 and payded.dftact > 0"
                        , tmpanal, paygrps, allowed_methods_list);

                // update hour pcnt rates to actual overhead
                con.ExecuteNonQuery("update anal set anal.overhead1 = anal.overhead1 * paygrp.payrt1 / 100"
                    + " from {0} anal"
                    + " join paygrp on paygrp.recnum = anal.paygrp"
                    + " join payded on payded.recnum = anal.clcnum"
                    + " where payded.clcmth in {1}"
                    , tmpanal, pcnt_methods_list);

                // remove state and local taxes
                /*
                con.ExecuteNonQuery("delete anal from {0} anal"
                    + " join payded on payded.recnum = anal.clcnum and payded.taxloc <> 0"
                    , tmpanal);

                con.ExecuteNonQuery("delete anal from {0} anal"
                    + " join payded on payded.recnum = anal.clcnum and !isnull(payded.taxste) and !empty(payded.taxste)"
                    , tmpanal);
                */

                // fill out the table
                con.ExecuteNonQuery("select anal.paygrp, paygrp.grpnme, anal.clcnum, payded.clcnme, anal.overhead1"
                    + " from {0} anal"
                    + " join paygrp on paygrp.recnum = anal.paygrp"
                    + " join payded on payded.recnum = anal.clcnum"
                    + " into table {1}"
                    , tmpanal, anal);
            #if false
                // add hourly rates
                // - paygrp specific
                con.ExecuteNonQuery("select anal.paygrp, payded.recnum as clcnum, sum(nvl(benfit.dedrte,00000000000.0000)) as dedrte"
                    + " from {0} anal"
                    + " left join benfit on benfit.paygrp = anal.paygrp and anal.clcnum = benfit.dednum"
                    + " left join payded on payded.recnum = benfit.dednum"
                    + " where payded.clcmth in (8, 9, 14, 15, 16)"
                    + " and payded.clctyp = 3"
                    + " and payded.benovr > 0"
                    + " group by 1"
                    + " into table {1}", anal, sums);

                con.ExecuteNonQuery("update anal set anal.overhead1 = sums.dedrte"
                    + " from {0} anal"
                    + " join {1} sums on sums.paygrp = anal.paygrp and anal.clcnum = sums.clcnum"
                    , anal, sums);

                // - nonpaygrp specific
                var nonpghourly = con.GetScalar<decimal>("select p.recnum as paygrp, payded.recnum as clcnum, payded.dftrte as dedrte"
                    + " from payded"
                    + " where payded.clctyp = 3"
                    + " and payded.clcmth in (8, 9, 14, 15, 16)"
                    + " and payded.benovr = 0");

                con.ExecuteNonQuery("update anal set anal.overhead1 = anal.overhead1 + {0} from {1} anal", nonpghourly, anal);

                // percentage rates
                // - paygrp specific
                con.ExecuteNonQuery("select anal.paygrp, sum(benfit.dedrte) as dedrte"
                    + " from {0} anal"
                    + " join benfit on benfit.paygrp = anal.paygrp"
//.........这里部分代码省略.........
开发者ID:vimalgupta1980,项目名称:dotnetlibs,代码行数:101,代码来源:PaygroupAnalysis.cs


注:本文中的System.Data.OleDb.OleDbConnection.GetScalar方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。