Ejemplo n.º 1
0
    protected void gvReimburseDetails_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        // 对数据列进行赋值
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            if ((e.Row.RowState & DataControlRowState.Edit) != DataControlRowState.Edit)
            {
                DataRowView drvDetail             = (DataRowView)e.Row.DataItem;
                FormDS.FormReimburseDetailRow row = (FormDS.FormReimburseDetailRow)drvDetail.Row;
                ApplyFeeTotal     = decimal.Round((ApplyFeeTotal + row.AccruedAmount), 2);
                RemainFeeTotal    = decimal.Round((RemainFeeTotal + row.RemainAmount), 2);
                ReimburseFeeTotal = decimal.Round((ReimburseFeeTotal + row.Amount), 2);

                TextBox txtAmount = (TextBox)e.Row.FindControl("txtAmount");
                txtAmount.Attributes.Add("onBlur", "PlusTotal(this);");
                txtAmount.Attributes.Add("onFocus", "MinusTotal(this)");

                HyperLink      lblApplyFormNo = (HyperLink)e.Row.FindControl("lblApplyFormNo");
                FormDS.FormRow form           = this.SalesReimburseBLL.GetFormByID(row.FormApplyID)[0];
                switch (form.PageType)
                {
                case (int)SystemEnums.PageType.PromotionApply:
                    lblApplyFormNo.NavigateUrl = "javascript:window.showModalDialog('" + System.Configuration.ConfigurationManager.AppSettings["WebSiteUrl"] + "/SalesForm/SalesPromotionApproval.aspx?ShowDialog=1&ObjectId=" + row.FormApplyID + "','', 'dialogWidth:1000px;dialogHeight:750px;resizable:yes;')";
                    break;

                case (int)SystemEnums.PageType.GeneralApply:
                    lblApplyFormNo.NavigateUrl = "javascript:window.showModalDialog('" + System.Configuration.ConfigurationManager.AppSettings["WebSiteUrl"] + "/SalesForm/SalesGeneralApproval.aspx?ShowDialog=1&ObjectId=" + row.FormApplyID + "','', 'dialogWidth:1000px;dialogHeight:750px;resizable:yes;')";
                    break;

                case (int)SystemEnums.PageType.RebateApply:
                    lblApplyFormNo.NavigateUrl = "javascript:window.showModalDialog('" + System.Configuration.ConfigurationManager.AppSettings["WebSiteUrl"] + "/SalesForm/SalesRebateApproval.aspx?ShowDialog=1&ObjectId=" + row.FormApplyID + "','', 'dialogWidth:1000px;dialogHeight:750px;resizable:yes;')";
                    break;

                case (int)SystemEnums.PageType.GeneralApplyExecute:
                    lblApplyFormNo.NavigateUrl = "javascript:window.showModalDialog('" + System.Configuration.ConfigurationManager.AppSettings["WebSiteUrl"] + "/SalesForm/SalesGeneralExecution.aspx?ShowDialog=1&ObjectId=" + row.FormApplyID + "','', 'dialogWidth:1000px;dialogHeight:750px;resizable:yes;')";
                    break;

                case (int)SystemEnums.PageType.PromotionApplyExecute:
                    lblApplyFormNo.NavigateUrl = "javascript:window.showModalDialog('" + System.Configuration.ConfigurationManager.AppSettings["WebSiteUrl"] + "/SalesForm/SalesPromotionExecution.aspx?ShowDialog=1&ObjectId=" + row.FormApplyID + "','', 'dialogWidth:1000px;dialogHeight:750px;resizable:yes;')";
                    break;
                }
            }
        }

        if (e.Row.RowType == DataControlRowType.Footer)
        {
            Label applbl = (Label)e.Row.FindControl("applbl");
            applbl.Text = ApplyFeeTotal.ToString("N");

            Label Remainlbl = (Label)e.Row.FindControl("Remainlbl");
            Remainlbl.Text = RemainFeeTotal.ToString("N");

            Label totallbl = (Label)e.Row.FindControl("totallbl");
            totallbl.Text = ReimburseFeeTotal.ToString("N");
        }
    }
Ejemplo n.º 2
0
    private bool FillDetail()
    {
        bool isValid = true;

        foreach (GridViewRow row in this.gvReimburseDetails.Rows)
        {
            if (row.RowType == DataControlRowType.DataRow)
            {
                //Label lblFormApplyExpenseDetailID = (Label)row.FindControl("lblFormApplyExpenseDetailID");
                //DataRow[] drArray = this.InnerDS.FormReimburseDetail.Select("FormApplyExpenseDetailID =" + lblFormApplyExpenseDetailID.Text);
                //FormDS.FormReimburseDetailRow detailRow = (FormDS.FormReimburseDetailRow)drArray[0];
                FormDS.FormReimburseDetailRow detailRow = this.InnerDS.FormReimburseDetail[row.RowIndex];
                TextBox txtPrePaidAmount = (TextBox)row.FindControl("txtPrePaidAmount");
                TextBox txtAmount        = (TextBox)row.FindControl("txtAmount");
                TextBox txtTaxAmount     = (TextBox)row.FindControl("txtTaxAmount");
                if (string.IsNullOrEmpty(txtPrePaidAmount.Text.Trim()))
                {
                    txtPrePaidAmount.Text = "0";
                }
                if (string.IsNullOrEmpty(txtAmount.Text.Trim()))
                {
                    txtAmount.Text = "0";
                }
                if (string.IsNullOrEmpty(txtTaxAmount.Text.Trim()))
                {
                    txtTaxAmount.Text = "0";
                }
                decimal PrePaidAmount = decimal.Parse(txtPrePaidAmount.Text.Trim());
                decimal Amount        = decimal.Parse(txtAmount.Text.Trim());
                decimal TaxAmount     = decimal.Parse(txtTaxAmount.Text.Trim());
                if (PrePaidAmount < 0 || TaxAmount < 0 || Amount < 0)
                {
                    PageUtility.ShowModelDlg(this.Page, "不能录入负数");
                    isValid = false;
                    break;
                }
                decimal paidAmount = this.SalesReimburseBLL.GetPayedAmountByFormApplyExpenseDetailID(detailRow.FormApplyExpenseDetailID);
                detailRow.RemainAmount = detailRow.ApplyAmount - paidAmount;

                if (Amount + TaxAmount > detailRow.RemainAmount)
                {
                    PageUtility.ShowModelDlg(this.Page, "报销金额不能大于可报销金额");
                    isValid = false;
                    break;
                }
                detailRow.Amount        = Amount;
                detailRow.PrePaidAmount = PrePaidAmount;
                detailRow.TaxAmount     = TaxAmount;
                ReimburseFeeTotal       = decimal.Round((ReimburseFeeTotal + Amount), 2);
            }
        }
        this.ViewState["ReimburseFeeTotal"] = ReimburseFeeTotal;
        return(isValid);
    }
Ejemplo n.º 3
0
 public void AddFormReimburseDetail(int?FormReimburseID, int FormApplyExpenseDetailID, string ApplyFormNo, int ApplyPaymentTypeID, DateTime ApplyPeriod, int ShopID, int SKUID,
                                    int ExpenseItemID, decimal ApplyAmount, decimal RemainAmount, decimal Amount)
 {
     FormDS.FormReimburseDetailRow rowDetail = this.FormDataSet.FormReimburseDetail.NewFormReimburseDetailRow();
     rowDetail.FormReimburseID          = FormReimburseID.GetValueOrDefault();
     rowDetail.FormApplyExpenseDetailID = FormApplyExpenseDetailID;
     rowDetail.ApplyFormNo        = ApplyFormNo;
     rowDetail.ApplyPeriod        = ApplyPeriod;
     rowDetail.ShopID             = ShopID;
     rowDetail.SKUID              = SKUID;
     rowDetail.ExpenseItemID      = ExpenseItemID;
     rowDetail.ApplyAmount        = ApplyAmount;
     rowDetail.RemainAmount       = RemainAmount;
     rowDetail.Amount             = Amount;
     rowDetail.ApplyPaymentTypeID = ApplyPaymentTypeID;
     this.FormDataSet.FormReimburseDetail.AddFormReimburseDetailRow(rowDetail);
 }
Ejemplo n.º 4
0
    private bool FillDetail()
    {
        bool isValid = true;

        foreach (GridViewRow row in this.gvReimburseDetails.Rows)
        {
            if (row.RowType == DataControlRowType.DataRow)
            {
                FormDS.FormReimburseDetailRow detailRow = this.InnerDS.FormReimburseDetail[row.RowIndex];
                TextBox txtAmount = (TextBox)row.FindControl("txtAmount");
                if (string.IsNullOrEmpty(txtAmount.Text.Trim()))
                {
                    txtAmount.Text = "0";
                }
                decimal amount = decimal.Parse(txtAmount.Text.Trim());
                if (amount < 0)
                {
                    PageUtility.ShowModelDlg(this.Page, "不能录入负数");
                    isValid = false;
                    break;
                }
                if (amount > detailRow.RemainAmount)
                {
                    PageUtility.ShowModelDlg(this.Page, "报销金额不能大于可报销金额");
                    isValid = false;
                    break;
                }
                detailRow.Amount  = amount;
                ReimburseFeeTotal = decimal.Round((ReimburseFeeTotal + amount), 2);
            }
        }
        if (ReimburseFeeTotal <= 0)
        {
            PageUtility.ShowModelDlg(this.Page, "报销总金额不能为零");
            isValid = false;
        }
        this.ViewState["ReimburseFeeTotal"] = ReimburseFeeTotal;
        return(isValid);
    }
Ejemplo n.º 5
0
    protected void gvReimburseDetails_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        // 对数据列进行赋值
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            if ((e.Row.RowState & DataControlRowState.Edit) != DataControlRowState.Edit)
            {
                DataRowView drvDetail             = (DataRowView)e.Row.DataItem;
                FormDS.FormReimburseDetailRow row = (FormDS.FormReimburseDetailRow)drvDetail.Row;
                ApplyFeeTotal     = decimal.Round((ApplyFeeTotal + row.AccruedAmount), 2);
                RemainFeeTotal    = decimal.Round((RemainFeeTotal + row.RemainAmount), 2);
                ReimburseFeeTotal = decimal.Round((ReimburseFeeTotal + row.Amount), 2);
                PrePaidFeeTaltal  = decimal.Round(PrePaidFeeTaltal + (row.IsPrePaidAmountNull()?0:row.PrePaidAmount), 2);
                TaxFeeTotal       = decimal.Round(TaxFeeTotal + (row.IsTaxAmountNull()?0:row.TaxAmount), 2);
                HyperLink      lblApplyFormNo = (HyperLink)e.Row.FindControl("lblApplyFormNo");
                FormDS.FormRow form           = this.SalesReimburseBLL.GetFormByID(row.FormApplyID)[0];
                switch (form.PageType)
                {
                case (int)SystemEnums.PageType.PromotionApply:
                    lblApplyFormNo.NavigateUrl = "javascript:window.showModalDialog('" + System.Configuration.ConfigurationManager.AppSettings["WebSiteUrl"] + "/SalesForm/SalesPromotionApproval.aspx?ShowDialog=1&ObjectId=" + row.FormApplyID + "','', 'dialogWidth:1000px;dialogHeight:750px;resizable:yes;')";
                    break;

                case (int)SystemEnums.PageType.GeneralApply:
                    lblApplyFormNo.NavigateUrl = "javascript:window.showModalDialog('" + System.Configuration.ConfigurationManager.AppSettings["WebSiteUrl"] + "/SalesForm/SalesGeneralApproval.aspx?ShowDialog=1&ObjectId=" + row.FormApplyID + "','', 'dialogWidth:1000px;dialogHeight:750px;resizable:yes;')";
                    break;

                case (int)SystemEnums.PageType.RebateApply:
                    lblApplyFormNo.NavigateUrl = "javascript:window.showModalDialog('" + System.Configuration.ConfigurationManager.AppSettings["WebSiteUrl"] + "/SalesForm/SalesRebateApproval.aspx?ShowDialog=1&ObjectId=" + row.FormApplyID + "','', 'dialogWidth:1000px;dialogHeight:750px;resizable:yes;')";
                    break;

                case (int)SystemEnums.PageType.GeneralApplyExecute:
                    lblApplyFormNo.NavigateUrl = "javascript:window.showModalDialog('" + System.Configuration.ConfigurationManager.AppSettings["WebSiteUrl"] + "/SalesForm/SalesGeneralExecution.aspx?ShowDialog=1&ObjectId=" + row.FormApplyID + "','', 'dialogWidth:1000px;dialogHeight:750px;resizable:yes;')";
                    break;

                case (int)SystemEnums.PageType.PromotionApplyExecute:
                    lblApplyFormNo.NavigateUrl = "javascript:window.showModalDialog('" + System.Configuration.ConfigurationManager.AppSettings["WebSiteUrl"] + "/SalesForm/SalesPromotionExecution.aspx?ShowDialog=1&ObjectId=" + row.FormApplyID + "','', 'dialogWidth:1000px;dialogHeight:750px;resizable:yes;')";
                    break;
                }
            }
        }

        if (e.Row.RowType == DataControlRowType.Footer)
        {
            Label sumlbl = new Label();
            sumlbl.Text = "合计";
            e.Row.Cells[6].Controls.Add(sumlbl);
            e.Row.Cells[6].HorizontalAlign = HorizontalAlign.Center;
            e.Row.Cells[6].CssClass        = "RedTextAlignCenter";
            e.Row.Cells[6].Width           = new Unit("200px");

            Label applbl = new Label();
            applbl.Text = ApplyFeeTotal.ToString("N");
            e.Row.Cells[7].Controls.Add(applbl);
            e.Row.Cells[7].HorizontalAlign = HorizontalAlign.Right;
            e.Row.Cells[7].CssClass        = "RedTextAlignCenter";
            e.Row.Cells[7].Width           = new Unit("70px");

            Label Remainlbl = new Label();
            Remainlbl.Text = RemainFeeTotal.ToString("N");
            e.Row.Cells[8].Controls.Add(Remainlbl);
            e.Row.Cells[8].HorizontalAlign = HorizontalAlign.Right;
            e.Row.Cells[8].CssClass        = "RedTextAlignCenter";
            e.Row.Cells[8].Width           = new Unit("70px");

            Label lblPrePaidTotal = new Label();
            lblPrePaidTotal.Text = PrePaidFeeTaltal.ToString("N");
            lblPrePaidTotal.ID   = "lblPrePaidTotal";
            e.Row.Cells[9].Controls.Add(lblPrePaidTotal);
            e.Row.Cells[9].HorizontalAlign = HorizontalAlign.Right;
            e.Row.Cells[9].CssClass        = "RedTextAlignCenter";
            e.Row.Cells[9].Width           = new Unit("70px");

            Label totallbl = new Label();
            totallbl.Text = ReimburseFeeTotal.ToString("N");
            totallbl.ID   = "totallbl";
            e.Row.Cells[10].Controls.Add(totallbl);
            e.Row.Cells[10].HorizontalAlign = HorizontalAlign.Right;
            e.Row.Cells[10].CssClass        = "RedTextAlignCenter";
            e.Row.Cells[10].Width           = new Unit("70px");

            Label lblTaxTotal = new Label();
            lblTaxTotal.Text = TaxFeeTotal.ToString("N");
            lblTaxTotal.ID   = "lblTaxTotal";
            e.Row.Cells[11].Controls.Add(lblTaxTotal);
            e.Row.Cells[11].HorizontalAlign = HorizontalAlign.Right;
            e.Row.Cells[11].CssClass        = "RedTextAlignCenter";
            e.Row.Cells[11].Width           = new Unit("70px");
        }
    }
Ejemplo n.º 6
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();
            }
        }