Beispiel #1
0
 protected void btnAddPolicyToList_Click(object sender, EventArgs e)
 {
     try {
         TextBox          tbPolicyNumberToList  = (TextBox)DetailsView1.FindControl("tbPolicyNumberToList");
         DropDownList     ddlInsuranceCompanies = (DropDownList)DetailsView1.FindControl("ddlInsuranceCompanies");
         int              icID = Convert.ToInt32(ddlInsuranceCompanies.SelectedValue);
         InsuranceCompany ic   = InsuranceCompany.Get(icID);
         PolicyItem       pi   = PolicyItem.GetByNumberAndInsuranceCompany(tbPolicyNumberToList.Text, icID);
         if (pi != null)
         {
             GridView           gvNewPolicies    = (GridView)DetailsView1.FindControl("gvNewPolicies");
             List <FactureInfo> lastFactureInfos = listFactureInfos;
             FactureInfo        fi = listFactureInfos.Where(c => c.PolicyNumber == tbPolicyNumberToList.Text).SingleOrDefault();
             if (fi != null)
             {
                 RegisterStartupScript("myAlert", "<script>alert('Полисата постои во листата!')</script>");
                 return;
             }
             FactureInfo newFactureInfo = new FactureInfo();
             newFactureInfo.PolicyNumber   = tbPolicyNumberToList.Text;
             newFactureInfo.IsForFacturing = true;
             newFactureInfo.ID             = pi.ID;
             lastFactureInfos.Add(newFactureInfo);
             listFactureInfos         = lastFactureInfos;
             gvNewPolicies.DataSource = lastFactureInfos;
             gvNewPolicies.DataBind();
         }
         else
         {
             RegisterStartupScript("myAlert", "<script>alert('Не постои полиса со избраниот број!')</script>");
         }
     } catch {
         RegisterStartupScript("myAlert", "<script>alert('Грешка!')</script>");
     }
 }
Beispiel #2
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 #3
0
    protected void btnInsert_Click(object sender, EventArgs e)
    {
        DateTime              startDate        = DateTime.Parse(tbStartDate.Text);
        DateTime              endDate          = DateTime.Parse(tbEndDate.Text);
        List <FactureInfo>    lastFactureInfos = listNewFactureInfos;
        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(facInfo => facInfo.ID == factureInfoID).SingleOrDefault();
            fi.IsForFacturing = cbIsForFacturing.Checked;
        }
        listNewFactureInfos = lastFactureInfos;
        List <PolicyItem> items = new List <PolicyItem>();

        foreach (FactureInfo fi in lastFactureInfos)
        {
            if (fi.IsForFacturing)
            {
                PolicyItem pi = PolicyItem.Get(fi.ID);
                items.Add(pi);
            }
        }
        if (items.Count > 0)
        {
            if (ddlClients.SelectedIndex != -1)
            {
                int clientID  = int.Parse(ddlClients.SelectedValue);
                int factureID = Broker.DataAccess.Facture.CreateGroupFacture(this.PageUser.ID, clientID, startDate, endDate, items);
                FactureID         = factureID;
                btnPrint.Visible  = true;
                btnInsert.Visible = false;
                //btnPrintAnex.Visible = true;
                InsertClientInFinansovo(clientID);
            }
            else
            {
                lblError.Visible = true;
                btnPrint.Visible = false;
            }
        }
        else
        {
            lblError.Visible = true;
            btnPrint.Visible = false;
        }
    }
Beispiel #4
0
    protected void gvNewPolicies_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        List <FactureInfo>    lastFactureInfos = listNewFactureInfos;
        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;
        }
        listNewFactureInfos      = lastFactureInfos;
        gvNewPolicies.PageIndex  = e.NewPageIndex;
        gvNewPolicies.DataSource = lastFactureInfos;
        gvNewPolicies.DataBind();
    }
Beispiel #5
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();
    }
Beispiel #6
0
    void LoadPoliciesForFacturing(int insuranceCompanyID)
    {
        GridView           gvNewPolicies   = (GridView)DetailsView1.FindControl("gvNewPolicies");
        List <PolicyItem>  newPiList       = PolicyItem.GetNonIncomeFactured(insuranceCompanyID);
        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();
    }
Beispiel #7
0
    void BindPolForClient(int clientID)
    {
        DateTime           startDate       = DateTime.Parse(tbStartDate.Text);
        DateTime           endDate         = DateTime.Parse(tbEndDate.Text);
        List <PolicyItem>  lstPolPerClient = PolicyItem.GetForGroupFactures(startDate, endDate, clientID);
        List <FactureInfo> lstFacInfo      = new List <FactureInfo>();

        foreach (PolicyItem pi in lstPolPerClient)
        {
            FactureInfo fi = new FactureInfo();
            fi.ID             = pi.ID;
            fi.PolicyNumber   = pi.PolicyNumber;
            fi.IsForFacturing = true;
            fi.PremiumValue   = pi.PremiumValue;
            lstFacInfo.Add(fi);
        }
        listNewFactureInfos      = lstFacInfo;
        gvNewPolicies.DataSource = lstFacInfo;
        gvNewPolicies.DataBind();
    }
Beispiel #8
0
    protected void btnCheck_Click(object sender, EventArgs e)
    {
        DateTime           fromDate        = DateTime.Parse(tbStartDate.Text);
        DateTime           toDate          = DateTime.Parse(tbEndDate.Text);
        List <PolicyItem>  oldPiList       = PolicyItem.GetFromPreivousMonthsForAccountFactures(fromDate, int.Parse(ddlInsuranceCompanies.SelectedValue));
        List <FactureInfo> oldFactureInfos = new List <FactureInfo>();

        foreach (PolicyItem pi in oldPiList)
        {
            FactureInfo fi = new FactureInfo();
            fi.ID             = pi.ID;
            fi.IsForFacturing = true;
            fi.PolicyNumber   = pi.PolicyNumber;
            oldFactureInfos.Add(fi);
        }
        listFactureInfos         = oldFactureInfos;
        gvOldPolicies.DataSource = oldFactureInfos;
        gvOldPolicies.Caption    = "Полиси од претходни месеци (" + oldFactureInfos.Count.ToString() + ")";
        gvOldPolicies.DataBind();

        List <PolicyItem>  newPiList       = PolicyItem.GetForAccountFacturingFromCurrentMonth(fromDate, toDate, int.Parse(ddlInsuranceCompanies.SelectedValue));
        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);
        }
        listNewFactureInfos      = newFactureInfos;
        gvNewPolicies.DataSource = newFactureInfos;
        gvNewPolicies.Caption    = "Полиси од селектираниот период (" + newFactureInfos.Count.ToString() + ")";
        gvNewPolicies.DataBind();
    }
Beispiel #9
0
    protected void btnCreate_Click(object sender, EventArgs e)
    {
        DateTime startDate     = DateTime.Parse(tbStartDate.Text);
        DateTime endDate       = DateTime.Parse(tbEndDate.Text);
        DateTime dateOfPayment = DateTime.Now.AddDays(15);

        if (tbDateOfPayment.Text.Trim() != string.Empty)
        {
            DateTime.TryParse(tbDateOfPayment.Text, out dateOfPayment);
        }
        InsuranceCompany company = InsuranceCompany.Get(int.Parse(ddlInsuranceCompanies.SelectedValue));

        Broker.DataAccess.User u = this.PageUser;

        DateTime fromDate = DateTime.Parse(tbStartDate.Text);
        DateTime toDate   = DateTime.Parse(tbEndDate.Text);

        if (rblInsuranceLifeType.SelectedValue == "NoLife")
        {
            //List<PolicyItem> piList = PolicyItem.GetFromPreivousMonths(fromDate, company.ID);
            List <FactureInfo>    lastFactureInfos = listNewFactureInfos;
            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(facInfo => facInfo.ID == factureInfoID).SingleOrDefault();
                fi.IsForFacturing = cbIsForFacturing.Checked;
            }
            listNewFactureInfos = lastFactureInfos;
            lastFactureInfos    = listFactureInfos;
            displayedRows       = gvOldPolicies.Rows;
            foreach (GridViewRow gvRow in displayedRows)
            {
                CheckBox    cbIsForFacturing = gvRow.FindControl("cbIsForFacturing") as CheckBox;
                int         factureInfoID    = Convert.ToInt32(gvOldPolicies.DataKeys[gvRow.RowIndex].Value);
                FactureInfo fi = lastFactureInfos.Where(facInfo => facInfo.ID == factureInfoID).SingleOrDefault();
                fi.IsForFacturing = cbIsForFacturing.Checked;
            }
            listFactureInfos = lastFactureInfos;


            List <PolicyItem>  policiesToRemove = new List <PolicyItem>();
            List <FactureInfo> listOldPolicies  = (List <FactureInfo>)listFactureInfos;
            foreach (FactureInfo fi in listOldPolicies)
            {
                if (!fi.IsForFacturing)
                {
                    policiesToRemove.Add(PolicyItem.Get(fi.ID));
                }
            }
            List <FactureInfo> listNewPolicies = (List <FactureInfo>)listNewFactureInfos;
            foreach (FactureInfo fi in listNewPolicies)
            {
                if (!fi.IsForFacturing)
                {
                    PolicyItem pi = PolicyItem.Get(fi.ID);
                    if (!policiesToRemove.Contains(pi))
                    {
                        policiesToRemove.Add(pi);
                    }
                }
            }



            Broker.DataAccess.Facture f = Broker.DataAccess.Facture.Generate(startDate, endDate, company, u, dateOfPayment, policiesToRemove);
            // f.Insert();

            //int number = 1;
            //List<FactureItem> fiList = new List<FactureItem>();
            //List<FactureItem.FactureItemGrouped> factureItemGroupedList = FactureItem.GetFactureItemsForCompany(company.ID, startDate, endDate);
            //foreach (FactureItem.FactureItemGrouped fifig in factureItemGroupedList) {
            //    FactureItem fi = new FactureItem();
            //    fi.PremiumValue = fifig.TotalValue;
            //    fi.Count = fifig.PaymentsCount;
            //    fi.FactureID = f.ID;
            //    fi.InsuranceSubTypeID = fifig.InsuranceSubTypeID;
            //    fi.Number = number;
            //    ++number;
            //    fi.Description = InsuranceSubType.Get(fifig.InsuranceSubTypeID).ShortDescription;
            //    fi.Insert();
            //    fiList.Add(fi);
            //}

            //List<PolicyItem> pItemList = PolicyItem.GetForFacture(f, company.ID);
            //PolicyItemFactureItem.InsertForFacture(fiList, pItemList);


            //List<FactureItem> fiListCash = new List<FactureItem>();
            //List<FactureItem.FactureItemGrouped> factureItemGroupedCashList = FactureItem.GetForCashPayments(company.ID, startDate, endDate);
            //foreach (FactureItem.FactureItemGrouped fifig in factureItemGroupedCashList) {
            //    FactureItem fi = new FactureItem();
            //    fi.PremiumValue = fifig.TotalValue;
            //    fi.Count = fifig.PaymentsCount;
            //    fi.FactureID = f.ID;
            //    fi.InsuranceSubTypeID = fifig.InsuranceSubTypeID;
            //    fi.Number = number;
            //    ++number;
            //    fi.Description = InsuranceSubType.Get(fifig.InsuranceSubTypeID).ShortDescription;
            //    fi.Insert();
            //    fiListCash.Add(fi);
            //}

            //List<PolicyItem> pItemListCash = PolicyItem.GetForFactureCash(f, company.ID);
            //PolicyItemFactureItem.InsertForFacture(fiListCash, pItemListCash);
            if (f != null)
            {
                lblError.Visible = false;
                odsFacturePreview.SelectParameters.Clear();
                odsFacturePreview.SelectParameters.Add("id", f.ID.ToString());
                odsFactureItems.SelectParameters.Clear();
                odsFactureItems.SelectParameters.Add("factureID", f.ID.ToString());
                mvMain.SetActiveView(viewFactureItems);
            }
            else
            {
                lblError.Visible   = true;
                lblError.Font.Bold = true;
                lblError.Text      = "Не постојат нефактурирани износи";
            }
        }
        else if (rblInsuranceLifeType.SelectedValue == "Life")
        {
            List <FactureInfo>    lastFactureInfos = listNewFactureInfos;
            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(facInfo => facInfo.ID == factureInfoID).SingleOrDefault();
                fi.IsForFacturing = cbIsForFacturing.Checked;
            }
            listNewFactureInfos = lastFactureInfos;
            lastFactureInfos    = listFactureInfos;
            displayedRows       = gvOldPolicies.Rows;
            foreach (GridViewRow gvRow in displayedRows)
            {
                CheckBox    cbIsForFacturing = gvRow.FindControl("cbIsForFacturing") as CheckBox;
                int         factureInfoID    = Convert.ToInt32(gvOldPolicies.DataKeys[gvRow.RowIndex].Value);
                FactureInfo fi = lastFactureInfos.Where(facInfo => facInfo.ID == factureInfoID).SingleOrDefault();
                fi.IsForFacturing = cbIsForFacturing.Checked;
            }
            listFactureInfos = lastFactureInfos;
            List <LifePolicy>  policiesToRemove = new List <LifePolicy>();
            List <FactureInfo> listOldPolicies  = (List <FactureInfo>)listFactureInfos;
            foreach (FactureInfo fi in listOldPolicies)
            {
                if (!fi.IsForFacturing)
                {
                    policiesToRemove.Add(LifePolicy.Get(fi.ID));
                }
            }
            List <FactureInfo> listNewPolicies = (List <FactureInfo>)listNewFactureInfos;
            foreach (FactureInfo fi in listNewPolicies)
            {
                if (!fi.IsForFacturing)
                {
                    LifePolicy pi = LifePolicy.Get(fi.ID);
                    if (!policiesToRemove.Contains(pi))
                    {
                        policiesToRemove.Add(pi);
                    }
                }
            }



            Broker.DataAccess.Facture f = Broker.DataAccess.Facture.GenerateForLife(startDate, endDate, company, u, dateOfPayment, policiesToRemove);

            if (f != null)
            {
                lblError.Visible = false;
                odsFacturePreview.SelectParameters.Clear();
                odsFacturePreview.SelectParameters.Add("id", f.ID.ToString());
                odsFactureItems.SelectParameters.Clear();
                odsFactureItems.SelectParameters.Add("factureID", f.ID.ToString());
                mvMain.SetActiveView(viewFactureItems);
            }
            else
            {
                lblError.Visible   = true;
                lblError.Font.Bold = true;
                lblError.Text      = "Не постојат нефактурирани износи";
            }
        }
    }
Beispiel #10
0
    protected void btnCheck_Click(object sender, EventArgs e)
    {
        DateTime fromDate = DateTime.Parse(tbStartDate.Text);
        DateTime toDate   = DateTime.Parse(tbEndDate.Text);

        if (rblInsuranceLifeType.SelectedValue == "NoLife")
        {
            List <PolicyItem>  oldPiList       = PolicyItem.GetFromPreivousMonths(fromDate, int.Parse(ddlInsuranceCompanies.SelectedValue));
            List <FactureInfo> oldFactureInfos = new List <FactureInfo>();
            foreach (PolicyItem pi in oldPiList)
            {
                FactureInfo fi = new FactureInfo();
                fi.ID             = pi.ID;
                fi.IsForFacturing = true;
                fi.PolicyNumber   = pi.PolicyNumber;
                //fi.PremiumValue = pi.PremiumValue;
                fi.PremiumValue = pi.RealPremiumValue;
                //fi.PaidValue = Payment.GetPaidValueForPolicyItem(pi.ID);
                oldFactureInfos.Add(fi);
            }
            listFactureInfos         = oldFactureInfos;
            gvOldPolicies.DataSource = oldFactureInfos;
            gvOldPolicies.Caption    = "Полиси од претходни месеци (" + oldFactureInfos.Count.ToString() + ")";
            gvOldPolicies.DataBind();

            List <PolicyItem>  newPiList       = PolicyItem.GetForFacturingFromCurrentMonth(fromDate, toDate, int.Parse(ddlInsuranceCompanies.SelectedValue));
            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;
                //fi.PremiumValue = pi.PremiumValue;
                fi.PremiumValue = pi.RealPremiumValue;
                //fi.PaidValue = Payment.GetPaidValueForPolicyItem(pi.ID);
                newFactureInfos.Add(fi);
            }
            listNewFactureInfos      = newFactureInfos;
            gvNewPolicies.DataSource = newFactureInfos;
            gvNewPolicies.Caption    = "Полиси од селектираниот период (" + newFactureInfos.Count.ToString() + ")";
            gvNewPolicies.DataBind();
        }
        else if (rblInsuranceLifeType.SelectedValue == "Life")
        {
            List <LifePolicy>  oldPiList       = LifePolicy.GetFromPreviousMonths(fromDate, int.Parse(ddlInsuranceCompanies.SelectedValue));
            List <FactureInfo> oldFactureInfos = new List <FactureInfo>();
            foreach (LifePolicy pi in oldPiList)
            {
                FactureInfo fi = new FactureInfo();
                fi.ID             = pi.ID;
                fi.IsForFacturing = true;
                fi.PolicyNumber   = pi.PolicyNumber;
                //fi.PremiumValue = pi.PremiumValue;
                fi.PremiumValue = pi.TotalPremumValue;
                //fi.PaidValue = Payment.GetPaidValueForPolicyItem(pi.ID);
                oldFactureInfos.Add(fi);
            }
            listFactureInfos         = oldFactureInfos;
            gvOldPolicies.DataSource = oldFactureInfos;
            gvOldPolicies.Caption    = "Полиси од претходни месеци (" + oldFactureInfos.Count.ToString() + ")";
            gvOldPolicies.DataBind();

            List <LifePolicy>  newPiList       = LifePolicy.GetForFacturingFromCurrentMonth(fromDate, toDate, int.Parse(ddlInsuranceCompanies.SelectedValue));
            List <FactureInfo> newFactureInfos = new List <FactureInfo>();
            foreach (LifePolicy pi in newPiList)
            {
                FactureInfo fi = new FactureInfo();
                fi.ID             = pi.ID;
                fi.IsForFacturing = true;
                fi.PolicyNumber   = pi.PolicyNumber;
                //fi.PremiumValue = pi.PremiumValue;
                fi.PremiumValue = pi.TotalPremumValue;
                //fi.PaidValue = Payment.GetPaidValueForPolicyItem(pi.ID);
                newFactureInfos.Add(fi);
            }
            listNewFactureInfos      = newFactureInfos;
            gvNewPolicies.DataSource = newFactureInfos;
            gvNewPolicies.Caption    = "Полиси од селектираниот период (" + newFactureInfos.Count.ToString() + ")";
            gvNewPolicies.DataBind();
        }
    }
Beispiel #11
0
    protected void btnCalculateCurrentState_Click(object sender, EventArgs e)
    {
        if (rblInsuranceLifeType.SelectedValue == "NoLife")
        {
            DateTime              startDate        = DateTime.Parse(tbStartDate.Text);
            DateTime              endDate          = DateTime.Parse(tbEndDate.Text);
            InsuranceCompany      company          = InsuranceCompany.Get(int.Parse(ddlInsuranceCompanies.SelectedValue));
            DateTime              fromDate         = DateTime.Parse(tbStartDate.Text);
            DateTime              toDate           = DateTime.Parse(tbEndDate.Text);
            List <FactureInfo>    lastFactureInfos = listNewFactureInfos;
            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(facInfo => facInfo.ID == factureInfoID).SingleOrDefault();
                fi.IsForFacturing = cbIsForFacturing.Checked;
            }
            listNewFactureInfos = lastFactureInfos;
            lastFactureInfos    = listFactureInfos;
            displayedRows       = gvOldPolicies.Rows;
            foreach (GridViewRow gvRow in displayedRows)
            {
                CheckBox    cbIsForFacturing = gvRow.FindControl("cbIsForFacturing") as CheckBox;
                int         factureInfoID    = Convert.ToInt32(gvOldPolicies.DataKeys[gvRow.RowIndex].Value);
                FactureInfo fi = lastFactureInfos.Where(facInfo => facInfo.ID == factureInfoID).SingleOrDefault();
                fi.IsForFacturing = cbIsForFacturing.Checked;
            }
            listFactureInfos = lastFactureInfos;


            List <PolicyItem>  policiesToRemove = new List <PolicyItem>();
            List <FactureInfo> listOldPolicies  = (List <FactureInfo>)listFactureInfos;
            foreach (FactureInfo fi in listOldPolicies)
            {
                if (!fi.IsForFacturing)
                {
                    policiesToRemove.Add(PolicyItem.Get(fi.ID));
                }
            }
            List <FactureInfo> listNewPolicies = (List <FactureInfo>)listNewFactureInfos;
            foreach (FactureInfo fi in listNewPolicies)
            {
                if (!fi.IsForFacturing)
                {
                    PolicyItem pi = PolicyItem.Get(fi.ID);
                    if (!policiesToRemove.Contains(pi))
                    {
                        policiesToRemove.Add(pi);
                    }
                }
            }

            List <Payment> paymentList                 = Payment.GetForFactureByDateAndInsuranceCompany(endDate, company.ID);
            decimal        brokerageValue              = 0;
            decimal        totalSum                    = 0;
            decimal        currentBrokerageValue       = 0;
            Dictionary <int, decimal[]> dictionary     = new Dictionary <int, decimal[]>();
            List <PolicyItem>           policyItemList = new List <PolicyItem>();

            foreach (Payment p in paymentList)
            {
                PolicyItem policyItem = p.Rate.PolicyItem;
                if (!policiesToRemove.Contains(policyItem))
                {
                    if (!policyItemList.Contains(policyItem))
                    {
                        policyItemList.Add(policyItem);
                    }
                    if (policyItem.Policy.PacketID != null)
                    {
                        if (policyItem.Policy.Client.IsLaw)
                        {
                            currentBrokerageValue = p.Value * policyItem.PacketsInsuranceSubType.BrokeragePecentageForLaws / 100;
                        }
                        else
                        {
                            currentBrokerageValue = p.Value * policyItem.PacketsInsuranceSubType.BrokeragePecentageForPrivates / 100;
                        }
                    }
                    else
                    {
                        if (policyItem.Policy.Client.IsLaw)
                        {
                            currentBrokerageValue = p.Value * policyItem.Brokerage.PercentageForLaws / 100;
                        }
                        else
                        {
                            currentBrokerageValue = p.Value * policyItem.Brokerage.PercentageForPrivates / 100;
                        }
                    }
                    brokerageValue += currentBrokerageValue;
                    if (dictionary.ContainsKey(policyItem.InsuranceSubTypeID))
                    {
                        dictionary[policyItem.InsuranceSubTypeID][0] += currentBrokerageValue;
                        dictionary[policyItem.InsuranceSubTypeID][1] += p.Value;
                        // dictionary[policyItem.InsuranceSubTypeID][2] += 1;
                    }
                    else
                    {
                        decimal[] newValues = { currentBrokerageValue, p.Value /*, 1 */ };
                        dictionary.Add(policyItem.InsuranceSubTypeID, newValues);
                    }
                    totalSum += p.Value;
                }
            }

            tbCurrentBrokerageValue.Text = String.Format("{0:#,0.00}", brokerageValue);
            tbCurrentPremiumValue.Text   = String.Format("{0:#,0.00}", totalSum);
        }
        else if (rblInsuranceLifeType.SelectedValue == "Life")
        {
        }
    }
Beispiel #12
0
    protected void btnCreate_Click(object sender, EventArgs e)
    {
        DateTime startDate     = DateTime.Parse(tbStartDate.Text);
        DateTime endDate       = DateTime.Parse(tbEndDate.Text);
        DateTime dateOfPayment = DateTime.Now.AddDays(15);

        if (tbDateOfPayment.Text.Trim() != string.Empty)
        {
            DateTime.TryParse(tbDateOfPayment.Text, out dateOfPayment);
        }
        InsuranceCompany company = InsuranceCompany.Get(int.Parse(ddlInsuranceCompanies.SelectedValue));

        Broker.DataAccess.User u = this.PageUser;

        DateTime fromDate = DateTime.Parse(tbStartDate.Text);
        DateTime toDate   = DateTime.Parse(tbEndDate.Text);
        //List<PolicyItem> piList = PolicyItem.GetFromPreivousMonths(fromDate, company.ID);
        List <FactureInfo>    lastFactureInfos = listNewFactureInfos;
        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(facInfo => facInfo.ID == factureInfoID).SingleOrDefault();
            fi.IsForFacturing = cbIsForFacturing.Checked;
        }
        listNewFactureInfos = lastFactureInfos;
        lastFactureInfos    = listFactureInfos;
        displayedRows       = gvOldPolicies.Rows;
        foreach (GridViewRow gvRow in displayedRows)
        {
            CheckBox    cbIsForFacturing = gvRow.FindControl("cbIsForFacturing") as CheckBox;
            int         factureInfoID    = Convert.ToInt32(gvOldPolicies.DataKeys[gvRow.RowIndex].Value);
            FactureInfo fi = lastFactureInfos.Where(facInfo => facInfo.ID == factureInfoID).SingleOrDefault();
            fi.IsForFacturing = cbIsForFacturing.Checked;
        }
        listFactureInfos = lastFactureInfos;


        List <PolicyItem>  policiesToInclude = new List <PolicyItem>();
        List <FactureInfo> listOldPolicies   = (List <FactureInfo>)listFactureInfos;

        foreach (FactureInfo fi in listOldPolicies)
        {
            if (fi.IsForFacturing)
            {
                policiesToInclude.Add(PolicyItem.Get(fi.ID));
            }
        }
        List <FactureInfo> listNewPolicies = (List <FactureInfo>)listNewFactureInfos;

        foreach (FactureInfo fi in listNewPolicies)
        {
            if (fi.IsForFacturing)
            {
                PolicyItem pi = PolicyItem.Get(fi.ID);
                if (!policiesToInclude.Contains(pi))
                {
                    policiesToInclude.Add(pi);
                }
            }
        }

        AccountFacture f = AccountFacture.Generate(tbAccountFactureNumber.Text, startDate, endDate, company, u, dateOfPayment, policiesToInclude, this.PageBranch);

        if (f != null)
        {
            lblError.Visible = false;
            odsFacturePreview.SelectParameters.Clear();
            odsFacturePreview.SelectParameters.Add("id", f.ID.ToString());
            odsFactureItems.SelectParameters.Clear();
            odsFactureItems.SelectParameters.Add("factureID", f.ID.ToString());
            mvMain.SetActiveView(viewFactureItems);
            GXGridView1SelectedValue = f.ID;
        }
        else
        {
            lblError.Visible   = true;
            lblError.Font.Bold = true;
            lblError.Text      = "Не постојат нефактурирани износи";
        }
    }
Beispiel #13
0
    protected void btnCalculateCurrentState_Click(object sender, EventArgs e)
    {
        DateTime              startDate        = DateTime.Parse(tbStartDate.Text);
        DateTime              endDate          = DateTime.Parse(tbEndDate.Text);
        InsuranceCompany      company          = InsuranceCompany.Get(int.Parse(ddlInsuranceCompanies.SelectedValue));
        DateTime              fromDate         = DateTime.Parse(tbStartDate.Text);
        DateTime              toDate           = DateTime.Parse(tbEndDate.Text);
        List <FactureInfo>    lastFactureInfos = listNewFactureInfos;
        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(facInfo => facInfo.ID == factureInfoID).SingleOrDefault();
            fi.IsForFacturing = cbIsForFacturing.Checked;
        }
        listNewFactureInfos = lastFactureInfos;
        lastFactureInfos    = listFactureInfos;
        displayedRows       = gvOldPolicies.Rows;
        foreach (GridViewRow gvRow in displayedRows)
        {
            CheckBox    cbIsForFacturing = gvRow.FindControl("cbIsForFacturing") as CheckBox;
            int         factureInfoID    = Convert.ToInt32(gvOldPolicies.DataKeys[gvRow.RowIndex].Value);
            FactureInfo fi = lastFactureInfos.Where(facInfo => facInfo.ID == factureInfoID).SingleOrDefault();
            fi.IsForFacturing = cbIsForFacturing.Checked;
        }
        listFactureInfos = lastFactureInfos;

        decimal brokerageValue        = 0;
        decimal totalSum              = 0;
        decimal currentBrokerageValue = 0;

        List <PolicyItem>  policiesToInclude = new List <PolicyItem>();
        List <FactureInfo> listOldPolicies   = (List <FactureInfo>)listFactureInfos;

        foreach (FactureInfo fi in listOldPolicies)
        {
            if (fi.IsForFacturing)
            {
                policiesToInclude.Add(PolicyItem.Get(fi.ID));
            }
        }
        List <FactureInfo> listNewPolicies = (List <FactureInfo>)listNewFactureInfos;

        foreach (FactureInfo fi in listNewPolicies)
        {
            if (fi.IsForFacturing)
            {
                PolicyItem pi = PolicyItem.Get(fi.ID);
                if (!policiesToInclude.Contains(pi))
                {
                    policiesToInclude.Add(pi);
                }
            }
        }

        foreach (PolicyItem policyItem in policiesToInclude)
        {
            if (policyItem.Policy.PacketID != null)
            {
                if (policyItem.Policy.Client.IsLaw)
                {
                    currentBrokerageValue = policyItem.PremiumValue * policyItem.PacketsInsuranceSubType.BrokeragePecentageForLaws / 100;
                }
                else
                {
                    currentBrokerageValue = policyItem.PremiumValue * policyItem.PacketsInsuranceSubType.BrokeragePecentageForPrivates / 100;
                }
            }
            else
            {
                if (policyItem.Policy.Client.IsLaw)
                {
                    currentBrokerageValue = policyItem.PremiumValue * policyItem.Brokerage.PercentageForLaws / 100;
                }
                else
                {
                    currentBrokerageValue = policyItem.PremiumValue * policyItem.Brokerage.PercentageForPrivates / 100;
                }
            }
            brokerageValue += currentBrokerageValue;
            totalSum       += policyItem.PremiumValue;
        }
        tbCurrentBrokerageValue.Text = String.Format("{0:#,0.00}", brokerageValue);
        tbCurrentPremiumValue.Text   = String.Format("{0:#,0.00}", totalSum);
    }