Beispiel #1
0
        public void InsertBudgetSalesFee(int CustomerID, int ExpenseItemID, DateTime Period, decimal OriginalBudget, decimal NormalBudget, decimal AdjustBudget, decimal TransferBudget, int UserID, int PositionID, String ModifyReason)
        {
            SqlTransaction transaction = null;

            try {
                ////事务开始
                transaction = TableAdapterHelper.BeginTransaction(this.TABudgetSales);
                TableAdapterHelper.SetTransaction(this.TABudgetSalesHistory, transaction);

                //检验重复性 客户、费用项、费用期间三项不能重复
                int iCount = this.TABudgetSales.SearchBudgetSalesByIns(CustomerID, ExpenseItemID, Period).GetValueOrDefault();
                if (iCount > 0)
                {
                    throw new ApplicationException("客户、费用项、费用期间三项不能重复!");
                }

                // 父表
                BudgetDS.BudgetSalesFeeDataTable table = new BudgetDS.BudgetSalesFeeDataTable();
                BudgetDS.BudgetSalesFeeRow       row   = table.NewBudgetSalesFeeRow();

                row.CustomerID     = CustomerID;
                row.ExpenseItemID  = ExpenseItemID;
                row.Period         = Period;
                row.OriginalBudget = OriginalBudget;
                row.NormalBudget   = NormalBudget;
                row.AdjustBudget   = AdjustBudget;
                row.TransferBudget = TransferBudget;
                row.ModifyReason   = ModifyReason;
                table.AddBudgetSalesFeeRow(row);
                this.TABudgetSales.Update(table);

                // 子表
                BudgetDS.BudgetSalesFeeHistoryDataTable tableDetail = new BudgetDS.BudgetSalesFeeHistoryDataTable();
                BudgetDS.BudgetSalesFeeHistoryRow       rowDetail   = tableDetail.NewBudgetSalesFeeHistoryRow();

                rowDetail.BudgetSalesFeeID = row.BudgetSalesFeeID;
                rowDetail.UserID           = UserID;
                rowDetail.PositionID       = PositionID;
                rowDetail.ModifyDate       = DateTime.Now;
                rowDetail.Action           = "Create";
                rowDetail.CustomerID       = CustomerID;
                rowDetail.ExpenseItemID    = ExpenseItemID;
                rowDetail.Period           = Period;
                rowDetail.OriginalBudget   = OriginalBudget;
                rowDetail.NormalBudget     = NormalBudget;
                rowDetail.AdjustBudget     = AdjustBudget;
                rowDetail.TransferBudget   = TransferBudget;
                rowDetail.ModifyReason     = ModifyReason;
                tableDetail.AddBudgetSalesFeeHistoryRow(rowDetail);
                this.TABudgetSalesHistory.Update(tableDetail);

                transaction.Commit();
            } catch (Exception ex) {
                transaction.Rollback();
                throw ex;
            } finally {
                transaction.Dispose();
            }
        }
Beispiel #2
0
        public void UpdateBudgetSalesFee(int BudgetSalesFeeID, decimal NormalBudget, decimal AdjustBudget, decimal TransferBudget, int UserID, int PositionID, String ModifyReason)
        {
            SqlTransaction transaction = null;

            try {
                ////事务开始
                transaction = TableAdapterHelper.BeginTransaction(this.TABudgetSales);
                TableAdapterHelper.SetTransaction(this.TABudgetSalesHistory, transaction);

                // 父表
                BudgetDS.BudgetSalesFeeRow row = this.TABudgetSales.GetDataById(BudgetSalesFeeID)[0];
                if (row.TotalBudget > (NormalBudget + AdjustBudget))  //如果是减少预算,要做检查
                {
                    decimal[] calculateAssistant = new decimal[14];
                    calculateAssistant = this.GetSalesBudgetByParameter(row.CustomerID, row.Period, new MasterDataBLL().GetExpenseItemByID(row.ExpenseItemID).ExpenseSubCategoryID);
                    if (row.TotalBudget - NormalBudget - AdjustBudget - TransferBudget > calculateAssistant[12])
                    {
                        throw new ApplicationException("本次修改导致原有记录超预算,不能修改");
                    }
                }
                row.NormalBudget   = NormalBudget;
                row.AdjustBudget   = AdjustBudget;
                row.TransferBudget = TransferBudget;
                row.ModifyReason   = ModifyReason;
                this.TABudgetSales.Update(row);

                // 子表
                BudgetDS.BudgetSalesFeeHistoryDataTable tableDetail = new BudgetDS.BudgetSalesFeeHistoryDataTable();
                BudgetDS.BudgetSalesFeeHistoryRow       rowDetail   = tableDetail.NewBudgetSalesFeeHistoryRow();

                rowDetail.BudgetSalesFeeID = row.BudgetSalesFeeID;
                rowDetail.UserID           = UserID;
                rowDetail.PositionID       = PositionID;
                rowDetail.ModifyDate       = DateTime.Now;
                rowDetail.Action           = "Modify";
                rowDetail.CustomerID       = row.CustomerID;
                rowDetail.ExpenseItemID    = row.ExpenseItemID;
                rowDetail.Period           = row.Period;
                rowDetail.OriginalBudget   = row.OriginalBudget;
                rowDetail.NormalBudget     = NormalBudget;
                rowDetail.AdjustBudget     = AdjustBudget;
                rowDetail.TransferBudget   = TransferBudget;
                rowDetail.ModifyReason     = ModifyReason;
                tableDetail.AddBudgetSalesFeeHistoryRow(rowDetail);
                this.TABudgetSalesHistory.Update(tableDetail);

                transaction.Commit();
            } catch (Exception ex) {
                transaction.Rollback();
                throw ex;
            } finally {
                transaction.Dispose();
            }
        }
Beispiel #3
0
        public void UpdateBudgetSalesFee(int BudgetSalesFeeID, decimal NormalBudget, decimal AdjustBudget,decimal TransferBudget, int UserID, int PositionID, String ModifyReason)
        {
            SqlTransaction transaction = null;
            try {

                ////����ʼ
                transaction = TableAdapterHelper.BeginTransaction(this.TABudgetSales);
                TableAdapterHelper.SetTransaction(this.TABudgetSalesHistory, transaction);

                // ����
                BudgetDS.BudgetSalesFeeRow row = this.TABudgetSales.GetDataById(BudgetSalesFeeID)[0];
                if (row.TotalBudget > (NormalBudget + AdjustBudget)) {//����Ǽ���Ԥ��,Ҫ�����
                    decimal[] calculateAssistant = new decimal[14];
                    calculateAssistant = this.GetSalesBudgetByParameter(row.CustomerID, row.Period, new MasterDataBLL().GetExpenseItemByID(row.ExpenseItemID).ExpenseSubCategoryID);
                    if (row.TotalBudget - NormalBudget - AdjustBudget - TransferBudget > calculateAssistant[12]) {
                        throw new ApplicationException("�����޸ĵ���ԭ�м�¼��Ԥ�㣬�����޸�");
                    }
                }
                row.NormalBudget = NormalBudget;
                row.AdjustBudget = AdjustBudget;
                row.TransferBudget = TransferBudget;
                row.ModifyReason = ModifyReason;
                this.TABudgetSales.Update(row);

                // �ӱ�
                BudgetDS.BudgetSalesFeeHistoryDataTable tableDetail = new BudgetDS.BudgetSalesFeeHistoryDataTable();
                BudgetDS.BudgetSalesFeeHistoryRow rowDetail = tableDetail.NewBudgetSalesFeeHistoryRow();

                rowDetail.BudgetSalesFeeID = row.BudgetSalesFeeID;
                rowDetail.UserID = UserID;
                rowDetail.PositionID = PositionID;
                rowDetail.ModifyDate = DateTime.Now;
                rowDetail.Action = "Modify";
                rowDetail.CustomerID = row.CustomerID;
                rowDetail.ExpenseItemID = row.ExpenseItemID;
                rowDetail.Period = row.Period;
                rowDetail.OriginalBudget = row.OriginalBudget;
                rowDetail.NormalBudget = NormalBudget;
                rowDetail.AdjustBudget = AdjustBudget;
                rowDetail.TransferBudget = TransferBudget;
                rowDetail.ModifyReason = ModifyReason;
                tableDetail.AddBudgetSalesFeeHistoryRow(rowDetail);
                this.TABudgetSalesHistory.Update(tableDetail);

                transaction.Commit();
            } catch (Exception ex) {
                transaction.Rollback();
                throw ex;
            } finally {
                transaction.Dispose();
            }
        }
Beispiel #4
0
        public void InsertBudgetSalesFee(int CustomerID, int ExpenseItemID, DateTime Period, decimal OriginalBudget, decimal NormalBudget, decimal AdjustBudget, decimal TransferBudget, int UserID, int PositionID, String ModifyReason)
        {
            SqlTransaction transaction = null;
            try {
                ////����ʼ
                transaction = TableAdapterHelper.BeginTransaction(this.TABudgetSales);
                TableAdapterHelper.SetTransaction(this.TABudgetSalesHistory, transaction);

                //�����ظ��� �ͻ�������������ڼ�������ظ�
                int iCount = this.TABudgetSales.SearchBudgetSalesByIns(CustomerID, ExpenseItemID, Period).GetValueOrDefault();
                if (iCount > 0) {
                    throw new ApplicationException("�ͻ�������������ڼ�������ظ�!");
                }

                // ����
                BudgetDS.BudgetSalesFeeDataTable table = new BudgetDS.BudgetSalesFeeDataTable();
                BudgetDS.BudgetSalesFeeRow row = table.NewBudgetSalesFeeRow();

                row.CustomerID = CustomerID;
                row.ExpenseItemID = ExpenseItemID;
                row.Period = Period;
                row.OriginalBudget = OriginalBudget;
                row.NormalBudget = NormalBudget;
                row.AdjustBudget = AdjustBudget;
                row.TransferBudget = TransferBudget;
                row.ModifyReason = ModifyReason;
                table.AddBudgetSalesFeeRow(row);
                this.TABudgetSales.Update(table);

                // �ӱ�
                BudgetDS.BudgetSalesFeeHistoryDataTable tableDetail = new BudgetDS.BudgetSalesFeeHistoryDataTable();
                BudgetDS.BudgetSalesFeeHistoryRow rowDetail = tableDetail.NewBudgetSalesFeeHistoryRow();

                rowDetail.BudgetSalesFeeID = row.BudgetSalesFeeID;
                rowDetail.UserID = UserID;
                rowDetail.PositionID = PositionID;
                rowDetail.ModifyDate = DateTime.Now;
                rowDetail.Action = "Create";
                rowDetail.CustomerID = CustomerID;
                rowDetail.ExpenseItemID = ExpenseItemID;
                rowDetail.Period = Period;
                rowDetail.OriginalBudget = OriginalBudget;
                rowDetail.NormalBudget = NormalBudget;
                rowDetail.AdjustBudget = AdjustBudget;
                rowDetail.TransferBudget = TransferBudget;
                rowDetail.ModifyReason = ModifyReason;
                tableDetail.AddBudgetSalesFeeHistoryRow(rowDetail);
                this.TABudgetSalesHistory.Update(tableDetail);

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