예제 #1
0
파일: BudgetBLL.cs 프로젝트: hijoy/CPL_ERS
        public void UpdateBudgetManageFee(int BudgetManageFeeID, decimal AOPRBudget, int UserID, int PositionID, string ModifyReason)
        {
            SqlTransaction transaction = null;
            try {
                ////事务开始
                transaction = TableAdapterHelper.BeginTransaction(this.TABudgetManageFee);
                TableAdapterHelper.SetTransaction(this.TABudgetManageFeeHistory, transaction);

                // 父表
                Budget.BudgetManageFeeRow row = this.TABudgetManageFee.GetDataByID(BudgetManageFeeID)[0];

                if (row.AOPRBudget > AOPRBudget) {
                    decimal[] calculateAssistant = this.GetPersonalBudgetByOUID(row.OrganizationUnitID, row.Year);
                    if (row.AOPRBudget - AOPRBudget > calculateAssistant[3]) {
                        throw new MyException("本次修改导致原有记录超预算,不能修改,目前部门剩余预算为:" + calculateAssistant[3], "Over budget,modify failed,current remain budget is :" + calculateAssistant[3]);
                    }
                }

                row.AOPRBudget = AOPRBudget;
                row.ModifyReason = ModifyReason;

                this.TABudgetManageFee.Update(row);

                // 子表
                Budget.BudgetManageFeeHistoryDataTable tableHistory = new Budget.BudgetManageFeeHistoryDataTable();
                Budget.BudgetManageFeeHistoryRow rowHistory = tableHistory.NewBudgetManageFeeHistoryRow();

                rowHistory.OrganizationUnitID = row.OrganizationUnitID;
                rowHistory.Year = row.Year;
                rowHistory.AOPBudget = row.AOPRBudget;
                rowHistory.AOPRBudget = row.AOPRBudget;
                rowHistory.AdjustBudget = row.AdjustBudget;
                rowHistory.Action = "Modify";
                rowHistory.ModifyDate = DateTime.Now;
                rowHistory.PositionID = PositionID;
                rowHistory.UserID = UserID;
                rowHistory.ModifyReason = ModifyReason;
                rowHistory.BudgetManageFeeID = row.BudgetManageFeeID;
                tableHistory.AddBudgetManageFeeHistoryRow(rowHistory);
                this.TABudgetManageFeeHistory.Update(tableHistory);

                transaction.Commit();
            } catch (Exception ex) {
                transaction.Rollback();
                throw ex;
            } finally {
                transaction.Dispose();
            }
        }
예제 #2
0
파일: BudgetBLL.cs 프로젝트: hijoy/CPL_ERS
        public void InsertBudgetManageFee(int OrganizationUnitID, int Year, decimal AOPBudget, decimal AOPRBudget, string ModifyReason, int UserID, int PositionID)
        {
            SqlTransaction transaction = null;
            try {

                //事务开始
                transaction = TableAdapterHelper.BeginTransaction(this.TABudgetManageFee);
                TableAdapterHelper.SetTransaction(this.TABudgetManageFeeHistory, transaction);

                //验证预算是否已存在,或者有父子部门,已设置过预算
                if ((int)this.TABudgetManageFee.SearchBudgetManageByIns(GetTreePathByOUID(OrganizationUnitID), Year) > 0) {
                    throw new MyException("预算重复设置或者上级或下级部门已经设置预算,不能增加!", "Insert failed, budget exists!");
                }

                // 父表
                Budget.BudgetManageFeeDataTable table = new Budget.BudgetManageFeeDataTable();
                Budget.BudgetManageFeeRow row = table.NewBudgetManageFeeRow();

                row.OrganizationUnitID = OrganizationUnitID;
                row.Year = Year;
                row.AOPBudget = AOPBudget;
                row.AOPRBudget = AOPRBudget;
                if (ModifyReason != null) {
                    row.ModifyReason = ModifyReason;
                }

                table.AddBudgetManageFeeRow(row);
                this.TABudgetManageFee.Update(table);

                // 子表
                Budget.BudgetManageFeeHistoryDataTable tableHistory = new Budget.BudgetManageFeeHistoryDataTable();
                Budget.BudgetManageFeeHistoryRow rowHistory = tableHistory.NewBudgetManageFeeHistoryRow();

                rowHistory.OrganizationUnitID = OrganizationUnitID;
                rowHistory.Year = Year;
                rowHistory.AOPBudget = AOPBudget;
                rowHistory.AOPRBudget = AOPRBudget;
                rowHistory.Action = "Create";
                rowHistory.ModifyDate = DateTime.Now;
                rowHistory.PositionID = PositionID;
                rowHistory.UserID = UserID;
                if (ModifyReason != null) {
                    rowHistory.ModifyReason = ModifyReason;
                }
                rowHistory.BudgetManageFeeID = row.BudgetManageFeeID;

                tableHistory.AddBudgetManageFeeHistoryRow(rowHistory);
                this.TABudgetManageFeeHistory.Update(tableHistory);

                transaction.Commit();
            } catch (Exception ex) {
                transaction.Rollback();
                throw ex;
            } finally {
                transaction.Dispose();
            }
        }