Exemple #1
0
    protected void SaveFormReimburse(SystemEnums.FormStatus StatusID)
    {
        this.SalesReimburseBLL.FormDataSet = this.InnerDS;
        if (FillDetail())
        {
            if (StatusID == SystemEnums.FormStatus.Awaiting)
            {
                if (ReimburseFeeTotal <= 0)
                {
                    PageUtility.ShowModelDlg(this.Page, "报销总金额不能为零");
                    return;
                }
                //去掉此限制
                //if (this.PaymentTypeDDL.SelectedValue != ((int)SystemEnums.PaymentType.PiaoKou).ToString()) {
                //    if (decimal.Parse(this.ViewState["InvoiceFeeTotal"].ToString()) < decimal.Parse(this.ViewState["ReimburseFeeTotal"].ToString())) {
                //        PageUtility.ShowModelDlg(this.Page, "发票金额不得小于报销金额");
                //        return;
                //    }
                //}
            }
            int?RejectedFormID = null;
            if (this.ViewState["RejectedObjectID"] != null)
            {
                RejectedFormID = (int)this.ViewState["RejectedObjectID"];
            }
            int UserID           = (int)this.ViewState["StuffUserID"];
            int?ProxyStuffUserId = null;
            if (Session["ProxyStuffUserId"] != null)
            {
                ProxyStuffUserId = int.Parse(Session["ProxyStuffUserId"].ToString());
            }
            int    OrganizationUnitID   = (int)this.ViewState["DepartmentID"];
            int    PositionID           = (int)this.ViewState["PositionID"];
            int    CustomerID           = int.Parse(this.ViewState["CustomerID"].ToString());
            int    PaymentTypeID        = int.Parse(this.PaymentTypeDDL.SelectedValue);
            string AttachedFileName     = this.UCFileUpload.AttachmentFileName;
            string RealAttachedFileName = this.UCFileUpload.RealAttachmentFileName;
            string Remark = this.RemarkCtl.Text;

            try {
                if (this.ViewState["ObjectId"] == null || RejectedFormID != null)
                {
                    this.SalesReimburseBLL.AddFormReimburseMoney(RejectedFormID, UserID, ProxyStuffUserId, null, OrganizationUnitID, PositionID, SystemEnums.FormType.ReimburseApply, StatusID,
                                                                 CustomerID, PaymentTypeID, AttachedFileName, RealAttachedFileName, Remark, this.ViewState["FormApplyIds"].ToString(), this.ViewState["FormApplyNos"].ToString(), this.ViewState["FlowTemplate"].ToString());
                }
                else
                {
                    int FormID = (int)this.ViewState["ObjectId"];
                    this.SalesReimburseBLL.UpdateFormReimburseMoney(FormID, StatusID, SystemEnums.FormType.ReimburseApply, AttachedFileName, RealAttachedFileName, Remark, this.ViewState["FlowTemplate"].ToString());
                }
                this.Page.Response.Redirect("~/Home.aspx");
            } catch (Exception ex) {
                PageUtility.DealWithException(this.Page, ex);
            }
        }
    }
    protected void SaveFormContractl(SystemEnums.FormStatus StatusID)
    {
        int?RejectedFormID = null;

        if (this.ViewState["RejectedObjectID"] != null)
        {
            RejectedFormID = (int)this.ViewState["RejectedObjectID"];
        }
        int UserID           = (int)this.ViewState["StuffUserID"];
        int?ProxyStuffUserId = null;

        if (Session["ProxyStuffUserId"] != null)
        {
            ProxyStuffUserId = int.Parse(Session["ProxyStuffUserId"].ToString());
        }
        int OrganizationUnitID = (int)this.ViewState["DepartmentID"];
        int PositionID         = (int)this.ViewState["PositionID"];

        string startPeriod = ((TextBox)(this.UCPeriodBegin.FindControl("txtDate"))).Text.Trim();
        string endPeriod   = ((TextBox)(this.UCPeriodEnd.FindControl("txtDate"))).Text.Trim();

        string   ContractName         = this.txtContractName.Text;
        int      ContractTypeID       = int.Parse(this.dplContractType.SelectedValue.ToString());
        decimal  ContractAmount       = decimal.Parse(this.txtContractAmount.Text.ToString());
        int      PageNumber           = int.Parse(this.txtPageNumber.Text.ToString());
        string   FirstCompany         = this.txtFirstCompany.Text;
        string   SecondCompany        = this.txtSecondCompany.Text;
        string   ThirdCompany         = this.txtThirdCompany.Text;
        DateTime BeginDate            = DateTime.Parse(startPeriod);
        DateTime EndDate              = DateTime.Parse(endPeriod);
        string   PaymentType          = this.txtPaymentType.Text;
        string   MainContent          = this.txtMainContent.Text;
        string   ChangePart           = this.txtChangePart.Text;
        string   AttachedFileName     = this.UCFileUpload.AttachmentFileName;
        string   RealAttachedFileName = this.UCFileUpload.RealAttachmentFileName;

        try {
            if (this.ViewState["ObjectId"] == null || RejectedFormID != null)
            {
                this.ContractApplyBLL.AddFormContract(RejectedFormID, UserID, ProxyStuffUserId, null, OrganizationUnitID, PositionID, SystemEnums.FormType.ContractApply, StatusID, ContractName, ContractTypeID, ContractAmount, PageNumber, FirstCompany, SecondCompany, ThirdCompany, BeginDate, EndDate, PaymentType, MainContent, ChangePart, AttachedFileName, RealAttachedFileName, this.ViewState["FlowTemplate"].ToString());
            }
            else
            {
                int FormID = (int)this.ViewState["ObjectId"];
                this.ContractApplyBLL.UpdateFormContract(FormID, StatusID, SystemEnums.FormType.ContractApply, ContractName, ContractTypeID, ContractAmount, PageNumber, FirstCompany, SecondCompany, ThirdCompany, BeginDate, EndDate, PaymentType, MainContent, ChangePart, AttachedFileName, RealAttachedFileName, this.ViewState["FlowTemplate"].ToString());
            }
            this.Page.Response.Redirect("~/Home.aspx");
        } catch (Exception ex) {
            PageUtility.DealWithException(this.Page, ex);
        }
    }
Exemple #3
0
    protected void SaveFormTravelReimburse(SystemEnums.FormStatus StatusID)
    {
        this.PersonalReimburseBLL.FormDataSet = this.InnerDS;
        int?RejectedFormID = null;

        if (this.ViewState["RejectedObjectID"] != null)
        {
            RejectedFormID = (int)this.ViewState["RejectedObjectID"];
        }

        int UserID           = (int)this.ViewState["StuffUserID"];
        int?ProxyStuffUserId = null;

        if (Session["ProxyStuffUserId"] != null)
        {
            ProxyStuffUserId = int.Parse(Session["ProxyStuffUserId"].ToString());
        }
        int OrganizationUnitID = (int)this.ViewState["DepartmentID"];
        int PositionID         = (int)this.ViewState["PositionID"];

        DateTime Period               = new MasterDataBLL().GetReimbursePeriodById(int.Parse(this.PeriodDDL.SelectedValue)).ReimbursePeriod;
        string   Remark               = this.RemarkCtl.Text;
        string   AttachedFileName     = this.UCFileUpload.AttachmentFileName;
        string   RealAttachedFileName = this.UCFileUpload.RealAttachmentFileName;

        try {
            if (this.ViewState["ObjectId"] == null || RejectedFormID != null)
            {
                this.PersonalReimburseBLL.AddFormTravelReimburse(RejectedFormID, UserID, ProxyStuffUserId, null, OrganizationUnitID, PositionID,
                                                                 SystemEnums.FormType.PersonalReimburseApply, StatusID, Period, Remark, AttachedFileName, RealAttachedFileName, (int)this.ViewState["FormTravelApplyID"]);
            }
            else
            {
                int FormID = (int)this.ViewState["ObjectId"];
                this.PersonalReimburseBLL.UpdateFormTravelReimburse(FormID, StatusID, SystemEnums.FormType.PersonalReimburseApply, Period,
                                                                    Remark, AttachedFileName, RealAttachedFileName);
            }
            this.Page.Response.Redirect("~/Home.aspx");
        } catch (Exception ex) {
            PageUtility.DealWithException(this.Page, ex);
        }
    }
Exemple #4
0
    protected void SaveFormMaterial(SystemEnums.FormStatus StatusID)
    {
        this.MaterialApplyBLL.FormDataSet = this.InnerDS;
        int?RejectedFormID = null;

        if (this.ViewState["RejectedObjectID"] != null)
        {
            RejectedFormID = (int)this.ViewState["RejectedObjectID"];
        }

        int UserID           = (int)this.ViewState["StuffUserID"];
        int?ProxyStuffUserId = null;

        if (Session["ProxyStuffUserId"] != null)
        {
            ProxyStuffUserId = int.Parse(Session["ProxyStuffUserId"].ToString());
        }
        int    OrganizationUnitID = (int)this.ViewState["DepartmentID"];
        int    PositionID         = (int)this.ViewState["PositionID"];
        int    ShopID             = int.Parse(this.UCShop.ShopID);
        int    FirstVolume        = int.Parse(this.FirstVolumeCtl.Text);
        int    SecondVolume       = int.Parse(this.SecondVolumeCtl.Text);
        int    ThirdVolume        = int.Parse(this.ThirdVolumeCtl.Text);
        string Remark             = this.RemarkCtl.Text;

        try {
            if (this.ViewState["ObjectId"] == null || RejectedFormID != null)
            {
                this.MaterialApplyBLL.AddFormMaterial(RejectedFormID, UserID, ProxyStuffUserId, null, OrganizationUnitID, PositionID,
                                                      SystemEnums.FormType.MaterialApply, StatusID, ShopID, FirstVolume, SecondVolume, ThirdVolume, Remark, ViewState["FlowTemplate"].ToString());
            }
            else
            {
                int FormID = (int)this.ViewState["ObjectId"];
                this.MaterialApplyBLL.UpdateFormMaterial(FormID, StatusID, SystemEnums.FormType.MaterialApply, ShopID, FirstVolume, SecondVolume, ThirdVolume, Remark, ViewState["FlowTemplate"].ToString());
            }
            this.Page.Response.Redirect("~/Home.aspx");
        } catch (Exception ex) {
            PageUtility.DealWithException(this.Page, ex);
        }
    }
Exemple #5
0
    protected void SaveFormBudgetAllocation(SystemEnums.FormStatus StatusID)
    {
        this.BudgetAllocationApplyBLL.FormDataSet = this.InnerDS;
        int?RejectedFormID = null;

        if (this.ViewState["RejectedObjectID"] != null)
        {
            RejectedFormID = (int)this.ViewState["RejectedObjectID"];
        }

        int UserID           = (int)this.ViewState["StuffUserID"];
        int?ProxyStuffUserId = null;

        if (Session["ProxyStuffUserId"] != null)
        {
            ProxyStuffUserId = int.Parse(Session["ProxyStuffUserId"].ToString());
        }
        int OrganizationUnitID = (int)this.ViewState["DepartmentID"];
        int PositionID         = (int)this.ViewState["PositionID"];

        string AttachFileName     = this.UCFileUpload.AttachmentFileName;
        string RealAttachFileName = this.UCFileUpload.RealAttachmentFileName;
        string Remark             = this.RemarkCtl.Text;

        try {
            if (this.ViewState["ObjectId"] == null || RejectedFormID != null)
            {
                this.BudgetAllocationApplyBLL.AddFormBudgetAllocation(RejectedFormID, UserID, ProxyStuffUserId, null, OrganizationUnitID, PositionID,
                                                                      SystemEnums.FormType.BudgetAllocationApply, StatusID, Remark, AttachFileName, RealAttachFileName, this.ViewState["FlowTemplate"].ToString());
            }
            else
            {
                int FormID = (int)this.ViewState["ObjectId"];
                this.BudgetAllocationApplyBLL.UpdateFormBudgetAllocation(FormID, StatusID, SystemEnums.FormType.BudgetAllocationApply, Remark, AttachFileName, RealAttachFileName, this.ViewState["FlowTemplate"].ToString());
            }
            this.Page.Response.Redirect("~/Home.aspx");
        } catch (Exception ex) {
            PageUtility.DealWithException(this.Page, ex);
        }
    }
Exemple #6
0
        //启动流程
        public void ApplyForm(APHelper AP, FormTableAdapter FormTA, int?RejectedFormID, FormDS.FormRow formRow, int OrganizationUnitID, string ProcessTemplateName, SystemEnums.FormStatus StatusID, Dictionary <string, object> map)
        {
            string email = string.Empty;

            if (StatusID == SystemEnums.FormStatus.Awaiting)
            {
                string ProcID = AP.createProcess(formRow.FormNo + ":" + DateTime.Now.ToString(), ProcessTemplateName, map);
                formRow.ProcID = ProcID;

                String inTurnStr = AP.startProcess(ProcID, OrganizationUnitID, ref email, formRow.UserID.ToString(), new AuthorizationBLL().GetStuffUserById(formRow.UserID).StuffName);

                string[] InTurn = inTurnStr.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;               //下一步的人员职位
                formRow.StatusID          = (int)SystemEnums.FormStatus.Awaiting;
                FormTA.Update(formRow);
            }

            //作废之前的单据
            if (RejectedFormID != null)
            {
                FormDS.FormRow oldRow = FormTA.GetDataByID(RejectedFormID.GetValueOrDefault())[0];
                if (oldRow.StatusID == (int)SystemEnums.FormStatus.Rejected)
                {
                    ScrapForm(oldRow.FormID);
                }
            }
        }
Exemple #7
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();
            }
        }
Exemple #8
0
    protected void SaveFormApply(SystemEnums.FormStatus StatusID)
    {
        decimal?CustomerBudget       = null;
        decimal?CustomerBudgetRemain = null;
        decimal?OUBudget             = null;
        decimal?OUAppovedAmount      = null;
        decimal?OUApprovingAmount    = null;
        decimal?OUCompletedAmount    = null;
        decimal?OUReimbursedAmount   = null;
        decimal?OUBudgetRemain       = null;
        decimal?OUBudgetRate         = null;

        if (StatusID == SystemEnums.FormStatus.Awaiting)  //提交时检查,保存草稿不检查
        //首先检查合同内金额是否超限
        {
            object[] amountLimit = this.SalesApplyBLL.GetCustomerAmountLimitByParameter(int.Parse(this.ViewState["CustomerID"].ToString()), DateTime.Parse(this.ViewState["BeginPeriod"].ToString()).Year, decimal.Parse(this.ViewState["InContractAmount"].ToString()));
            if (amountLimit != null)
            {
                if (!(bool)amountLimit[0])
                {
                    PageUtility.ShowModelDlg(this.Page, string.Format("您当前选择的客户的合同内金额超出限制(剩余金额{0})", amountLimit[3].ToString()));
                    return;
                }
            }

            decimal[] calculateAssistant = new decimal[14];
            calculateAssistant = new BudgetBLL().GetSalesBudgetByParameter(int.Parse(this.ViewState["CustomerID"].ToString()), DateTime.Parse(this.ViewState["BeginPeriod"].ToString()), int.Parse(this.ViewState["ExpenseSubCategoryID"].ToString()));
            if (calculateAssistant[12] < decimal.Parse(this.ViewState["ManualApplyFeeTotal"].ToString()))
            {
                PageUtility.ShowModelDlg(this.Page, "本次申请金额超过可用预算,不能提交");
                return;
            }
            else
            {
                CustomerBudget       = calculateAssistant[0];
                CustomerBudgetRemain = calculateAssistant[5];
                OUBudget             = calculateAssistant[7];
                OUAppovedAmount      = calculateAssistant[8];
                OUApprovingAmount    = calculateAssistant[9];
                OUCompletedAmount    = calculateAssistant[10];
                OUReimbursedAmount   = calculateAssistant[11];
                OUBudgetRemain       = calculateAssistant[12];
                OUBudgetRate         = calculateAssistant[13];
            }
        }

        this.SalesApplyBLL.FormDataSet = this.InnerDS;
        int?RejectedFormID = null;

        if (this.ViewState["RejectedObjectID"] != null)
        {
            RejectedFormID = (int)this.ViewState["RejectedObjectID"];
        }

        int UserID           = (int)this.ViewState["StuffUserID"];
        int?ProxyStuffUserId = null;

        if (Session["ProxyStuffUserId"] != null)
        {
            ProxyStuffUserId = int.Parse(Session["ProxyStuffUserId"].ToString());
        }
        int      OrganizationUnitID   = (int)this.ViewState["DepartmentID"];
        int      PositionID           = (int)this.ViewState["PositionID"];
        DateTime BeginPeriod          = DateTime.Parse(this.ViewState["BeginPeriod"].ToString());
        DateTime EndPeriod            = DateTime.Parse(this.ViewState["EndPeriod"].ToString());
        int      CustomerID           = int.Parse(this.ViewState["CustomerID"].ToString());
        int      ShopID               = int.Parse(this.ShopDDL.SelectedValue);
        int      PaymentTypeID        = int.Parse(this.PaymentTypeDDL.SelectedValue);
        int      ExpenseSubCategoryID = int.Parse(this.ViewState["ExpenseSubCategoryID"].ToString());
        string   ContractNo           = this.ContractNoCtl.Text;
        DateTime PromotionBeginDate   = DateTime.Parse(this.UCPromotionBegin.SelectedDate);
        DateTime PromotionEndDate     = DateTime.Parse(this.UCPromotionEnd.SelectedDate);
        DateTime DeliveryBeginDate    = DateTime.Parse(this.UCDeliveryBegin.SelectedDate);
        DateTime DeliveryEndDate      = DateTime.Parse(this.UCDeliveryEnd.SelectedDate);
        int      PromotionScopeID     = int.Parse(this.PromotionScopeDDL.SelectedValue);
        int      PromotionTypeID      = int.Parse(this.PromotionTypeDDL.SelectedValue);
        string   PromotionDesc        = this.PromotionDescCtl.Text;
        int      ShelfTypeID          = int.Parse(this.ShelfTypeDDL.SelectedValue);
        int?     FirstVolume          = null;

        if (this.FirstVolumeCtl.Text != string.Empty)
        {
            FirstVolume = int.Parse(this.FirstVolumeCtl.Text);
        }
        int?SecondVolume = null;

        if (this.SecondVolumeCtl.Text != string.Empty)
        {
            SecondVolume = int.Parse(this.SecondVolumeCtl.Text);
        }
        int?ThirdVolume = null;

        if (this.ThirdVolumeCtl.Text != string.Empty)
        {
            ThirdVolume = int.Parse(this.ThirdVolumeCtl.Text);
        }
        string AttachedFileName     = this.UCFileUpload.AttachmentFileName;
        string RealAttachedFileName = this.UCFileUpload.RealAttachmentFileName;
        string Remark             = this.RemarkCtl.Text;
        string FormApplyName      = this.txtFormApplyName.Text;
        int    PromotionPriceType = int.Parse(this.ViewState["PromotionPriceType"].ToString());

        //预算信息

        //提交时判断跨月方案分摊比例是否正常
        if (StatusID == SystemEnums.FormStatus.Awaiting && EndPeriod.Month != BeginPeriod.Month)
        {
            if (InnerDS.FormApplySplitRate == null || InnerDS.FormApplySplitRate.Count == 0)
            {
                PageUtility.ShowModelDlg(this, "方案分摊比例异常,请重新填写!");
                return;
            }
            else
            {
                int sum = 0;
                foreach (FormDS.FormApplySplitRateRow item in InnerDS.FormApplySplitRate)
                {
                    sum += item.Rate;
                }
                if (sum != 100)
                {
                    PageUtility.ShowModelDlg(this, "方案分摊比例总和异常,请重新填写!");
                    return;
                }
            }
        }

        try {
            if (this.ViewState["ObjectId"] == null || RejectedFormID != null)
            {
                this.SalesApplyBLL.AddFormApply(RejectedFormID, UserID, ProxyStuffUserId, null, OrganizationUnitID, PositionID, SystemEnums.FormType.SalesApply, StatusID, BeginPeriod,
                                                EndPeriod, CustomerID, ShopID, PaymentTypeID, ExpenseSubCategoryID, ContractNo, PromotionBeginDate, PromotionEndDate, DeliveryBeginDate, DeliveryEndDate,
                                                PromotionScopeID, PromotionTypeID, PromotionDesc, ShelfTypeID, FirstVolume, SecondVolume, ThirdVolume, CustomerBudget, CustomerBudgetRemain, OUBudget, OUAppovedAmount, OUApprovingAmount, OUCompletedAmount,
                                                OUReimbursedAmount, OUBudgetRemain, OUBudgetRate, AttachedFileName, RealAttachedFileName, Remark, PromotionPriceType, int.Parse(ViewState["ReimburseRequirements"].ToString()), this.ViewState["FlowTemplate"].ToString(), FormApplyName);
            }
            else
            {
                int FormID = (int)this.ViewState["ObjectId"];
                this.SalesApplyBLL.UpdateFormApply(FormID, StatusID, SystemEnums.FormType.SalesApply, ShopID, PaymentTypeID, ContractNo, PromotionBeginDate,
                                                   PromotionEndDate, DeliveryBeginDate, DeliveryEndDate, PromotionScopeID, PromotionTypeID, PromotionDesc, ShelfTypeID, FirstVolume, SecondVolume, ThirdVolume, CustomerBudget, CustomerBudgetRemain,
                                                   OUBudget, OUAppovedAmount, OUApprovingAmount, OUCompletedAmount, OUReimbursedAmount, OUBudgetRemain, OUBudgetRate, AttachedFileName, RealAttachedFileName, Remark, int.Parse(ViewState["ReimburseRequirements"].ToString()), this.ViewState["FlowTemplate"].ToString(), FormApplyName);
            }
            this.Page.Response.Redirect("~/SalesForm/SalesApplySelect.aspx");
        } catch (Exception ex) {
            PageUtility.DealWithException(this.Page, ex);
        }
    }
        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();
            }
        }
Exemple #10
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();
            }
        }
Exemple #11
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();
            }
        }
Exemple #12
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();
            }
        }
Exemple #13
0
    protected void SaveFormApply(SystemEnums.FormStatus StatusID)
    {
        decimal?CustomerBudget       = null;
        decimal?CustomerBudgetRemain = null;
        decimal?OUBudget             = null;
        decimal?OUAppovedAmount      = null;
        decimal?OUApprovingAmount    = null;
        decimal?OUCompletedAmount    = null;
        decimal?OUReimbursedAmount   = null;
        decimal?OUBudgetRemain       = null;
        decimal?OUBudgetRate         = null;

        if (StatusID == SystemEnums.FormStatus.Awaiting)  //提交时检查,保存草稿不检查
        {
            decimal[] calculateAssistant = new decimal[14];
            calculateAssistant = new BudgetBLL().GetSalesBudgetByParameter(int.Parse(this.ViewState["CustomerID"].ToString()), DateTime.Parse(this.ViewState["BeginPeriod"].ToString()), int.Parse(this.ViewState["ExpenseSubCategoryID"].ToString()));
            if (calculateAssistant[12] < decimal.Parse(this.ViewState["ManualApplyFeeTotal"].ToString()))
            {
                PageUtility.ShowModelDlg(this.Page, "本次申请金额超过可用预算,不能提交");
                return;
            }
            else
            {
                CustomerBudget       = calculateAssistant[0];
                CustomerBudgetRemain = calculateAssistant[5];
                OUBudget             = calculateAssistant[7];
                OUAppovedAmount      = calculateAssistant[8];
                OUApprovingAmount    = calculateAssistant[9];
                OUCompletedAmount    = calculateAssistant[10];
                OUReimbursedAmount   = calculateAssistant[11];
                OUBudgetRemain       = calculateAssistant[12];
                OUBudgetRate         = calculateAssistant[13];
            }
        }

        this.SalesApplyBLL.FormDataSet = this.InnerDS;
        int?RejectedFormID = null;

        if (this.ViewState["RejectedObjectID"] != null)
        {
            RejectedFormID = (int)this.ViewState["RejectedObjectID"];
        }

        int UserID           = (int)this.ViewState["StuffUserID"];
        int?ProxyStuffUserId = null;

        if (Session["ProxyStuffUserId"] != null)
        {
            ProxyStuffUserId = int.Parse(Session["ProxyStuffUserId"].ToString());
        }
        int      OrganizationUnitID   = (int)this.ViewState["DepartmentID"];
        int      PositionID           = (int)this.ViewState["PositionID"];
        DateTime BeginPeriod          = DateTime.Parse(this.ViewState["BeginPeriod"].ToString());
        DateTime EndPeriod            = DateTime.Parse(this.ViewState["EndPeriod"].ToString());
        int      CustomerID           = int.Parse(this.ViewState["CustomerID"].ToString());
        int      ShopID               = int.Parse(this.ShopDDL.SelectedValue);
        int      PaymentTypeID        = int.Parse(this.PaymentTypeDDL.SelectedValue);
        int      ExpenseSubCategoryID = int.Parse(this.ViewState["ExpenseSubCategoryID"].ToString());
        string   ContractNo           = this.ContractNoCtl.Text;
        string   AttachedFileName     = this.UCFileUpload.AttachmentFileName;
        string   RealAttachedFileName = this.UCFileUpload.RealAttachmentFileName;
        string   Remark               = this.RemarkCtl.Text;
        string   FormApplyName        = this.txtFormApplyName.Text;

        if (this.SalesApplyBLL.GetRebateApplyCountByParameter(CustomerID, BeginPeriod.Year, BeginPeriod.Month, ExpenseSubCategoryID) > 0)
        {
            PageUtility.ShowModelDlg(this, "系统中已经存在该客户的返利申请,返利申请每月只能申请一次!");
            return;
        }
        try {
            if (this.ViewState["ObjectId"] == null || RejectedFormID != null)
            {
                this.SalesApplyBLL.AddFormApplyRebate(RejectedFormID, UserID, ProxyStuffUserId, null, OrganizationUnitID, PositionID, SystemEnums.FormType.SalesApply, StatusID, BeginPeriod,
                                                      EndPeriod, CustomerID, ShopID, PaymentTypeID, ExpenseSubCategoryID, ContractNo, CustomerBudget, CustomerBudgetRemain, OUBudget, OUAppovedAmount, OUApprovingAmount, OUCompletedAmount,
                                                      OUReimbursedAmount, OUBudgetRemain, OUBudgetRate, AttachedFileName, RealAttachedFileName, Remark, this.ViewState["FlowTemplate"].ToString(), FormApplyName);
            }
            else
            {
                int FormID = (int)this.ViewState["ObjectId"];
                this.SalesApplyBLL.UpdateFormApplyRebate(FormID, StatusID, SystemEnums.FormType.SalesApply, ShopID, PaymentTypeID, ContractNo, CustomerBudget, CustomerBudgetRemain,
                                                         OUBudget, OUAppovedAmount, OUApprovingAmount, OUCompletedAmount, OUReimbursedAmount, OUBudgetRemain, OUBudgetRate, AttachedFileName, RealAttachedFileName, Remark, this.ViewState["FlowTemplate"].ToString(), FormApplyName);
            }
            this.Page.Response.Redirect("~/SalesForm/SalesApplySelect.aspx");
        } catch (Exception ex) {
            PageUtility.DealWithException(this.Page, ex);
        }
    }
Exemple #14
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();
            }
        }
    protected void SaveFormPersonal(SystemEnums.FormStatus StatusID)
    {
        if (this.gvFormTravelApplyDetails.Rows.Count == 0)
        {
            PageUtility.ShowModelDlg(this, "请输入至少一条明细!");
            return;
        }
        this.PersonalReimburseBLL.FormDataSet = this.InnerDS;
        int?RejectedFormID = null;

        if (this.ViewState["RejectedObjectID"] != null)
        {
            RejectedFormID = (int)this.ViewState["RejectedObjectID"];
        }

        int UserID           = (int)this.ViewState["StuffUserID"];
        int?ProxyStuffUserId = null;

        if (Session["ProxyStuffUserId"] != null)
        {
            ProxyStuffUserId = int.Parse(Session["ProxyStuffUserId"].ToString());
        }
        int     OrganizationUnitID = (int)this.ViewState["DepartmentID"];
        int     PositionID         = (int)this.ViewState["PositionID"];
        decimal?TransportFee       = null;
        decimal?HotelFee           = null;
        decimal?MealFee            = null;
        decimal?OtherFee           = null;
        decimal temp = 0;

        if ((!string.IsNullOrEmpty(this.txtTransportFee.Text)) && decimal.TryParse(this.txtTransportFee.Text, out temp))
        {
            TransportFee = temp;
        }
        if ((!string.IsNullOrEmpty(this.txtHotelFee.Text)) && decimal.TryParse(this.txtHotelFee.Text, out temp))
        {
            HotelFee = temp;
        }
        if ((!string.IsNullOrEmpty(this.txtMealFee.Text)) && decimal.TryParse(this.txtMealFee.Text, out temp))
        {
            MealFee = temp;
        }
        if ((!string.IsNullOrEmpty(this.txtOtherFee.Text)) && decimal.TryParse(this.txtOtherFee.Text, out temp))
        {
            OtherFee = temp;
        }

        string Remark = this.RemarkCtl.Text;

        try {
            if (this.ViewState["ObjectId"] == null || RejectedFormID != null)
            {
                this.PersonalReimburseBLL.AddFormTravelApply(RejectedFormID, UserID, ProxyStuffUserId, null, OrganizationUnitID, PositionID,
                                                             SystemEnums.FormType.TravelApply, StatusID, TransportFee, HotelFee, MealFee, OtherFee, Remark, this.UCFileUpload.AttachmentFileName, this.UCFileUpload.RealAttachmentFileName);
            }
            else
            {
                int FormID = (int)this.ViewState["ObjectId"];
                this.PersonalReimburseBLL.UpdateFormTravelApply(FormID, StatusID, TransportFee, HotelFee, MealFee, OtherFee, Remark, this.UCFileUpload.AttachmentFileName, this.UCFileUpload.RealAttachmentFileName);
            }
            this.Page.Response.Redirect("~/Home.aspx");
        } catch (Exception ex) {
            PageUtility.DealWithException(this.Page, ex);
        }
    }
        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();
            }
        }
        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();
            }
        }