Esempio n. 1
0
        public void DeleteFormReimburse(int FormID)
        {
            SqlTransaction transaction = null;

            try {
                //事务开始
                transaction = TableAdapterHelper.BeginTransaction(this.TAForm);
                TableAdapterHelper.SetTransaction(this.TAFormReimburse, transaction);
                TableAdapterHelper.SetTransaction(this.TAFormReimburseDetail, transaction);
                TableAdapterHelper.SetTransaction(this.TAFormReimburseInvoice, transaction);
                TableAdapterHelper.SetTransaction(this.TAFormReimburseSKUDetail, transaction);

                this.TAFormReimburseDetail.DeleteByFormReimburseID(FormID);
                this.TAFormReimburseSKUDetail.DeleteByFormReimburseID(FormID);
                this.TAFormReimburseInvoice.DeleteByFormReimburseID(FormID);
                this.TAFormReimburse.DeleteByID(FormID);
                this.TAForm.DeleteByID(FormID);
                transaction.Commit();
            } catch (Exception ex) {
                transaction.Rollback();
                throw new ApplicationException("Save Fail!" + ex.ToString());
            } finally {
                if (transaction != null)
                {
                    transaction.Dispose();
                }
            }
        }
Esempio n. 2
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();
            }
        }
Esempio n. 3
0
        public void InsertBudgetManageFee(int OrganizationUnitID, DateTime Period, int ExpenseManageTypeID, decimal OriginalBudget, decimal NormalBudget, decimal?AdjustBudget, int UserID, int PositionID, string ModifyReason)
        {
            SqlTransaction transaction = null;

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

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

                row.OrganizationUnitID  = OrganizationUnitID;
                row.Period              = Period;
                row.ExpenseManageTypeID = ExpenseManageTypeID;
                row.OriginalBudget      = OriginalBudget;
                row.NormalBudget        = NormalBudget;
                row.AdjustBudget        = AdjustBudget.GetValueOrDefault();
                if (ModifyReason != null)
                {
                    row.ModifyReason = ModifyReason;
                }
                table.AddBudgetManageFeeRow(row);
                this.TABudgetManage.Update(table);

                // 子表
                BudgetDS.BudgetManageFeeHistoryDataTable tableDetail = new BudgetDS.BudgetManageFeeHistoryDataTable();
                BudgetDS.BudgetManageFeeHistoryRow       rowDetail   = tableDetail.NewBudgetManageFeeHistoryRow();

                rowDetail.OrganizationUnitID  = OrganizationUnitID;
                rowDetail.Period              = Period;
                rowDetail.ExpenseManageTypeID = ExpenseManageTypeID;
                rowDetail.OriginalBudget      = OriginalBudget;
                rowDetail.NormalBudget        = NormalBudget;
                rowDetail.AdjustBudget        = AdjustBudget.GetValueOrDefault();
                rowDetail.Action              = "Create";
                rowDetail.ModifyDate          = DateTime.Now;
                rowDetail.PositionID          = PositionID;
                rowDetail.UserID              = UserID;
                if (ModifyReason != null)
                {
                    rowDetail.ModifyReason = ModifyReason;
                }
                rowDetail.BudgetManageFeeID = row.BudgetManageFeeID;
                tableDetail.AddBudgetManageFeeHistoryRow(rowDetail);
                this.TABudgetManageHistory.Update(tableDetail);

                transaction.Commit();
            } catch (Exception ex) {
                transaction.Rollback();
                throw ex;
            } finally {
                transaction.Dispose();
            }
        }
Esempio n. 4
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();
            }
        }
Esempio n. 5
0
        public void UpdateBudgetManageFee(int BudgetManageFeeID, decimal NormalBudget, decimal?AdjustBudget, int UserID, int PositionID, string ModifyReason)
        {
            SqlTransaction transaction = null;

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

                // 父表
                BudgetDS.BudgetManageFeeRow row = this.TABudgetManage.GetDataByID(BudgetManageFeeID)[0];
                if (row.TotalBudget > (NormalBudget + AdjustBudget.GetValueOrDefault()))  //如果是减少预算,要做检查
                {
                    decimal[] calculateAssistant = new decimal[4];
                    calculateAssistant = this.GetPersonalBudgetByOUID(row.OrganizationUnitID, row.Period);
                    if (row.TotalBudget - NormalBudget - AdjustBudget.GetValueOrDefault() > calculateAssistant[3])
                    {
                        throw new ApplicationException("本次修改导致原有记录超预算,不能修改");
                    }
                }
                row.NormalBudget = NormalBudget;
                row.AdjustBudget = AdjustBudget.GetValueOrDefault();
                row.ModifyReason = ModifyReason;
                this.TABudgetManage.Update(row);

                // 子表
                BudgetDS.BudgetManageFeeHistoryDataTable tableDetail = new BudgetDS.BudgetManageFeeHistoryDataTable();
                BudgetDS.BudgetManageFeeHistoryRow       rowDetail   = tableDetail.NewBudgetManageFeeHistoryRow();

                rowDetail.OrganizationUnitID  = row.OrganizationUnitID;
                rowDetail.Period              = row.Period;
                rowDetail.ExpenseManageTypeID = row.ExpenseManageTypeID;
                rowDetail.OriginalBudget      = row.OriginalBudget;
                rowDetail.NormalBudget        = row.NormalBudget;
                rowDetail.AdjustBudget        = row.AdjustBudget;
                rowDetail.Action              = "Modify";
                rowDetail.ModifyDate          = DateTime.Now;
                rowDetail.PositionID          = PositionID;
                rowDetail.UserID              = UserID;
                rowDetail.ModifyReason        = ModifyReason;
                rowDetail.BudgetManageFeeID   = row.BudgetManageFeeID;
                tableDetail.AddBudgetManageFeeHistoryRow(rowDetail);
                this.TABudgetManageHistory.Update(tableDetail);

                transaction.Commit();
            } catch (Exception ex) {
                transaction.Rollback();
                throw ex;
            } finally {
                transaction.Dispose();
            }
        }
Esempio n. 6
0
        /// <summary>
        /// 删除职务
        /// </summary>
        /// <param name="positionId"></param>
        public void DeletePosition(int positionId)
        {
            SqlTransaction transaction = null;

            AuthorizationDS.PositionRow position = this.DS.Position.FindByPositionId(positionId);
            string  positionName = position.PositionName;
            DataSet backDS       = this.DS.Copy();

            try {
                //action on backDS and database first
                AuthorizationDS actionDS = new AuthorizationDS();
                actionDS.Merge(backDS);
                AuthorizationDS.PositionRow actionPosition = actionDS.Position.FindByPositionId(positionId);
                foreach (AuthorizationDS.PositionAndPositionTypeRow positionType in actionPosition.GetPositionAndPositionTypeRows())
                {
                    positionType.Delete();
                }
                actionPosition.Delete();

                PositionAndPositionTypeTableAdapter ptAd = new PositionAndPositionTypeTableAdapter();
                PositionTableAdapter psAd = new PositionTableAdapter();
                transaction = TableAdapterHelper.BeginTransaction(ptAd);
                TableAdapterHelper.SetTransaction(psAd, transaction);
                ptAd.Update(actionDS.PositionAndPositionType);
                psAd.Update(actionDS.Position);
                transaction.Commit();

                //if success, update dataset
                foreach (AuthorizationDS.PositionAndPositionTypeRow positionType in position.GetPositionAndPositionTypeRows())
                {
                    positionType.Delete();
                }
                position.Delete();
                this.DS.AcceptChanges();
            } catch (Exception ex) {
                transaction.Rollback();
                //this.DS.Clear();
                //this.DS.Merge(backupDS);
                throw new ApplicationException("职位" + positionName + "已在系统中使用");
            } finally {
                if (transaction != null)
                {
                    transaction.Dispose();
                }
            }
        }
Esempio n. 7
0
        public void ContractRecovery(int FormID)
        {
            SqlTransaction transaction = null;

            try {
                transaction = TableAdapterHelper.BeginTransaction(this.TAFormContract);
                FormDS.FormContractRow contract = this.TAFormContract.GetDataById(FormID)[0];
                contract.isRecovery = true;
                this.TAFormContract.Update(contract);
                transaction.Commit();
            } catch (Exception ex) {
                transaction.Rollback();
                throw new ApplicationException(ex.Message);
            } finally {
                transaction.Dispose();
            }
        }
Esempio n. 8
0
        public void DeleteBudgetManageFeeByID(int BudgetManageFeeID)
        {
            SqlTransaction transaction = null;

            BudgetDS.BudgetManageFeeRow provRow = TABudgetManage.GetDataByID(BudgetManageFeeID)[0];
            try {
                BudgetDS.BudgetManageFeeRow row = this.TABudgetManage.GetDataByID(BudgetManageFeeID)[0];
                decimal[] calculateAssistant    = new decimal[4];
                calculateAssistant = this.GetPersonalBudgetByOUID(row.OrganizationUnitID, row.Period);
                if (row.TotalBudget > calculateAssistant[3])
                {
                    throw new ApplicationException("本次修改导致原有记录超预算,不能删除");
                }
                transaction = TableAdapterHelper.BeginTransaction(TABudgetManage);
                TableAdapterHelper.SetTransaction(TABudgetManageHistory, transaction);
                TABudgetManageHistory.DeleteByBudgetManageFeeId(BudgetManageFeeID);
                TABudgetManage.Delete(BudgetManageFeeID);
                transaction.Commit();
            } catch (SqlException ex) {
                if (transaction != null)
                {
                    transaction.Rollback();
                }
                if (ex.Class == 16)
                {
                    throw new ApplicationException("不能删除,该管理预算已被引用");
                }
                else
                {
                    throw ex;
                }
            } finally {
                if (transaction != null)
                {
                    transaction.Dispose();
                }
            }
            this.TABudgetSales.Delete(BudgetManageFeeID);
        }
        public void SaveRealAmountForPersonalReimburse(int FormID)
        {
            SqlTransaction transaction = null;

            try {
                ////事务开始
                transaction = TableAdapterHelper.BeginTransaction(this.TAForm);
                TableAdapterHelper.SetTransaction(this.TAFormPersonalReimburse, transaction);
                TableAdapterHelper.SetTransaction(this.TAFormPersonalReimburseDetail, transaction);

                //处理申请表的内容
                FormDS.FormPersonalReimburseRow formPersonalReimburseRow = this.TAFormPersonalReimburse.GetDataByID(FormID)[0];

                this.TAFormPersonalReimburse.Update(formPersonalReimburseRow);

                //明细表
                decimal totalRealAmount = 0;//计算总申请金额
                foreach (FormDS.FormPersonalReimburseDetailRow detailRow in this.FormDataSet.FormPersonalReimburseDetail)
                {
                    // 与父表绑定
                    if (detailRow.RowState != DataRowState.Deleted)
                    {
                        totalRealAmount += detailRow.RealAmount;
                    }
                }
                this.TAFormPersonalReimburseDetail.Update(this.FormDataSet.FormPersonalReimburseDetail);

                formPersonalReimburseRow.Amount = totalRealAmount;
                this.TAFormPersonalReimburse.Update(formPersonalReimburseRow);

                transaction.Commit();
            } catch (Exception ex) {
                transaction.Rollback();
                throw new ApplicationException(ex.Message);
            } finally {
                transaction.Dispose();
            }
        }
Esempio n. 10
0
        public void DeleteBudgetSalesFeeByID(int BudgetSalesFeeId)
        {
            SqlTransaction transaction = null;

            BudgetDS.BudgetSalesFeeRow row = TABudgetSales.GetDataById(BudgetSalesFeeId)[0];
            try {
                decimal[] calculateAssistant = new decimal[14];
                calculateAssistant = this.GetSalesBudgetByParameter(row.CustomerID, row.Period, new MasterDataBLL().GetExpenseItemByID(row.ExpenseItemID).ExpenseSubCategoryID);
                if (row.TotalBudget > calculateAssistant[12])
                {
                    throw new ApplicationException("本次修改导致原有记录超预算,不能修改");
                }
                transaction = TableAdapterHelper.BeginTransaction(TABudgetSales);
                TableAdapterHelper.SetTransaction(TABudgetSalesHistory, transaction);
                TABudgetSalesHistory.DeleteByBudgetSalesFeeId(BudgetSalesFeeId);
                TABudgetSales.Delete(BudgetSalesFeeId);
                transaction.Commit();
            } catch (SqlException ex) {
                if (transaction != null)
                {
                    transaction.Rollback();
                }
                if (ex.Class == 16)
                {
                    throw new ApplicationException("不能删除,该销售预算已被引用");
                }
                else
                {
                    throw ex;
                }
            } finally {
                if (transaction != null)
                {
                    transaction.Dispose();
                }
            }
            this.TABudgetSales.Delete(BudgetSalesFeeId);
        }
Esempio n. 11
0
        public void DeleteFormBudgetAllocation(int FormID)
        {
            SqlTransaction transaction = null;

            try {
                //事务开始
                transaction = TableAdapterHelper.BeginTransaction(this.TAForm);
                TableAdapterHelper.SetTransaction(this.TAFormBudgetAllocation, transaction);
                TableAdapterHelper.SetTransaction(this.TAFormBudgetAllocationDetail, transaction);
                this.TAFormBudgetAllocationDetail.DeleteByFormID(FormID);
                this.TAFormBudgetAllocation.DeleteByID(FormID);
                this.TAForm.DeleteByID(FormID);
                transaction.Commit();
            } catch (Exception ex) {
                transaction.Rollback();
                throw ex;
            } finally {
                if (transaction != null)
                {
                    transaction.Dispose();
                }
            }
        }
        public void UpdateFormPersonalReimburse(int FormID, SystemEnums.FormStatus StatusID, SystemEnums.FormType FormTypeID, DateTime?Period, string Remark,
                                                string AttachedFileName, string RealAttachedFileName, string FlowTemplate)
        {
            SqlTransaction transaction = null;

            try {
                ////事务开始
                transaction = TableAdapterHelper.BeginTransaction(this.TAForm);
                TableAdapterHelper.SetTransaction(this.TAFormPersonalReimburse, transaction);
                TableAdapterHelper.SetTransaction(this.TAFormPersonalReimburseDetail, transaction);

                FormDS.FormRow formRow = this.TAForm.GetDataByID(FormID)[0];

                decimal[]  calculateAssistant = this.GetPersonalBudgetByParameter(formRow.PositionID, Period);
                UtilityBLL utility            = new UtilityBLL();
                if (StatusID == SystemEnums.FormStatus.Awaiting)
                {
                    string formTypeString = utility.GetFormTypeString((int)FormTypeID);
                    formRow.FormNo            = utility.GetFormNo(formTypeString);
                    formRow.InTurnUserIds     = "P"; //待改动
                    formRow.InTurnPositionIds = "P"; //待改动
                }
                else
                {
                    formRow.SetFormNoNull();
                }
                formRow.StatusID     = (int)StatusID;
                formRow.SubmitDate   = DateTime.Now;
                formRow.LastModified = DateTime.Now;
                this.TAForm.Update(formRow);

                //处理申请表的内容
                FormDS.FormPersonalReimburseRow formPersonalReimburseRow = this.TAFormPersonalReimburse.GetDataByID(FormID)[0];
                formPersonalReimburseRow.FormPersonalReimburseID = formRow.FormID;
                formPersonalReimburseRow.Period = Period.GetValueOrDefault();
                formPersonalReimburseRow.Amount = decimal.Zero;
                formPersonalReimburseRow.Remark = Remark;

                formPersonalReimburseRow.TotalBudget     = calculateAssistant[0];
                formPersonalReimburseRow.ApprovedAmount  = calculateAssistant[1];
                formPersonalReimburseRow.ApprovingAmount = calculateAssistant[2];
                formPersonalReimburseRow.RemainAmount    = calculateAssistant[3];

                if (AttachedFileName != null)
                {
                    formPersonalReimburseRow.AttachedFileName = AttachedFileName;
                }
                if (RealAttachedFileName != null)
                {
                    formPersonalReimburseRow.RealAttachedFileName = RealAttachedFileName;
                }

                this.TAFormPersonalReimburse.Update(formPersonalReimburseRow);

                //明细表
                decimal totalAmount = 0;//计算总申请金额
                foreach (FormDS.FormPersonalReimburseDetailRow detailRow in this.FormDataSet.FormPersonalReimburseDetail)
                {
                    // 与父表绑定
                    if (detailRow.RowState != DataRowState.Deleted)
                    {
                        detailRow.FormPersonalReimburseID = formPersonalReimburseRow.FormPersonalReimburseID;
                        totalAmount += detailRow.Amount;
                    }
                }
                this.TAFormPersonalReimburseDetail.Update(this.FormDataSet.FormPersonalReimburseDetail);

                formPersonalReimburseRow.Amount = totalAmount;
                this.TAFormPersonalReimburse.Update(formPersonalReimburseRow);

                // 正式提交或草稿
                Dictionary <string, object> dic = new Dictionary <string, object>();
                if (StatusID == SystemEnums.FormStatus.Awaiting)
                {
                    if (formPersonalReimburseRow.Amount > calculateAssistant[3])  //如果是减少预算,要做检查
                    {
                        throw new ApplicationException("申请报销总额超出部门可用余额,不能提交!");
                    }
                    dic["Apply_Amount"] = totalAmount;//金额
                    AuthorizationDS.OrganizationUnitDataTable OUTable = new AuthorizationDSTableAdapters.OrganizationUnitTableAdapter().GetOrganizationUnitCodeByOrganizationUnitID(formRow.OrganizationUnitID);
                    if (OUTable.Count == 0)
                    {
                        throw new ApplicationException("没有找到您所在部门的流程,请联系管理员");
                    }
                    dic["Department"] = OUTable[0].OrganizationUnitCode;
                    APHelper AP = new APHelper();
                    new APFlowBLL().ApplyForm(AP, TAForm, null, formRow, formRow.OrganizationUnitID, FlowTemplate, StatusID, dic);
                }
                transaction.Commit();
            } catch (Exception ex) {
                transaction.Rollback();
                throw new ApplicationException(ex.Message);
            } finally {
                transaction.Dispose();
            }
        }
Esempio n. 13
0
        public void AddFormContract(int?RejectedFormID, int UserID, int?ProxyUserID, int?ProxyPositionID, int OrganizationUnitID, int PositionID, SystemEnums.FormType FormTypeID,
                                    SystemEnums.FormStatus StatusID, string ContractName, int ContractTypeID, Decimal?ContractAmount, int?PageNumber, string FirstCompany, string SecondCompany, string ThirdCompany, DateTime?BeginDate, DateTime?EndDate, string PaymentType, string MainContent, string ChangePart, string AttachedFileName, string RealAttachedFileName, string FlowTemplate)
        {
            SqlTransaction transaction = null;

            try {
                transaction = TableAdapterHelper.BeginTransaction(this.TAForm);
                TableAdapterHelper.SetTransaction(this.TAFormContract, transaction);

                FormDS.FormRow formRow = this.FormDataSet.Form.NewFormRow();
                if (RejectedFormID != null)
                {
                    formRow.RejectedFormID = RejectedFormID.GetValueOrDefault();
                }
                formRow.UserID = UserID;
                UtilityBLL utility = new UtilityBLL();
                if (StatusID == SystemEnums.FormStatus.Awaiting)
                {
                    string formTypeString = utility.GetFormTypeString((int)FormTypeID);
                    formRow.FormNo = utility.GetFormNo(formTypeString);
                }
                else
                {
                    formRow.SetFormNoNull();
                }
                if (ProxyUserID != null)
                {
                    formRow.ProxyUserID = ProxyUserID.GetValueOrDefault();
                }
                if (ProxyPositionID != null)
                {
                    formRow.ProxyPositionID = ProxyPositionID.GetValueOrDefault();
                }
                formRow.OrganizationUnitID = OrganizationUnitID;
                formRow.PositionID         = PositionID;
                formRow.FormTypeID         = (int)FormTypeID;
                formRow.StatusID           = (int)StatusID;
                formRow.SubmitDate         = DateTime.Now;
                formRow.LastModified       = DateTime.Now;
                formRow.InTurnUserIds      = "P"; //待改动
                formRow.InTurnPositionIds  = "P"; //待改动
                formRow.PageType           = (int)SystemEnums.PageType.ContractApply;
                this.FormDataSet.Form.AddFormRow(formRow);
                this.TAForm.Update(formRow);

                //处理申请表的内容
                FormDS.FormContractRow formContractRow = this.FormDataSet.FormContract.NewFormContractRow();
                formContractRow.ContractName         = ContractName;
                formContractRow.FormContractID       = formRow.FormID;
                formContractRow.ContractTypeID       = ContractTypeID;
                formContractRow.ContractAmount       = ContractAmount.GetValueOrDefault();
                formContractRow.PageNumber           = PageNumber.GetValueOrDefault();
                formContractRow.FirstCompany         = FirstCompany;
                formContractRow.SecondCompany        = SecondCompany;
                formContractRow.ThirdCompany         = ThirdCompany;
                formContractRow.BeginDate            = BeginDate.GetValueOrDefault();
                formContractRow.EndDate              = EndDate.GetValueOrDefault();
                formContractRow.PaymentType          = PaymentType;
                formContractRow.MainContent          = MainContent;
                formContractRow.ChangePart           = ChangePart;
                formContractRow.AttachedFileName     = AttachedFileName;
                formContractRow.RealAttachedFileName = RealAttachedFileName;
                if (StatusID == SystemEnums.FormStatus.Awaiting)
                {
                    formContractRow.ContractNo = GetContractNo(ContractTypeID);
                }
                this.FormDataSet.FormContract.AddFormContractRow(formContractRow);
                this.TAFormContract.Update(formContractRow);

                // 正式提交或草稿

                Dictionary <string, object> dic = new Dictionary <string, object>();
                dic["Apply_Amount"] = ContractAmount;    //合同金额
                dic["ContractType"] = new MasterDataBLL().GetContractTypeById(ContractTypeID).ContractTypeName;
                APHelper AP = new APHelper();
                new APFlowBLL().ApplyForm(AP, TAForm, RejectedFormID, formRow, OrganizationUnitID, FlowTemplate, StatusID, dic);

                //this.TAFormContract.Update(formContractRow);
                transaction.Commit();
            } catch (Exception ex) {
                transaction.Rollback();
                throw new ApplicationException("Save Fail!" + ex.ToString());
            } finally {
                transaction.Dispose();
            }
        }
Esempio n. 14
0
        /// <summary>
        /// 删除组织机构,同时上次该组织机构的下属机构和职务
        /// </summary>
        /// <param name="organizationUnitId"></param>
        /// <exception cref="System.ApplicationException">如果该组织机构或者其下属机构和职务已经被使用,被关联时抛出异常</exception>
        public void DeleteOrganizationUnit(int organizationUnitId)
        {
            SqlTransaction transaction = null;

            AuthorizationDS.OrganizationUnitRow ou = this.DS.OrganizationUnit.FindByOrganizationUnitId(organizationUnitId);
            string  ouName = ou.OrganizationUnitName;
            DataSet backDS = this.DS.Copy();

            try {
                PositionTableAdapter                positionAdapter = new PositionTableAdapter();
                OrganizationUnitTableAdapter        ouAdapter       = new OrganizationUnitTableAdapter();
                PositionAndPositionTypeTableAdapter ptAd            = new PositionAndPositionTypeTableAdapter();
                transaction = TableAdapterHelper.BeginTransaction(positionAdapter);
                TableAdapterHelper.SetTransaction(ouAdapter, transaction);
                TableAdapterHelper.SetTransaction(ptAd, transaction);

                //action on backDS and database first
                AuthorizationDS actionDS = new AuthorizationDS();
                actionDS.Merge(backDS);
                AuthorizationDS.OrganizationUnitRow   actionOU  = actionDS.OrganizationUnit.FindByOrganizationUnitId(organizationUnitId);
                AuthorizationDS.OrganizationUnitRow[] actionOUs = this.GetDepFirstChildren(actionOU);
                foreach (AuthorizationDS.OrganizationUnitRow o in actionOUs)
                {
                    foreach (AuthorizationDS.PositionRow position in o.GetPositionRows())
                    {
                        foreach (AuthorizationDS.PositionAndPositionTypeRow positionType in position.GetPositionAndPositionTypeRows())
                        {
                            positionType.Delete();
                        }
                        position.Delete();
                    }
                    o.Delete();
                    ptAd.Update(actionDS.PositionAndPositionType);
                    positionAdapter.Update(actionDS.Position);
                    ouAdapter.Update(actionDS.OrganizationUnit);
                }
                transaction.Commit();

                //if success update dataset

                AuthorizationDS.OrganizationUnitRow[] ous = this.GetDepFirstChildren(ou);
                foreach (AuthorizationDS.OrganizationUnitRow o in ous)
                {
                    foreach (AuthorizationDS.PositionRow position in o.GetPositionRows())
                    {
                        foreach (AuthorizationDS.PositionAndPositionTypeRow positionType in position.GetPositionAndPositionTypeRows())
                        {
                            positionType.Delete();
                        }
                        position.Delete();
                    }
                    o.Delete();
                    //ptAd.Update(this.DS.PositionAndPositionType);
                    //positionAdapter.Update(this.DS.Position);
                    //ouAdapter.Update(this.DS.OrganizationUnit);
                    this.DS.AcceptChanges();
                }
            } catch (Exception ex) {
                transaction.Rollback();
                //this.DS.Clear();
                //this.DS.Merge(backDS);
                throw new ApplicationException("组织机构" + ouName + "或者分支机构,职位已被使用");
            } finally {
                transaction.Dispose();
            }
        }
Esempio n. 15
0
        public void UpdateFormBudgetAllocation(int FormID, SystemEnums.FormStatus StatusID, SystemEnums.FormType FormTypeID, string Remark, string AttachFileName, string RealAttachFileName, string FlowTemplate)
        {
            SqlTransaction transaction = null;

            try {
                ////事务开始
                transaction = TableAdapterHelper.BeginTransaction(this.TAForm);
                TableAdapterHelper.SetTransaction(this.TAFormBudgetAllocation, transaction);
                TableAdapterHelper.SetTransaction(this.TAFormBudgetAllocationDetail, transaction);

                FormDS.FormRow formRow = this.TAForm.GetDataByID(FormID)[0];
                UtilityBLL     utility = new UtilityBLL();
                if (StatusID == SystemEnums.FormStatus.Awaiting)
                {
                    string formTypeString = utility.GetFormTypeString((int)FormTypeID);
                    formRow.FormNo            = utility.GetFormNo(formTypeString);
                    formRow.InTurnUserIds     = "P"; //待改动
                    formRow.InTurnPositionIds = "P"; //待改动
                }
                else
                {
                    formRow.SetFormNoNull();
                }
                formRow.StatusID     = (int)StatusID;
                formRow.SubmitDate   = DateTime.Now;
                formRow.LastModified = DateTime.Now;
                this.TAForm.Update(formRow);

                //处理申请表的内容
                FormDS.FormBudgetAllocationRow formBudgetAllocationRow = this.TAFormBudgetAllocation.GetDataByID(FormID)[0];
                formBudgetAllocationRow.Amount             = decimal.Zero;
                formBudgetAllocationRow.AttachFileName     = AttachFileName;
                formBudgetAllocationRow.RealAttachFileName = RealAttachFileName;
                formBudgetAllocationRow.Remark             = Remark;
                this.TAFormBudgetAllocation.Update(formBudgetAllocationRow);

                //明细表
                decimal totalAmount    = 0; //计算总申请金额
                decimal totalInAmount  = 0; //计算调入总金额
                decimal totalOutAmount = 0; //计算调出总金额

                foreach (FormDS.FormBudgetAllocationDetailRow detailRow in this.FormDataSet.FormBudgetAllocationDetail)
                {
                    // 与父表绑定
                    if (detailRow.RowState != DataRowState.Deleted)
                    {
                        detailRow.FormBudgetAllocationID = formBudgetAllocationRow.FormBudgetAllocationID;
                        if (detailRow.AllocationType == (int)SystemEnums.AllocationType.In)
                        {
                            totalInAmount += detailRow.TransferBudget;
                        }
                        else
                        {
                            totalOutAmount += detailRow.TransferBudget;
                        }
                        totalAmount += detailRow.TransferBudget;
                    }
                }

                this.TAFormBudgetAllocationDetail.Update(this.FormDataSet.FormBudgetAllocationDetail);

                formBudgetAllocationRow.Amount = totalOutAmount;
                this.TAFormBudgetAllocation.Update(formBudgetAllocationRow);

                // 正式提交或草稿

                Dictionary <string, object> dic = new Dictionary <string, object>();
                dic["Apply_Amount"] = totalOutAmount;    //调拨金额

                APHelper AP = new APHelper();
                new APFlowBLL().ApplyForm(AP, TAForm, null, formRow, formRow.OrganizationUnitID, FlowTemplate, StatusID, dic);


                transaction.Commit();
            } catch (Exception ex) {
                transaction.Rollback();
                throw new ApplicationException(ex.Message);
            } finally {
                transaction.Dispose();
            }
        }
Esempio n. 16
0
        public void AddFormBudgetAllocation(int?RejectedFormID, int UserID, int?ProxyUserID, int?ProxyPositionID, int OrganizationUnitID, int PositionID, SystemEnums.FormType FormTypeID,
                                            SystemEnums.FormStatus StatusID, string Remark, string AttachFileName, string RealAttachFileName, string FlowTemplate)
        {
            SqlTransaction transaction = null;

            try {
                transaction = TableAdapterHelper.BeginTransaction(this.TAForm);
                TableAdapterHelper.SetTransaction(this.TAFormBudgetAllocation, transaction);
                TableAdapterHelper.SetTransaction(this.TAFormBudgetAllocationDetail, transaction);

                FormDS.FormRow formRow = this.FormDataSet.Form.NewFormRow();
                if (RejectedFormID != null)
                {
                    formRow.RejectedFormID = RejectedFormID.GetValueOrDefault();
                }
                formRow.UserID = UserID;
                UtilityBLL utility = new UtilityBLL();
                if (StatusID == SystemEnums.FormStatus.Awaiting)
                {
                    string formTypeString = utility.GetFormTypeString((int)FormTypeID);
                    formRow.FormNo = utility.GetFormNo(formTypeString);
                }
                else
                {
                    formRow.SetFormNoNull();
                }
                if (ProxyUserID != null)
                {
                    formRow.ProxyUserID = ProxyUserID.GetValueOrDefault();
                }
                if (ProxyPositionID != null)
                {
                    formRow.ProxyPositionID = ProxyPositionID.GetValueOrDefault();
                }
                formRow.OrganizationUnitID = OrganizationUnitID;
                formRow.PositionID         = PositionID;
                formRow.FormTypeID         = (int)FormTypeID;
                formRow.StatusID           = (int)StatusID;
                formRow.SubmitDate         = DateTime.Now;
                formRow.LastModified       = DateTime.Now;
                formRow.InTurnUserIds      = "P"; //待改动
                formRow.InTurnPositionIds  = "P"; //待改动
                formRow.PageType           = (int)SystemEnums.PageType.BudgetAllocationApply;
                this.FormDataSet.Form.AddFormRow(formRow);
                this.TAForm.Update(formRow);

                //处理申请表的内容
                FormDS.FormBudgetAllocationRow formBudgetAllocationRow = this.FormDataSet.FormBudgetAllocation.NewFormBudgetAllocationRow();
                formBudgetAllocationRow.FormBudgetAllocationID = formRow.FormID;
                formBudgetAllocationRow.Amount             = decimal.Zero;
                formBudgetAllocationRow.AttachFileName     = AttachFileName;
                formBudgetAllocationRow.RealAttachFileName = RealAttachFileName;
                formBudgetAllocationRow.Remark             = Remark;


                this.FormDataSet.FormBudgetAllocation.AddFormBudgetAllocationRow(formBudgetAllocationRow);
                this.TAFormBudgetAllocation.Update(formBudgetAllocationRow);

                //明细表
                decimal totalAmount    = 0; //计算总申请金额
                decimal totalInAmount  = 0; //计算调入总金额
                decimal totalOutAmount = 0; //计算调出总金额

                if (RejectedFormID != null)
                {
                    FormDS.FormBudgetAllocationDetailDataTable newDetailTable = new FormDS.FormBudgetAllocationDetailDataTable();
                    foreach (FormDS.FormBudgetAllocationDetailRow detailRow in this.FormDataSet.FormBudgetAllocationDetail)
                    {
                        if (detailRow.RowState != System.Data.DataRowState.Deleted)
                        {
                            FormDS.FormBudgetAllocationDetailRow newDetailRow = newDetailTable.NewFormBudgetAllocationDetailRow();
                            newDetailRow.FormBudgetAllocationID = formBudgetAllocationRow.FormBudgetAllocationID;
                            newDetailRow.CustomerID             = detailRow.CustomerID;
                            newDetailRow.CustomerName           = detailRow.CustomerName;
                            newDetailRow.ExpenseItemID          = detailRow.ExpenseItemID;
                            newDetailRow.ExpenseItemName        = detailRow.ExpenseItemName;
                            newDetailRow.Period           = detailRow.Period;
                            newDetailRow.OriginalBudget   = detailRow.OriginalBudget;
                            newDetailRow.NormalBudget     = detailRow.NormalBudget;
                            newDetailRow.AdjustBudget     = detailRow.AdjustBudget;
                            newDetailRow.TotalBudget      = detailRow.TotalBudget;
                            newDetailRow.TransferBudget   = detailRow.TransferBudget;
                            newDetailRow.AllocationType   = detailRow.AllocationType;
                            newDetailRow.BudgetSalesFeeId = detailRow.BudgetSalesFeeId;
                            totalAmount += newDetailRow.TransferBudget;
                            if (detailRow.AllocationType == (int)SystemEnums.AllocationType.In)
                            {
                                totalInAmount += detailRow.TransferBudget;
                            }
                            else
                            {
                                totalOutAmount += detailRow.TransferBudget;
                            }
                            newDetailTable.AddFormBudgetAllocationDetailRow(newDetailRow);
                        }
                    }
                    this.TAFormBudgetAllocationDetail.Update(newDetailTable);
                }
                else
                {
                    foreach (FormDS.FormBudgetAllocationDetailRow detailRow in this.FormDataSet.FormBudgetAllocationDetail)
                    {
                        // 与父表绑定
                        if (detailRow.RowState != DataRowState.Deleted)
                        {
                            detailRow.FormBudgetAllocationID = formBudgetAllocationRow.FormBudgetAllocationID;
                            if (detailRow.AllocationType == (int)SystemEnums.AllocationType.In)
                            {
                                totalInAmount += detailRow.TransferBudget;
                            }
                            else
                            {
                                totalOutAmount += detailRow.TransferBudget;
                            }
                            totalAmount += detailRow.TransferBudget;
                        }
                    }
                    this.TAFormBudgetAllocationDetail.Update(this.FormDataSet.FormBudgetAllocationDetail);
                }

                formBudgetAllocationRow.Amount = totalOutAmount;
                this.TAFormBudgetAllocation.Update(formBudgetAllocationRow);
                // 正式提交或草稿

                Dictionary <string, object> dic = new Dictionary <string, object>();
                dic["Apply_Amount"] = totalOutAmount;    //调拨金额

                APHelper AP = new APHelper();
                new APFlowBLL().ApplyForm(AP, TAForm, RejectedFormID, formRow, OrganizationUnitID, FlowTemplate, StatusID, dic);

                transaction.Commit();
            } catch (Exception ex) {
                transaction.Rollback();
                throw new ApplicationException(ex.Message);
            } finally {
                transaction.Dispose();
            }
        }
Esempio n. 17
0
        public void AddFormMaterial(int?RejectedFormID, int UserID, int?ProxyUserID, int?ProxyPositionID, int OrganizationUnitID, int PositionID, SystemEnums.FormType FormTypeID,
                                    SystemEnums.FormStatus StatusID, int ShopID, int FirstVolume, int SecondVolume, int ThirdVolume, string Remark, string FlowTemplate)
        {
            SqlTransaction transaction = null;

            try {
                transaction = TableAdapterHelper.BeginTransaction(this.TAForm);
                TableAdapterHelper.SetTransaction(this.TAFormMaterial, transaction);
                TableAdapterHelper.SetTransaction(this.TAFormMaterialDetail, transaction);

                FormDS.FormRow formRow = this.FormDataSet.Form.NewFormRow();
                if (RejectedFormID != null)
                {
                    formRow.RejectedFormID = RejectedFormID.GetValueOrDefault();
                }
                formRow.UserID = UserID;
                UtilityBLL utility = new UtilityBLL();
                if (StatusID == SystemEnums.FormStatus.Awaiting)
                {
                    string formTypeString = utility.GetFormTypeString((int)FormTypeID);
                    formRow.FormNo = utility.GetFormNo(formTypeString);
                }
                else
                {
                    formRow.SetFormNoNull();
                }
                if (ProxyUserID != null)
                {
                    formRow.ProxyUserID = ProxyUserID.GetValueOrDefault();
                }
                if (ProxyPositionID != null)
                {
                    formRow.ProxyPositionID = ProxyPositionID.GetValueOrDefault();
                }
                formRow.OrganizationUnitID = OrganizationUnitID;
                formRow.PositionID         = PositionID;
                formRow.FormTypeID         = (int)FormTypeID;
                formRow.StatusID           = (int)StatusID;
                formRow.SubmitDate         = DateTime.Now;
                formRow.LastModified       = DateTime.Now;
                formRow.InTurnUserIds      = "P"; //待改动
                formRow.InTurnPositionIds  = "P"; //待改动
                formRow.PageType           = (int)SystemEnums.PageType.MaterialApply;
                this.FormDataSet.Form.AddFormRow(formRow);
                this.TAForm.Update(formRow);

                //处理申请表的内容
                FormDS.FormMaterialRow formMaterialRow = this.FormDataSet.FormMaterial.NewFormMaterialRow();
                formMaterialRow.FormMaterialID = formRow.FormID;
                formMaterialRow.ShopID         = ShopID;
                formMaterialRow.FirstVolume    = FirstVolume;
                formMaterialRow.SecondVolume   = SecondVolume;
                formMaterialRow.ThirdVolume    = ThirdVolume;
                formMaterialRow.Amount         = 0;//默认值
                formMaterialRow.Remark         = Remark;

                this.FormDataSet.FormMaterial.AddFormMaterialRow(formMaterialRow);
                this.TAFormMaterial.Update(formMaterialRow);

                //明细表
                decimal totalAmount = 0;//计算总申请金额

                if (RejectedFormID != null)
                {
                    FormDS.FormMaterialDetailDataTable newDetailTable = new FormDS.FormMaterialDetailDataTable();
                    foreach (FormDS.FormMaterialDetailRow detailRow in this.FormDataSet.FormMaterialDetail)
                    {
                        if (detailRow.RowState != System.Data.DataRowState.Deleted)
                        {
                            FormDS.FormMaterialDetailRow newDetailRow = newDetailTable.NewFormMaterialDetailRow();
                            newDetailRow.FormMaterialID = formMaterialRow.FormMaterialID;
                            newDetailRow.MaterialID     = detailRow.MaterialID;
                            ERS.MaterialRow material = new MasterDataBLL().GetMaterialById(detailRow.MaterialID);
                            newDetailRow.MaterialName  = material.MaterialName;
                            newDetailRow.UOM           = material.UOM;
                            newDetailRow.Description   = material.Description;
                            newDetailRow.MaterialPrice = material.MaterialPrice;
                            newDetailRow.Quantity      = detailRow.Quantity;
                            newDetailRow.Amount        = newDetailRow.MaterialPrice * detailRow.Quantity;
                            if (!detailRow.IsRemarkNull())
                            {
                                newDetailRow.Remark = detailRow.Remark;
                            }
                            totalAmount += newDetailRow.Amount;
                            newDetailTable.AddFormMaterialDetailRow(newDetailRow);
                        }
                    }
                    this.TAFormMaterialDetail.Update(newDetailTable);
                }
                else
                {
                    foreach (FormDS.FormMaterialDetailRow detailRow in this.FormDataSet.FormMaterialDetail)
                    {
                        // 与父表绑定
                        if (detailRow.RowState != DataRowState.Deleted)
                        {
                            detailRow.FormMaterialID = formMaterialRow.FormMaterialID;
                            totalAmount += detailRow.Amount;
                        }
                    }
                    this.TAFormMaterialDetail.Update(this.FormDataSet.FormMaterialDetail);
                }

                formMaterialRow.Amount = totalAmount;
                this.TAFormMaterial.Update(formMaterialRow);

                // 正式提交或草稿

                Dictionary <string, object> dic = new Dictionary <string, object>();
                dic["Apply_Amount"] = totalAmount;    //金额
                APHelper AP = new APHelper();
                new APFlowBLL().ApplyForm(AP, TAForm, RejectedFormID, formRow, OrganizationUnitID, FlowTemplate, StatusID, dic);

                transaction.Commit();
            } catch (Exception ex) {
                transaction.Rollback();
                throw new ApplicationException("Save Fail!" + ex.ToString());
            } finally {
                transaction.Dispose();
            }
        }
Esempio n. 18
0
        public void UpdateFormMaterial(int FormID, SystemEnums.FormStatus StatusID, SystemEnums.FormType FormTypeID, int ShopID, int FirstVolume, int SecondVolume, int ThirdVolume, string Remark, string FlowTemplate)
        {
            SqlTransaction transaction = null;

            try {
                ////事务开始
                transaction = TableAdapterHelper.BeginTransaction(this.TAForm);
                TableAdapterHelper.SetTransaction(this.TAFormMaterial, transaction);
                TableAdapterHelper.SetTransaction(this.TAFormMaterialDetail, transaction);

                FormDS.FormRow formRow = this.TAForm.GetDataByID(FormID)[0];
                UtilityBLL     utility = new UtilityBLL();
                if (StatusID == SystemEnums.FormStatus.Awaiting)
                {
                    string formTypeString = utility.GetFormTypeString((int)FormTypeID);
                    formRow.FormNo            = utility.GetFormNo(formTypeString);
                    formRow.InTurnUserIds     = "P"; //待改动
                    formRow.InTurnPositionIds = "P"; //待改动
                }
                else
                {
                    formRow.SetFormNoNull();
                }
                formRow.StatusID     = (int)StatusID;
                formRow.SubmitDate   = DateTime.Now;
                formRow.LastModified = DateTime.Now;
                this.TAForm.Update(formRow);

                //处理申请表的内容
                FormDS.FormMaterialRow formMaterialRow = this.TAFormMaterial.GetDataByID(FormID)[0];
                formMaterialRow.ShopID       = ShopID;
                formMaterialRow.FirstVolume  = FirstVolume;
                formMaterialRow.SecondVolume = SecondVolume;
                formMaterialRow.ThirdVolume  = ThirdVolume;
                formMaterialRow.Remark       = Remark;
                this.TAFormMaterial.Update(formMaterialRow);

                //明细表
                decimal totalAmount = 0;//计算总申请金额
                foreach (FormDS.FormMaterialDetailRow detailRow in this.FormDataSet.FormMaterialDetail)
                {
                    // 与父表绑定
                    if (detailRow.RowState != DataRowState.Deleted)
                    {
                        detailRow.FormMaterialID = formMaterialRow.FormMaterialID;
                        totalAmount += detailRow.Amount;
                    }
                }
                this.TAFormMaterialDetail.Update(this.FormDataSet.FormMaterialDetail);

                formMaterialRow.Amount = totalAmount;
                this.TAFormMaterial.Update(formMaterialRow);
                // 正式提交或草稿
                if (StatusID == SystemEnums.FormStatus.Awaiting)
                {
                    Dictionary <string, object> dic = new Dictionary <string, object>();
                    dic["Apply_Amount"] = totalAmount;//金额
                    APHelper AP = new APHelper();
                    new APFlowBLL().ApplyForm(AP, TAForm, null, formRow, formRow.OrganizationUnitID, FlowTemplate, StatusID, dic);
                }
                transaction.Commit();
            } catch (Exception ex) {
                transaction.Rollback();
                throw new ApplicationException("Save Fail!" + ex.ToString());
            } finally {
                transaction.Dispose();
            }
        }
Esempio n. 19
0
        public void UpdateFormReimburseGoods(int FormID, SystemEnums.FormStatus StatusID, SystemEnums.FormType FormTypeID,
                                             string AttachedFileName, string RealAttachedFileName, string Remark, string FlowTemplate)
        {
            SqlTransaction transaction = null;

            try {
                //事务开始
                transaction = TableAdapterHelper.BeginTransaction(this.TAForm);
                TableAdapterHelper.SetTransaction(this.TAFormReimburse, transaction);
                TableAdapterHelper.SetTransaction(this.TAFormReimburseDetail, transaction);
                TableAdapterHelper.SetTransaction(this.TAFormReimburseSKUDetail, transaction);

                FormDS.FormRow          formRow          = this.TAForm.GetDataByID(FormID)[0];
                FormDS.FormReimburseRow FormReimburseRow = this.TAFormReimburse.GetDataByID(FormID)[0];

                //处理单据的内容
                UtilityBLL utility = new UtilityBLL();
                if (StatusID == SystemEnums.FormStatus.Awaiting)
                {
                    string formTypeString = utility.GetFormTypeString((int)FormTypeID);
                    formRow.FormNo = utility.GetFormNo(formTypeString);
                }
                else
                {
                    formRow.SetFormNoNull();
                }
                formRow.StatusID     = (int)StatusID;
                formRow.SubmitDate   = DateTime.Now;
                formRow.LastModified = DateTime.Now;

                this.TAForm.Update(formRow);

                //处理FormReimburseRow的内容
                if (AttachedFileName != null && AttachedFileName != string.Empty)
                {
                    FormReimburseRow.AttachedFileName = AttachedFileName;
                }
                else
                {
                    FormReimburseRow.SetAttachedFileNameNull();
                }
                if (RealAttachedFileName != null && RealAttachedFileName != string.Empty)
                {
                    FormReimburseRow.RealAttachedFileName = RealAttachedFileName;
                }
                else
                {
                    FormReimburseRow.SetRealAttachedFileNameNull();
                }
                if (Remark != null && Remark != string.Empty)
                {
                    FormReimburseRow.Remark = Remark;
                }

                this.TAFormReimburse.Update(FormReimburseRow);

                //处理free goods明细
                foreach (FormDS.FormReimburseSKUDetailRow detailFGRow in this.FormDataSet.FormReimburseSKUDetail)
                {
                    // 与父表绑定
                    if (detailFGRow.RowState != DataRowState.Deleted)
                    {
                        detailFGRow.FormReimburseID = FormReimburseRow.FormReimburseID;
                    }
                }
                this.TAFormReimburseSKUDetail.Update(this.FormDataSet.FormReimburseSKUDetail);

                //处理明细
                decimal totalAmount = 0;
                foreach (FormDS.FormReimburseDetailRow detailRow in this.FormDataSet.FormReimburseDetail)
                {
                    if (detailRow.RowState != DataRowState.Deleted)
                    {
                        totalAmount += detailRow.Amount;
                        detailRow.FormReimburseID = FormReimburseRow.FormReimburseID;
                    }
                }
                this.TAFormReimburseDetail.Update(this.FormDataSet.FormReimburseDetail);

                FormReimburseRow.Amount = totalAmount;
                this.TAFormReimburse.Update(FormReimburseRow);

                // 正式提交
                if (StatusID == SystemEnums.FormStatus.Awaiting)
                {
                    Dictionary <string, object> dic = new Dictionary <string, object>();
                    dic["Apply_Amount"] = totalAmount;
                    //dic["Dept"] = new AuthorizationDSTableAdapters.OrganizationUnitTableAdapter().GetOrganizationUnitCodeByOrganizationUnitID(formRow.OrganizationUnitID)[0].OrganizationUnitCode;
                    dic["Expense_Category"] = getExpenseCategoryIDByFormID(int.Parse(FormReimburseRow.FormApplyIds.Split(',')[0])).ToString();//此处待改动
                    APHelper AP = new APHelper();
                    new APFlowBLL().ApplyForm(AP, TAForm, null, formRow, formRow.OrganizationUnitID, FlowTemplate, StatusID, dic);
                }
                transaction.Commit();
            } catch (Exception ex) {
                transaction.Rollback();
                throw new ApplicationException("Save Fail!" + ex.ToString());
            } finally {
                transaction.Dispose();
            }
        }
Esempio n. 20
0
        //审批方法
        public void ApproveForm(APHelper AP, int formID, int stuffUserId, string stuffName, bool pass, string comment, string ProxyStuffName, int OrganizationUnitID)
        {
            string         email       = string.Empty;
            SqlTransaction transaction = null;

            try {
                FormTableAdapter TAMainForm = new FormTableAdapter();

                transaction = TableAdapterHelper.BeginTransaction(TAMainForm);

                FormDS.FormRow formRow = TAMainForm.GetDataByID(formID)[0];

                string   returnValue = AP.approve(pass, comment, stuffUserId.ToString(), stuffName, formRow.ProcID, ProxyStuffName, formRow.OrganizationUnitID, ref email);
                string[] approveinfo = AP.GetProcessApproveUser(formRow.ProcID);
                if (AP.GetProcessIsEnd(formRow.ProcID))
                {
                    formRow.LastApprover = stuffUserId.ToString();
                    formRow.Comment      = comment;
                    formRow.ApprovedDate = Convert.ToDateTime(approveinfo[0]);
                }
                formRow.ApproverIds = approveinfo[3];
                if (returnValue == null)
                {
                    formRow.InTurnUserIds     = "P";
                    formRow.InTurnPositionIds = "P";
                    //formRow.SubmitDate = DateTime.Now;

                    if (pass)
                    {
                        //如果审批通过且返回值为空则该流程结束

                        formRow.StatusID = (int)SystemEnums.FormStatus.ApproveCompleted;
                        //mailTitle = string.Format("您申请的编号为{0}的单据已经通过审批", formRow.FormNo);
                        //mailBody = string.Format(mailBody, formRow.FormNo);
                        //email = AP.getUserEmailByID(formRow.UserID);

                        //AP.sendMail(email, "", mailTitle, mailBody);
                    }
                    else
                    {
                        //如果不通过则为驳回
                        formRow.StatusID = (int)SystemEnums.FormStatus.Rejected;

                        //mailTitle = string.Format("您有单据申请被{0}退回", stuffName);
                        //mailBody = string.Format(mailBody, formRow.FormNo);
                        //email = AP.getUserEmailByID(formRow.UserID);

                        //AP.sendMail(email, "", mailTitle, mailBody);
                    }
                }
                else
                {
                    string[] InTurn = returnValue.Split('&');//不同流程角色下的人员和职位
                    string   ids    = "";
                    string   pids   = "";
                    for (int a = 0; a < InTurn.Length; a++)
                    {
                        ids  += InTurn[a].Split('$')[0].ToString(); ///人员
                        pids += InTurn[a].Split('$')[1].ToString(); //职位
                    }
                    formRow.InTurnUserIds     = ids;                //下一步的人员
                    formRow.InTurnPositionIds = pids;               //下一步的人员职位

                    //mailTitle = string.Format(mailTitle, stuffName, formRow.FormNo);
                    //mailBody = string.Format(mailBody, formRow.FormNo);
                    //AP.sendMail(email, "", mailTitle,mailBody);
                }

                TAMainForm.Update(formRow);

                transaction.Commit();
            } catch (Exception ex) {
                if (transaction != null)
                {
                    transaction.Rollback();
                }
                throw ex;
            } finally {
                if (transaction != null)
                {
                    transaction.Dispose();
                }
            }
            //System.Threading.Thread.Sleep(3000);
        }
Esempio n. 21
0
        public void AddFormReimburseGoods(int?RejectedFormID, int UserID, int?ProxyUserID, int?ProxyPositionID, int OrganizationUnitID, int PositionID, SystemEnums.FormType FormTypeID,
                                          SystemEnums.FormStatus StatusID, int CustomerID, int PaymentTypeID, string AttachedFileName, string RealAttachedFileName, string Remark, string FormApplyIds, string FormApplyNos, string FlowTemplate)
        {
            SqlTransaction transaction = null;

            try {
                transaction = TableAdapterHelper.BeginTransaction(this.TAForm);
                TableAdapterHelper.SetTransaction(this.TAFormReimburse, transaction);
                TableAdapterHelper.SetTransaction(this.TAFormReimburseDetail, transaction);
                TableAdapterHelper.SetTransaction(this.TAFormReimburseSKUDetail, transaction);

                FormDS.FormRow formRow = this.FormDataSet.Form.NewFormRow();
                if (RejectedFormID != null)
                {
                    formRow.RejectedFormID = RejectedFormID.GetValueOrDefault();
                }
                formRow.UserID = UserID;
                UtilityBLL utility = new UtilityBLL();
                if (StatusID == SystemEnums.FormStatus.Awaiting)
                {
                    string formTypeString = utility.GetFormTypeString((int)FormTypeID);
                    formRow.FormNo = utility.GetFormNo(formTypeString);
                }
                else
                {
                    formRow.SetFormNoNull();
                }
                if (ProxyUserID != null)
                {
                    formRow.ProxyUserID = ProxyUserID.GetValueOrDefault();
                }
                if (ProxyPositionID != null)
                {
                    formRow.ProxyPositionID = ProxyPositionID.GetValueOrDefault();
                }
                formRow.OrganizationUnitID = OrganizationUnitID;
                formRow.PositionID         = PositionID;
                formRow.FormTypeID         = (int)FormTypeID;
                formRow.StatusID           = (int)StatusID;
                formRow.SubmitDate         = DateTime.Now;
                formRow.LastModified       = DateTime.Now;
                formRow.InTurnUserIds      = "P"; //待改动
                formRow.InTurnPositionIds  = "P"; //待改动
                formRow.PageType           = (int)SystemEnums.PageType.ReimburseGoodsApply;
                this.FormDataSet.Form.AddFormRow(formRow);
                this.TAForm.Update(formRow);

                //处理申请表的内容
                FormDS.FormReimburseRow FormReimburseRow = this.FormDataSet.FormReimburse.NewFormReimburseRow();
                FormReimburseRow.FormReimburseID = formRow.FormID;
                FormReimburseRow.CustomerID      = CustomerID;
                FormReimburseRow.PaymentTypeID   = PaymentTypeID;
                FormReimburseRow.Amount          = 0;//默认值
                if (AttachedFileName != null && AttachedFileName != string.Empty)
                {
                    FormReimburseRow.AttachedFileName = AttachedFileName;
                }
                if (RealAttachedFileName != null && RealAttachedFileName != string.Empty)
                {
                    FormReimburseRow.RealAttachedFileName = RealAttachedFileName;
                }
                if (Remark != null && Remark != string.Empty)
                {
                    FormReimburseRow.Remark = Remark;
                }
                FormReimburseRow.FormApplyIds       = FormApplyIds;
                FormReimburseRow.FormApplyNos       = FormApplyNos;
                FormReimburseRow.IsDeliveryComplete = false;

                this.FormDataSet.FormReimburse.AddFormReimburseRow(FormReimburseRow);
                this.TAFormReimburse.Update(FormReimburseRow);


                //处理free goods明细
                if (RejectedFormID != null)
                {
                    FormDS.FormReimburseSKUDetailDataTable newFGTable = new FormDS.FormReimburseSKUDetailDataTable();
                    foreach (FormDS.FormReimburseSKUDetailRow detailFGRow in this.FormDataSet.FormReimburseSKUDetail)
                    {
                        // 与父表绑定
                        if (detailFGRow.RowState != DataRowState.Deleted)
                        {
                            FormDS.FormReimburseSKUDetailRow newDetailFGRow = newFGTable.NewFormReimburseSKUDetailRow();
                            newDetailFGRow.FormReimburseID = FormReimburseRow.FormReimburseID;
                            newDetailFGRow.SKUID           = detailFGRow.SKUID;
                            newDetailFGRow.PackageQuantity = detailFGRow.PackageQuantity;
                            newDetailFGRow.UnitPrice       = detailFGRow.UnitPrice;
                            newDetailFGRow.Quantity        = detailFGRow.Quantity;
                            newDetailFGRow.Amount          = detailFGRow.Amount;

                            if (!detailFGRow.IsRemarkNull())
                            {
                                newDetailFGRow.Remark = detailFGRow.Remark;
                            }
                            newFGTable.AddFormReimburseSKUDetailRow(newDetailFGRow);
                        }
                    }
                    this.TAFormReimburseSKUDetail.Update(newFGTable);
                }
                else
                {
                    foreach (FormDS.FormReimburseSKUDetailRow detailFGRow in this.FormDataSet.FormReimburseSKUDetail)
                    {
                        // 与父表绑定
                        if (detailFGRow.RowState != DataRowState.Deleted)
                        {
                            detailFGRow.FormReimburseID = FormReimburseRow.FormReimburseID;
                        }
                    }
                    this.TAFormReimburseSKUDetail.Update(this.FormDataSet.FormReimburseSKUDetail);
                }

                //明细表
                decimal totalAmount = 0;//计算总申请金额
                FormDS.FormReimburseDetailDataTable newDetailTable = new FormDS.FormReimburseDetailDataTable();
                foreach (FormDS.FormReimburseDetailRow detailRow in this.FormDataSet.FormReimburseDetail)
                {
                    // 与父表绑定
                    if (detailRow.RowState != DataRowState.Deleted)
                    {
                        totalAmount += detailRow.Amount;

                        FormDS.FormReimburseDetailRow newDetailRow = newDetailTable.NewFormReimburseDetailRow();
                        newDetailRow.FormReimburseID          = FormReimburseRow.FormReimburseID;
                        newDetailRow.FormApplyExpenseDetailID = detailRow.FormApplyExpenseDetailID;
                        newDetailRow.ApplyFormNo        = detailRow.ApplyFormNo;
                        newDetailRow.ApplyPeriod        = detailRow.ApplyPeriod;
                        newDetailRow.ShopID             = detailRow.ShopID;
                        newDetailRow.SKUID              = detailRow.SKUID;
                        newDetailRow.ExpenseItemID      = detailRow.ExpenseItemID;
                        newDetailRow.ApplyAmount        = detailRow.ApplyAmount;
                        newDetailRow.RemainAmount       = detailRow.RemainAmount;
                        newDetailRow.Amount             = detailRow.Amount;
                        newDetailRow.ApplyPaymentTypeID = detailRow.ApplyPaymentTypeID;
                        newDetailRow.FormApplyID        = detailRow.FormApplyID;
                        newDetailRow.AccruedAmount      = detailRow.IsAccruedAmountNull() ? 0 : detailRow.AccruedAmount;
                        newDetailTable.AddFormReimburseDetailRow(newDetailRow);
                    }
                }
                this.TAFormReimburseDetail.Update(newDetailTable);
                FormReimburseRow.Amount = totalAmount;
                this.TAFormReimburse.Update(FormReimburseRow);

                //作废之前的单据
                if (RejectedFormID != null)
                {
                    FormDS.FormRow oldRow = this.TAForm.GetDataByID(RejectedFormID.GetValueOrDefault())[0];
                    if (oldRow.StatusID == (int)SystemEnums.FormStatus.Rejected)
                    {
                        oldRow.StatusID = (int)SystemEnums.FormStatus.Scrap;
                        this.TAForm.Update(oldRow);
                    }
                }

                // 正式提交或草稿
                if (StatusID == SystemEnums.FormStatus.Awaiting)
                {
                    Dictionary <string, object> dic = new Dictionary <string, object>();
                    dic["Apply_Amount"] = totalAmount;
                    //dic["Dept"] = new AuthorizationDSTableAdapters.OrganizationUnitTableAdapter().GetOrganizationUnitCodeByOrganizationUnitID(formRow.OrganizationUnitID)[0].OrganizationUnitCode;
                    dic["Expense_Category"] = getExpenseCategoryIDByFormID(int.Parse(FormApplyIds.Split(',')[0])).ToString();//此处待改动
                    APHelper AP = new APHelper();
                    new APFlowBLL().ApplyForm(AP, TAForm, RejectedFormID, formRow, OrganizationUnitID, FlowTemplate, StatusID, dic);
                }

                transaction.Commit();
            } catch (Exception ex) {
                transaction.Rollback();
                throw new ApplicationException("Save Fail!" + ex.ToString());
            } finally {
                transaction.Dispose();
            }
        }