예제 #1
0
    protected void gvMaterialDetails_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.FormMaterialDetailRow row = (FormDS.FormMaterialDetailRow)drvDetail.Row;
                TotalFee = decimal.Round((TotalFee + row.Amount), 2);
            }
        }
        this.ViewState["ManualApplyFeeTotal"] = TotalFee;
        if (e.Row.RowType == DataControlRowType.Footer)
        {
            Label sumlbl = new Label();
            sumlbl.Text = "合计";
            e.Row.Cells[4].Controls.Add(sumlbl);
            e.Row.Cells[4].HorizontalAlign = HorizontalAlign.Right;
            e.Row.Cells[4].CssClass        = "RedTextAlignCenter";
            e.Row.Cells[4].Width           = new Unit("100px");

            Label totallbl = new Label();
            totallbl.Text = TotalFee.ToString("N");
            e.Row.Cells[5].Controls.Add(totallbl);
            e.Row.Cells[5].CssClass        = "RedTextAlignCenter";
            e.Row.Cells[5].HorizontalAlign = HorizontalAlign.Right;
            e.Row.Cells[5].Width           = new Unit("100px");
        }
    }
예제 #2
0
 public void AddFormMaterialDetail(int?FormMaterialID, int MaterialID, decimal Quantity, string Remark)
 {
     FormDS.FormMaterialDetailRow rowDetail = this.FormDataSet.FormMaterialDetail.NewFormMaterialDetailRow();
     rowDetail.FormMaterialID = FormMaterialID.GetValueOrDefault();
     ERS.MaterialRow material = new MasterDataBLL().GetMaterialById(MaterialID);
     rowDetail.MaterialID    = MaterialID;
     rowDetail.MaterialName  = material.MaterialName;
     rowDetail.UOM           = material.UOM;
     rowDetail.Description   = material.Description;
     rowDetail.MaterialPrice = material.MaterialPrice;
     rowDetail.Quantity      = Quantity;
     rowDetail.Amount        = rowDetail.MaterialPrice * Quantity;
     rowDetail.Remark        = Remark;
     // 填加行并进行更新处理
     this.FormDataSet.FormMaterialDetail.AddFormMaterialDetailRow(rowDetail);
 }
예제 #3
0
 public void UpdateFormMaterialDetail(int FormMaterialDetailID, int MaterialID, decimal Quantity, string Remark)
 {
     FormDS.FormMaterialDetailDataTable table     = this.FormDataSet.FormMaterialDetail;
     FormDS.FormMaterialDetailRow       rowDetail = table.FindByFormMaterialDetailID(FormMaterialDetailID);
     if (rowDetail == null)
     {
         return;
     }
     ERS.MaterialRow material = new MasterDataBLL().GetMaterialById(MaterialID);
     rowDetail.MaterialID    = MaterialID;
     rowDetail.MaterialName  = material.MaterialName;
     rowDetail.UOM           = material.UOM;
     rowDetail.Description   = material.Description;
     rowDetail.MaterialPrice = material.MaterialPrice;
     rowDetail.Quantity      = Quantity;
     rowDetail.Amount        = rowDetail.MaterialPrice * Quantity;
     rowDetail.Remark        = Remark;
 }
예제 #4
0
    protected void gvMaterialDetails_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.FormMaterialDetailRow row = (FormDS.FormMaterialDetailRow)drvDetail.Row;
                TotalFee = decimal.Round((TotalFee + row.Amount), 2);
            }
        }

        this.ViewState["ManualApplyFeeTotal"] = TotalFee;

        if (e.Row.RowType == DataControlRowType.Footer)
        {
            if (e.Row.RowType == DataControlRowType.Footer)
            {
                Label applbl = (Label)e.Row.FindControl("lblTotal");
                applbl.Text = TotalFee.ToString("N");
            }
        }
    }
예제 #5
0
        public void AddFormMaterial(int?RejectedFormID, int UserID, int?ProxyUserID, int?ProxyPositionID, int OrganizationUnitID, int PositionID, SystemEnums.FormType FormTypeID,
                                    SystemEnums.FormStatus StatusID, int ShopID, int FirstVolume, int SecondVolume, int ThirdVolume, string Remark, string FlowTemplate)
        {
            SqlTransaction transaction = null;

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

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

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

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

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

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

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

                // 正式提交或草稿

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

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