private void DeleteDtl()
 {
     try
     {
         RmsOA.BFL.GK_OA_SubmitAccountDtlBFL bfl  = new RmsOA.BFL.GK_OA_SubmitAccountDtlBFL();
         List <GK_OA_SubmitAccountDtlModel>  Objs = bfl.GetGK_OA_SubmitAccountDtlList(RmsPM.BLL.ConvertRule.ToString(this.ViewState["Code"]));
         foreach (GK_OA_SubmitAccountDtlModel mObj in Objs)
         {
             bfl.Delete(mObj);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
    /// <summary>
    /// 保存明细
    /// </summary>

    private void UpdateDtl()
    {
        List <GK_OA_SubmitAccountDtlModel> mObjs = GetScreenDtl();

        try
        {
            RmsOA.BFL.GK_OA_SubmitAccountDtlBFL bfl = new RmsOA.BFL.GK_OA_SubmitAccountDtlBFL();
            Hashtable tbInDtl = new Hashtable();

            //删除
            List <GK_OA_SubmitAccountDtlModel> oldObjs = bfl.GetGK_OA_SubmitAccountDtlList(Convert.ToString(this.ViewState["Code"]));
            foreach (GK_OA_SubmitAccountDtlModel mObj in oldObjs)
            {
                if (!tbInDtl.Contains(mObj.Code))
                {
                    tbInDtl.Add(mObj.Code, mObj.Code);
                }

                if (FindModel(mObjs, mObj.Code.ToString()) == null)
                {
                    bfl.Delete(mObj);
                }
            }

            foreach (GK_OA_SubmitAccountDtlModel mObj in mObjs)
            {
                if (!tbInDtl.Contains(mObj.Code))
                {
                    tbInDtl.Add(mObj.Code, mObj.Code);
                }

                if (mObj.Code <= 0)  //新增
                {
                    mObj.MastCode = Convert.ToString(this.ViewState["Code"]);
                    bfl.Insert(mObj);
                }
                else  //修改
                {
                    bfl.Update(mObj);
                }
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
Exemple #3
0
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        switch (e.Row.RowType)
        {
        case DataControlRowType.DataRow:
            decimal sumStandardCost = 0;
            RmsOA.BFL.GK_OA_SubmitAccountDtlBFL bfl = new RmsOA.BFL.GK_OA_SubmitAccountDtlBFL();
            System.Collections.Generic.List <RmsOA.MODEL.GK_OA_SubmitAccountDtlModel> lst = bfl.GetGK_OA_SubmitAccountDtlList(((RmsOA.MODEL.GK_OA_SubmitAccountMainModel)e.Row.DataItem).Code.ToString());

            foreach (RmsOA.MODEL.GK_OA_SubmitAccountDtlModel Model in lst)
            {
                sumStandardCost += Model.StandardCost;
            }
            ((Label)e.Row.FindControl("StandardCostLabel")).Text = RmsPM.BLL.MathRule.GetDecimalShowString(sumStandardCost);

            break;

        default:
            break;
        }
    }
    protected void FormView1_DataBound(object sender, EventArgs e)
    {
        if (FormView1.CurrentMode == FormViewMode.ReadOnly)
        {
            Button btnDelete = ((Button)this.FormView1.Row.FindControl("btnDelete"));
            if (btnDelete != null)
            {
                btnDelete.Attributes["OnClick"] = "javascript:return confirm('确实要删除当前记录吗?')";
            }
        }
        else
        {
            DataGrid dgDtl = (DataGrid)this.FormView1.Row.FindControl("dgDtl");
            if (dgDtl != null)
            {
                RmsOA.BFL.GK_OA_SubmitAccountDtlBFL bfl = new RmsOA.BFL.GK_OA_SubmitAccountDtlBFL();

                List <GK_OA_SubmitAccountDtlModel> Models = bfl.GetGK_OA_SubmitAccountDtlList(RmsPM.BLL.ConvertRule.ToString(this.ViewState["Code"]));
                ViewState["Models"] = Models;
                BindDtl(Models);
            }
        }
    }