Beispiel #1
0
    protected void dvDataSource_Inserted(object sender, ObjectDataSourceStatusEventArgs e)
    {
        object          o     = e.ReturnValue;
        IncomingFacture inFac = (IncomingFacture)o;

        if (inFac.IncomingFactureType.Code == IncomingFactureType.ZA_POLISI)
        {
            GridView              gvNewPolicies    = (GridView)DetailsView1.FindControl("gvNewPolicies");
            List <FactureInfo>    lastFactureInfos = listFactureInfos;
            GridViewRowCollection displayedRows    = gvNewPolicies.Rows;
            foreach (GridViewRow gvRow in displayedRows)
            {
                CheckBox    cbIsForFacturing = gvRow.FindControl("cbIsForFacturing") as CheckBox;
                int         factureInfoID    = Convert.ToInt32(gvNewPolicies.DataKeys[gvRow.RowIndex].Value);
                FactureInfo fi = lastFactureInfos.Where(f => f.ID == factureInfoID).SingleOrDefault();
                fi.IsForFacturing = cbIsForFacturing.Checked;
            }
            listFactureInfos = lastFactureInfos;
            List <FactureInfo> listFactureInfo = listFactureInfos.Where(c => c.IsForFacturing == true).ToList();
            foreach (FactureInfo fi in listFactureInfo)
            {
                IncomingFacturePolicyItem ifpi = new IncomingFacturePolicyItem();
                ifpi.IncomingFactureID = inFac.ID;
                ifpi.PolicyItemID      = fi.ID;
                ifpi.IsActive          = true;
                ifpi.Insert();
                PolicyItem pi = PolicyItem.Get(fi.ID);
                pi.PolicyIncomeFactureStatusID = PolicyIncomeFactureStatuse.GetByCode(PolicyIncomeFactureStatuse.CELOSNO_FAKTURIRANA).ID;
                PolicyItem.Table.Context.SubmitChanges();
            }
        }
    }
Beispiel #2
0
    void LoadPoliciesForEdit(int incomeFactureID)
    {
        GridView           gvNewPolicies   = (GridView)DetailsView1.FindControl("gvNewPolicies");
        List <PolicyItem>  newPiList       = IncomingFacturePolicyItem.GetByIncomingFactureID(incomeFactureID).Select(c => c.PolicyItem).ToList();
        List <FactureInfo> newFactureInfos = new List <FactureInfo>();

        foreach (PolicyItem pi in newPiList)
        {
            FactureInfo fi = new FactureInfo();
            fi.ID             = pi.ID;
            fi.IsForFacturing = true;
            fi.PolicyNumber   = pi.PolicyNumber;
            newFactureInfos.Add(fi);
        }
        listFactureInfos         = newFactureInfos;
        gvNewPolicies.DataSource = newFactureInfos;
        gvNewPolicies.DataBind();
    }