Example #1
0
        private void MergeDuplicatePersonFees(AcountCheckTemp.ERRORACCOUT_DOUBLERow dr)
        {
            //查出流水中的实际额度,可用额度
            //实际额度
            string strActual = @"select sum(zzz.BUDGETMONEY) from zzz_person  zzz where zzz.OWNERCOMPANYID='" + dr.OWNERCOMPANYID +
                        "' and zzz.SUBJECTID='" + dr.SUBJECTID + "' and zzz.OWNERID='" + dr.OWNERID + "'"
                        + "and zzz.CHECKSTATESNAME='审核通过'";
            object Actualobj = dal.ExecuteCustomerSql(strActual);



            //可用额度
            string strUsable = @"select sum(zzz.BUDGETMONEY) from zzz_person  zzz where zzz.OWNERCOMPANYID='" + dr.OWNERCOMPANYID +
                        "' and zzz.SUBJECTID='" + dr.SUBJECTID + "' and zzz.OWNERID='" + dr.OWNERID + "'"
                        + "or ( zzz.OWNERCOMPANYID='" + dr.OWNERCOMPANYID +
                       "' and zzz.SUBJECTID='" + dr.SUBJECTID + "' and zzz.OWNERID='" + dr.OWNERID + "'"
                        + "and zzz.CHECKSTATESNAME <> '审核中'"
                        + "and zzz.ORDERTYPENAME = '还款单') ";
            object Usableobj = dal.ExecuteCustomerSql(strUsable);

            //取流水最新数据
            string strFreshRecord = @"select ep.POSTID,d.DEPARTMENTID,c.COMPANYID from  smthrm.t_hr_employeepost ep  
                                        inner join smthrm.t_hr_post p on ep.postid = p.postid
                                         inner join smthrm.t_hr_department d on p.departmentid = d.departmentid
                                         inner join smthrm.t_hr_company c on d.companyid = c.companyid where ep.OWNERID='" + dr.OWNERID + "'"
                                        +@"and  ep.editstate=1  and ep.checkstate=2 and ep.isagency=0";

            DataTable dtFreshRecord = dal.GetDataTable(strFreshRecord);
            


            decimal Actualmoney = 0;
            if (Actualobj != null)
            {
                Actualmoney = decimal.Parse(Actualobj.ToString());
            }
            decimal Usablemoney = 0;
            if (Usableobj != null)
            {
                Usablemoney = decimal.Parse(Usableobj.ToString());
            }
            DataRow[] rows = dt.Select("ACCOUNTOBJECTTYPE=3 and OWNERCOMPANYID='" + dr.OWNERCOMPANYID +
                        "' and SUBJECTID='" + dr.SUBJECTID + "' and OWNERID='" + dr.OWNERID + "'");
            if (rows.Count() > 1)
            {
                string updateid = rows[0]["BUDGETACCOUNTID"].ToString();
                
                string strUpdate = "update t_fb_budgetaccount t set t.actualmoney=" + Actualmoney
                    + ", t.usablemoney=" + Usablemoney + " where t.budgetaccountid='" + updateid + "'";
                object falg = dal.ExecuteCustomerSql(strUpdate);

                //更新为最新的公司,部门,岗位
                if (dtFreshRecord.Rows.Count > 0)
                {
                    string strUpdateFreshRow = "update t_fb_budgetaccount t set t.OWNERDEPARTMENTID=" + dtFreshRecord.Rows[0]["DEPARTMENTID"].ToString()
                        + ", t.OWNERPOSTID=" + dtFreshRecord.Rows[0]["POSTID"].ToString()
                   + ", t.OWNERCOMPANYID=" + dtFreshRecord.Rows[0]["COMPANYID"].ToString() + " where t.budgetaccountid='" + updateid + "'";
                    object falgs = dal.ExecuteCustomerSql(strUpdate);
                }

                foreach (DataRow drdel in rows)
                {
                    if (drdel["BUDGETACCOUNTID"] == System.DBNull.Value)
                    {
                        continue;
                    }

                    if (drdel["BUDGETACCOUNTID"].ToString() != updateid)
                    {
                        string strdel = "delete t_fb_budgetaccount t where t.budgetaccountid='" + drdel["BUDGETACCOUNTID"].ToString() + "'";
                        object falgdel = dal.ExecuteCustomerSql(strdel);
                    }
                }
            }
        }
Example #2
0
        private void MergeDuplicateDepartFees(AcountCheckTemp.ERRORACCOUT_DOUBLERow dr)
        {
            //查出流水中的实际额度,可用额度
            //实际额度
            string strActual = @"select sum(zzz.BUDGETMONEY) from ZZZ_DEPT  zzz where zzz.OWNERCOMPANYID='" + dr.OWNERCOMPANYID +
                        "' and zzz.SUBJECTID='" + dr.SUBJECTID + "' and zzz.OWNERDEPARTMENTID='" + dr.OWNERDEPARTMENTID + "'"
                        + "and zzz.CHECKSTATESNAME='审核通过'";
            object Actualobj = dal.ExecuteCustomerSql(strActual);
            //可用额度
            string strUsable = @"select sum(zzz.BUDGETMONEY) from ZZZ_DEPT  zzz where zzz.OWNERCOMPANYID='" + dr.OWNERCOMPANYID +
                        "' and zzz.SUBJECTID='" + dr.SUBJECTID + "' and zzz.OWNERDEPARTMENTID='" + dr.OWNERDEPARTMENTID + "'"
                        + "and zzz.CHECKSTATESNAME <> '审核中或未汇总'";
            object Usableobj = dal.ExecuteCustomerSql(strUsable);

            decimal Actualmoney = 0;
            if (Actualobj != null)
            {
                Actualmoney = decimal.Parse(Actualobj.ToString());
            }
            decimal Usablemoney = 0;
            if (Usableobj != null)
            {
                Usablemoney = decimal.Parse(Usableobj.ToString());
            }
            DataRow[] rows = dt.Select("ACCOUNTOBJECTTYPE=2 and OWNERCOMPANYID='" + dr.OWNERCOMPANYID +
                        "' and SUBJECTID='" + dr.SUBJECTID + "' and OWNERDEPARTMENTID='" + dr.OWNERDEPARTMENTID + "'");
            if (rows.Count() > 1)
            {
                string updateid = rows[0]["BUDGETACCOUNTID"].ToString();
                string strUpdate = "update t_fb_budgetaccount t set t.actualmoney=" + Actualmoney
                    + ", t.usablemoney=" + Usablemoney + " where t.budgetaccountid='" + updateid + "'";
                object falg = dal.ExecuteCustomerSql(strUpdate);
                foreach (DataRow drdel in rows)
                {
                    if (drdel["BUDGETACCOUNTID"] == System.DBNull.Value)
                    {
                        continue;
                    }

                    if (drdel["BUDGETACCOUNTID"].ToString() != updateid)
                    {
                        string strdel = "delete t_fb_budgetaccount t where t.budgetaccountid='" + drdel["BUDGETACCOUNTID"].ToString() + "'";
                        object falgdel = dal.ExecuteCustomerSql(strdel);
                    }
                }
            }
        }