Ejemplo n.º 1
0
    protected void gvInvoice_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.FormReimburseInvoiceRow row = (FormDS.FormReimburseInvoiceRow)drvDetail.Row;
                InvoiceFeeTotal = decimal.Round((InvoiceFeeTotal + row.InvoiceAmount), 2);
                string SystemInfo = row.IsSystemInfoNull() ? "" : row.SystemInfo;
                CommonUtility.GenerateRepeatControl(e.Row.Cells[3].Controls, SystemInfo);
            }
        }
        if (e.Row.RowType == DataControlRowType.Footer)
        {
            Label sumlbl = new Label();
            sumlbl.Text = "合计";
            e.Row.Cells[0].Controls.Add(sumlbl);
            e.Row.Cells[0].CssClass        = "RedTextAlignCenter";
            e.Row.Cells[0].HorizontalAlign = HorizontalAlign.Center;
            e.Row.Cells[0].Width           = new Unit("220px");

            Label totallbl = new Label();
            totallbl.Text = InvoiceFeeTotal.ToString("N");
            e.Row.Cells[1].Controls.Add(totallbl);
            e.Row.Cells[1].CssClass        = "RedTextAlignCenter";
            e.Row.Cells[1].HorizontalAlign = HorizontalAlign.Right;
            e.Row.Cells[1].Width           = new Unit("150px");
        }
    }
Ejemplo n.º 2
0
 public void AddFormReimburseInvoice(int?FormReimburseID, string InvoiceNo, decimal InvoiceAmount, string Remark)
 {
     FormDS.FormReimburseInvoiceRow rowDetail = this.FormDataSet.FormReimburseInvoice.NewFormReimburseInvoiceRow();
     rowDetail.FormReimburseID = FormReimburseID.GetValueOrDefault();
     rowDetail.InvoiceNo       = InvoiceNo;
     rowDetail.InvoiceAmount   = InvoiceAmount;
     rowDetail.Remark          = Remark;
     rowDetail.SystemInfo      = UtilityBLL.GenerateRepeatFormStr(this.TAForm.GetDataByInvoiceNo(InvoiceNo));
     // 填加行并进行更新处理
     this.FormDataSet.FormReimburseInvoice.AddFormReimburseInvoiceRow(rowDetail);
 }
Ejemplo n.º 3
0
 public void UpdateFormReimburseInvoice(int FormReimburseInvoiceID, string InvoiceNo, decimal InvoiceAmount, string Remark)
 {
     FormDS.FormReimburseInvoiceDataTable table     = this.FormDataSet.FormReimburseInvoice;
     FormDS.FormReimburseInvoiceRow       rowDetail = table.FindByFormReimburseInvoiceID(FormReimburseInvoiceID);
     if (rowDetail == null)
     {
         return;
     }
     rowDetail.InvoiceNo     = InvoiceNo;
     rowDetail.InvoiceAmount = InvoiceAmount;
     rowDetail.Remark        = Remark;
 }
Ejemplo n.º 4
0
        public void AddFormReimburseMoney(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.TAFormReimburseInvoice, transaction);
                TableAdapterHelper.SetTransaction(this.TAPKRecord, 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.ReimburseMoneyApply;
                this.FormDataSet.Form.AddFormRow(formRow);
                this.TAForm.Update(formRow);
                //处理PKRecord,如果提交才需要锁定
                if (PaymentTypeID == (int)SystemEnums.PaymentType.PiaoKou && StatusID == SystemEnums.FormStatus.Awaiting)
                {
                    TAPKRecord.LockPKRecord(formRow.FormID, FormApplyNos);
                }
                //处理申请表的内容
                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);

                //发票
                if (RejectedFormID != null)
                {
                    FormDS.FormReimburseInvoiceDataTable newInvoiceTable = new FormDS.FormReimburseInvoiceDataTable();
                    foreach (FormDS.FormReimburseInvoiceRow invoiceRow in this.FormDataSet.FormReimburseInvoice)
                    {
                        if (invoiceRow.RowState != DataRowState.Deleted)
                        {
                            FormDS.FormReimburseInvoiceRow newInvoiceRow = newInvoiceTable.NewFormReimburseInvoiceRow();
                            newInvoiceRow.FormReimburseID = FormReimburseRow.FormReimburseID;
                            newInvoiceRow.InvoiceNo       = invoiceRow.InvoiceNo;
                            newInvoiceRow.InvoiceAmount   = invoiceRow.InvoiceAmount;
                            newInvoiceRow.Remark          = invoiceRow.IsRemarkNull() ? "" : invoiceRow.Remark;
                            newInvoiceRow.SystemInfo      = invoiceRow.IsSystemInfoNull() ? "" : invoiceRow.SystemInfo;
                            newInvoiceTable.AddFormReimburseInvoiceRow(newInvoiceRow);
                        }
                        this.TAFormReimburseInvoice.Update(newInvoiceTable);
                    }
                }
                else
                {
                    foreach (FormDS.FormReimburseInvoiceRow invoiceRow in this.FormDataSet.FormReimburseInvoice)
                    {
                        // 与父表绑定
                        if (invoiceRow.RowState != DataRowState.Deleted)
                        {
                            invoiceRow.FormReimburseID = FormReimburseRow.FormReimburseID;
                        }
                    }
                }
                this.TAFormReimburseInvoice.Update(this.FormDataSet.FormReimburseInvoice);

                //明细表
                decimal totalAmount    = 0; //计算总申请金额
                decimal totalTaxAmount = 0; //总税金
                FormDS.FormReimburseDetailDataTable newDetailTable = new FormDS.FormReimburseDetailDataTable();
                foreach (FormDS.FormReimburseDetailRow detailRow in this.FormDataSet.FormReimburseDetail)
                {
                    // 与父表绑定
                    if (detailRow.RowState != DataRowState.Deleted)
                    {
                        totalAmount    += detailRow.Amount;
                        totalTaxAmount += detailRow.IsTaxAmountNull() ? 0 : detailRow.TaxAmount;
                        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.TaxAmount          = detailRow.IsTaxAmountNull() ? 0 : detailRow.TaxAmount;
                        newDetailRow.PrePaidAmount      = detailRow.IsPrePaidAmountNull() ? 0 : detailRow.PrePaidAmount;
                        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;
                FormReimburseRow.TaxAmount = totalTaxAmount;
                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 + totalTaxAmount;
                    //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, null, formRow, formRow.OrganizationUnitID, FlowTemplate, StatusID, dic);
                }
                transaction.Commit();
            } catch (Exception ex) {
                transaction.Rollback();
                throw new ApplicationException("Save Fail!" + ex.ToString());
            } finally {
                transaction.Dispose();
            }
        }