예제 #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();
            }
        }
    }
예제 #2
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;
        }
    }
예제 #3
0
    protected void btnClientEMBGSearch_Click(object sender, EventArgs e)
    {
        Panel            pnlClient          = PoliciesDetailsView.FindControl("pnlClient") as Panel;
        DetailsView      clientDetailsView  = pnlClient.FindControl("ClientDetailsView") as DetailsView;
        ObjectDataSource clientdvDataSource = pnlClient.FindControl("ClientdvDataSource") as ObjectDataSource;

        if (PoliciesDetailsView.SelectedValue != null)
        {
            int        policyItemID = Convert.ToInt32(PoliciesDetailsView.SelectedValue);
            PolicyItem policyItem   = PolicyItem.Get(policyItemID);
            string     clientEMBG   = policyItem.Policy.Client.EMBG;
            pnlClient.Visible = true;
            clientdvDataSource.SelectParameters.Clear();
            clientdvDataSource.SelectParameters.Add("embg", clientEMBG);
            clientDetailsView.DataBind();
        }
        else
        {
            pnlClient.Visible = false;
            clientdvDataSource.SelectParameters.Clear();
            clientDetailsView.DataBind();
        }
    }
예제 #4
0
 protected void btnUpdate_Click(object sender, EventArgs e)
 {
     if (PoliciesDetailsView.SelectedValue != null)
     {
         int          policyItemID = Convert.ToInt32(PoliciesDetailsView.SelectedValue);
         PolicyItem   policyItem   = PolicyItem.Get(policyItemID);
         DropDownList ddlStatuses  = PoliciesDetailsView.FindControl("ddlStatuses") as DropDownList;
         policyItem.StatusID = Convert.ToInt32(ddlStatuses.SelectedValue);
         Policy  policy            = Policy.Get(policyItem.PolicyID);
         TextBox tbStartDate       = PoliciesDetailsView.FindControl("tbStartDate") as TextBox;
         TextBox tbEndDate         = PoliciesDetailsView.FindControl("tbEndDate") as TextBox;
         TextBox tbApplicationDate = PoliciesDetailsView.FindControl("tbApplicationDate") as TextBox;
         policy.StartDate       = Convert.ToDateTime(tbStartDate.Text);
         policy.EndDate         = Convert.ToDateTime(tbEndDate.Text);
         policy.ApplicationDate = Convert.ToDateTime(tbApplicationDate.Text);
         Policy.Table.Context.SubmitChanges();
         Panel pnlExtendControls = PoliciesDetailsView.FindControl("pnlExtendControls") as Panel;
         List <Broker.DataAccess.Control> listControls = Broker.DataAccess.Control.GetActiveByInsuranceSubType(policyItem.InsuranceSubTypeID);
         foreach (Broker.DataAccess.Control c in listControls)
         {
             PolicyExtendInformation pei = PolicyExtendInformation.GetByPolicyItemAndControl(policyItem.ID, c.ID);
             TextBox           tbControl = (TextBox)pnlExtendControls.FindControl(c.TextBoxID);
             ControlCollection cc        = pnlExtendControls.Controls;
             if (pei != null)
             {
                 pei.Value = tbControl.Text;
                 if (c.HasCompareValidator)
                 {
                     CompareValidator cv = (CompareValidator)pnlExtendControls.FindControl("cv" + c.TextBoxID);
                     if (cv.Type == ValidationDataType.Double)
                     {
                         if (tbControl.Text == string.Empty)
                         {
                             pei.Value = "0";
                         }
                     }
                 }
                 PolicyExtendInformation.Table.Context.SubmitChanges();
             }
             else
             {
                 PolicyExtendInformation newpei = new PolicyExtendInformation();
                 newpei.ControlID    = c.ID;
                 newpei.PolicyItemID = policyItem.ID;
                 newpei.Value        = tbControl.Text;
                 if (c.HasCompareValidator)
                 {
                     CompareValidator cv = (CompareValidator)pnlExtendControls.FindControl("cv" + c.TextBoxID);
                     if (cv.Type == ValidationDataType.Double)
                     {
                         if (tbControl.Text == string.Empty)
                         {
                             pei.Value = "0";
                         }
                     }
                 }
                 pei.Insert();
             }
             btnSearch.Enabled = false;
         }
     }
 }
예제 #5
0
    protected override void CreateChildControls()
    {
        if (PoliciesDetailsView.SelectedValue != null)
        {
            int        policyItemID      = Convert.ToInt32(PoliciesDetailsView.SelectedValue);
            PolicyItem policyItem        = PolicyItem.Get(policyItemID);
            Panel      pnlExtendControls = PoliciesDetailsView.FindControl("pnlExtendControls") as Panel;
            int        j = 0;
            List <Broker.DataAccess.Control> listControls = Broker.DataAccess.Control.GetByInsuranceSubType(policyItem.InsuranceSubTypeID);

            pnlExtendControls.Controls.Clear();
            lblFieldNames = new List <Label>();
            tbValues      = new List <TextBox>();

            HtmlTable titleTable = new HtmlTable();
            titleTable.Width = "695px";
            HtmlTableRow firstTitleTableRow = new HtmlTableRow();
            titleTable.Rows.Add(firstTitleTableRow);
            HtmlTableCell firstCellFirstRowInTitleTable = new HtmlTableCell();
            firstTitleTableRow.Cells.Add(firstCellFirstRowInTitleTable);
            Label lblPremiumBrokerageTitle = new Label();
            lblPremiumBrokerageTitle.ID        = "lblPremiumBrokerageTitle";
            lblPremiumBrokerageTitle.Font.Bold = true;
            lblPremiumBrokerageTitle.Text      = "Премија и брокеража";
            firstCellFirstRowInTitleTable.Controls.Add(lblPremiumBrokerageTitle);
            pnlExtendControls.Controls.Add(titleTable);

            HtmlTable defaultTable = new HtmlTable();
            defaultTable.Width = "695px";

            HtmlTableRow fourthDefaultTableRow = new HtmlTableRow();
            fourthDefaultTableRow.BgColor = "#FAFAF8";
            defaultTable.Rows.Add(fourthDefaultTableRow);
            HtmlTableCell firstCellFourthRowInDefaultTable = new HtmlTableCell();
            firstCellFourthRowInDefaultTable.Width = "160px";
            fourthDefaultTableRow.Cells.Add(firstCellFourthRowInDefaultTable);
            Label lblPolicyValue = new Label();
            lblPolicyValue.ID   = "lblPolicyValue" + (j + 1).ToString();
            lblPolicyValue.Text = "Премија";
            firstCellFourthRowInDefaultTable.Controls.Add(lblPolicyValue);
            HtmlTableCell secondCellFourthRowInDefaultTable = new HtmlTableCell();
            secondCellFourthRowInDefaultTable.Width = "187px";
            fourthDefaultTableRow.Cells.Add(secondCellFourthRowInDefaultTable);
            TextBox tbPolicyValue = new TextBox();
            tbPolicyValue.ID           = "tbPolicyValue" + (j + 1).ToString();
            tbPolicyValue.AutoPostBack = true;
            tbPolicyValue.Text         = policyItem.PremiumValue.ToString();
            tbPolicyValue.ReadOnly     = true;

            tbPolicyValue.TextChanged += new EventHandler(tbPolicyValue_TextChanged);
            RequiredFieldValidator rfvPolicyValue = new RequiredFieldValidator();
            rfvPolicyValue.ID                = "rfvPolicyValue" + (j + 1).ToString();
            rfvPolicyValue.ErrorMessage      = "*";
            rfvPolicyValue.Display           = ValidatorDisplay.Dynamic;
            rfvPolicyValue.ControlToValidate = tbPolicyValue.ID;
            CompareValidator cvPolicyValue = new CompareValidator();
            cvPolicyValue.ID                = "cvPolicyValue" + (j + 1).ToString();
            cvPolicyValue.ErrorMessage      = "*";
            cvPolicyValue.Display           = ValidatorDisplay.Dynamic;
            cvPolicyValue.ControlToValidate = tbPolicyValue.ID;
            cvPolicyValue.Operator          = ValidationCompareOperator.DataTypeCheck;
            cvPolicyValue.Type              = ValidationDataType.Double;
            secondCellFourthRowInDefaultTable.Controls.Add(tbPolicyValue);
            secondCellFourthRowInDefaultTable.Controls.Add(rfvPolicyValue);
            secondCellFourthRowInDefaultTable.Controls.Add(cvPolicyValue);
            HtmlTableCell thirdCellFourthRowInDefaultTable = new HtmlTableCell();
            thirdCellFourthRowInDefaultTable.Width = "160px";
            fourthDefaultTableRow.Cells.Add(thirdCellFourthRowInDefaultTable);
            HtmlTableCell fourthCellFourthRowInDefaultTable = new HtmlTableCell();
            fourthCellFourthRowInDefaultTable.Width = "187px";
            fourthDefaultTableRow.Cells.Add(fourthCellFourthRowInDefaultTable);

            HtmlTableRow fifthDefaultTableRow = new HtmlTableRow();
            defaultTable.Rows.Add(fifthDefaultTableRow);
            HtmlTableCell firstCellFifthRowInDefaultTable = new HtmlTableCell();
            firstCellFifthRowInDefaultTable.Width = "160px";
            fifthDefaultTableRow.Cells.Add(firstCellFifthRowInDefaultTable);
            Label lblBrokeragePercentage = new Label();
            lblBrokeragePercentage.ID   = "lblBrokeragePercentage" + (j + 1).ToString();
            lblBrokeragePercentage.Text = "Процент на брокеража";
            firstCellFifthRowInDefaultTable.Controls.Add(lblBrokeragePercentage);
            HtmlTableCell secondCellFifthRowInDefaultTable = new HtmlTableCell();
            secondCellFifthRowInDefaultTable.Width = "187px";
            fifthDefaultTableRow.Cells.Add(secondCellFifthRowInDefaultTable);
            TextBox tbBrokeragePercentage = new TextBox();
            tbBrokeragePercentage.ID       = "tbBrokeragePercentage" + (j + 1).ToString();
            tbBrokeragePercentage.Text     = policyItem.BrokeragePercentage.ToString();
            tbBrokeragePercentage.ReadOnly = true;
            secondCellFifthRowInDefaultTable.Controls.Add(tbBrokeragePercentage);
            HtmlTableCell thirdCellFifthRowInDefaultTable = new HtmlTableCell();
            thirdCellFifthRowInDefaultTable.Width = "160px";
            fifthDefaultTableRow.Cells.Add(thirdCellFifthRowInDefaultTable);
            HtmlTableCell fourthCellFifthRowInDefaultTable = new HtmlTableCell();
            fourthCellFifthRowInDefaultTable.Width = "187px";
            fifthDefaultTableRow.Cells.Add(fourthCellFifthRowInDefaultTable);

            HtmlTableRow sixthDefaultTableRow = new HtmlTableRow();
            sixthDefaultTableRow.BgColor = "#FAFAF8";
            defaultTable.Rows.Add(sixthDefaultTableRow);
            HtmlTableCell firstCellSixthRowInDefaultTable = new HtmlTableCell();
            firstCellSixthRowInDefaultTable.Width = "160px";
            sixthDefaultTableRow.Cells.Add(firstCellSixthRowInDefaultTable);
            Label lblBrokerageValue = new Label();
            lblBrokerageValue.ID   = "lblBrokerageValue" + (j + 1).ToString();
            lblBrokerageValue.Text = "Брокеража";
            firstCellSixthRowInDefaultTable.Controls.Add(lblBrokerageValue);
            HtmlTableCell secondCellSixthRowInDefaultTable = new HtmlTableCell();
            secondCellSixthRowInDefaultTable.Width = "187px";
            sixthDefaultTableRow.Cells.Add(secondCellSixthRowInDefaultTable);
            TextBox tbBrokerageValue = new TextBox();
            tbBrokerageValue.ID       = "tbBrokerageValue" + (j + 1).ToString();
            tbBrokerageValue.ReadOnly = true;
            tbBrokerageValue.Text     = policyItem.BrokerageValue.ToString();
            secondCellSixthRowInDefaultTable.Controls.Add(tbBrokerageValue);
            HtmlTableCell thirdCellSixthRowInDefaultTable = new HtmlTableCell();
            thirdCellSixthRowInDefaultTable.Width = "160px";
            sixthDefaultTableRow.Cells.Add(thirdCellSixthRowInDefaultTable);
            HtmlTableCell fourthCellSixthRowInDefaultTable = new HtmlTableCell();
            fourthCellSixthRowInDefaultTable.Width = "187px";
            sixthDefaultTableRow.Cells.Add(fourthCellSixthRowInDefaultTable);

            pnlExtendControls.Controls.Add(defaultTable);

            HtmlTable titlePolicyTable = new HtmlTable();
            titlePolicyTable.Width = "695px";
            HtmlTableRow firstTitlePolicyTableRow = new HtmlTableRow();
            titlePolicyTable.Rows.Add(firstTitlePolicyTableRow);
            HtmlTableCell firstCellFirstRowInTitlePolicyTable = new HtmlTableCell();
            firstTitlePolicyTableRow.Cells.Add(firstCellFirstRowInTitlePolicyTable);
            Label lblPolicyDetailsTitle = new Label();
            lblPolicyDetailsTitle.ID        = "lblPolicyDetailsTitle";
            lblPolicyDetailsTitle.Font.Bold = true;
            lblPolicyDetailsTitle.Text      = "Детални информации за полиса";
            firstCellFirstRowInTitlePolicyTable.Controls.Add(lblPolicyDetailsTitle);
            pnlExtendControls.Controls.Add(titlePolicyTable);

            HtmlTable table = new HtmlTable();
            table.Width = "695px";
            int counter = 0;
            foreach (Broker.DataAccess.Control c in listControls)
            {
                if (c.IsActive)
                {
                    PolicyExtendInformation policyExtendInformation = PolicyExtendInformation.GetByPolicyItemAndControl(policyItem.ID, c.ID);
                    if (listControls.Count == 1)
                    {
                        HtmlTableRow tableRow = new HtmlTableRow();
                        tableRow.BgColor = "#FAFAF8";
                        table.Rows.Add(tableRow);
                        HtmlTableCell tableCell = new HtmlTableCell();
                        tableCell.Width = "160px";
                        tableRow.Cells.Add(tableCell);
                        Label label = new Label();
                        label.ID   = c.LabelID;
                        label.Text = c.LabelName;
                        lblFieldNames.Add(label);
                        tableCell.Controls.Add(label);
                        HtmlTableCell tableCellSecond = new HtmlTableCell();
                        tableCellSecond.Width = "187px";
                        tableRow.Cells.Add(tableCellSecond);
                        TextBox textbox = new TextBox();
                        textbox.ID = c.TextBoxID;
                        if (policyExtendInformation != null)
                        {
                            textbox.Text = policyExtendInformation.Value;
                        }
                        if (c.IsLatin != null)
                        {
                            if ((bool)c.IsLatin == true)
                            {
                                textbox.Attributes.Add("onkeyup", "toEnglish(this.id)");
                            }
                        }
                        tbValues.Add(textbox);
                        tableCellSecond.Controls.Add(textbox);
                        if (c.HasRequredFieldValidator)
                        {
                            RequiredFieldValidator rfv = new RequiredFieldValidator();
                            rfv.ID                = "rfv" + textbox.ID;
                            rfv.ErrorMessage      = "*";
                            rfv.Display           = ValidatorDisplay.Dynamic;
                            rfv.ControlToValidate = textbox.ID;
                            tableCellSecond.Controls.Add(rfv);
                        }
                        if (c.HasCompareValidator)
                        {
                            CompareValidator cv = new CompareValidator();
                            cv.ID                = "cv" + textbox.ID;
                            cv.ErrorMessage      = "*";
                            cv.Display           = ValidatorDisplay.Dynamic;
                            cv.ControlToValidate = textbox.ID;
                            cv.Operator          = ValidationCompareOperator.DataTypeCheck;
                            cv.Type              = Broker.DataAccess.VariableType.GetForVariableType(c.VariableTypeID);
                            tableCellSecond.Controls.Add(cv);
                        }
                        HtmlTableCell tableCellThird = new HtmlTableCell();
                        tableCellThird.Width = "160px";
                        tableRow.Cells.Add(tableCellThird);
                        HtmlTableCell tableCellForth = new HtmlTableCell();
                        tableCellForth.Width = "187px";
                        tableRow.Cells.Add(tableCellForth);
                    }
                    else
                    {
                        if (counter % 2 == 0)
                        {
                            HtmlTableRow tableRow = new HtmlTableRow();
                            if ((counter % 4 == 0) || (counter % 4 == 1))
                            {
                                tableRow.BgColor = "#FAFAF8";
                            }
                            table.Rows.Add(tableRow);
                            HtmlTableCell tableCell = new HtmlTableCell();
                            tableCell.Width = "160px";
                            tableRow.Cells.Add(tableCell);
                            Label label = new Label();
                            label.ID   = c.LabelID;
                            label.Text = c.LabelName;
                            lblFieldNames.Add(label);
                            tableCell.Controls.Add(label);
                            HtmlTableCell tableCellSecond = new HtmlTableCell();
                            tableCellSecond.Width = "187px";
                            tableRow.Cells.Add(tableCellSecond);
                            TextBox textbox = new TextBox();
                            textbox.ID = c.TextBoxID;
                            if (policyExtendInformation != null)
                            {
                                textbox.Text = policyExtendInformation.Value;
                            }
                            if (c.IsLatin != null)
                            {
                                if ((bool)c.IsLatin == true)
                                {
                                    textbox.Attributes.Add("onkeyup", "toEnglish(this.id)");
                                }
                            }
                            tbValues.Add(textbox);
                            tableCellSecond.Controls.Add(textbox);
                            if (c.HasRequredFieldValidator)
                            {
                                RequiredFieldValidator rfv = new RequiredFieldValidator();
                                rfv.ID                = "rfv" + textbox.ID;
                                rfv.ErrorMessage      = "*";
                                rfv.Display           = ValidatorDisplay.Dynamic;
                                rfv.ControlToValidate = textbox.ID;
                                tableCellSecond.Controls.Add(rfv);
                            }
                            if (c.HasCompareValidator)
                            {
                                CompareValidator cv = new CompareValidator();
                                cv.ID                = "cv" + textbox.ID;
                                cv.ErrorMessage      = "*";
                                cv.Display           = ValidatorDisplay.Dynamic;
                                cv.ControlToValidate = textbox.ID;
                                cv.Operator          = ValidationCompareOperator.DataTypeCheck;
                                cv.Type              = Broker.DataAccess.VariableType.GetForVariableType(c.VariableTypeID);
                                tableCellSecond.Controls.Add(cv);
                            }
                        }
                        else if (counter % 2 == 1)
                        {
                            HtmlTableRow tableRow = table.Rows[counter / 2];
                            if ((counter % 4 == 0) || (counter % 4 == 1))
                            {
                                tableRow.BgColor = "#FAFAF8";
                            }
                            HtmlTableCell tableCellThird = new HtmlTableCell();
                            tableCellThird.Width = "160px";
                            tableRow.Cells.Add(tableCellThird);
                            Label label = new Label();
                            label.ID   = c.LabelID;
                            label.Text = c.LabelName;
                            lblFieldNames.Add(label);
                            tableCellThird.Controls.Add(label);
                            HtmlTableCell tableCellForth = new HtmlTableCell();
                            tableCellForth.Width = "187px";
                            tableRow.Cells.Add(tableCellForth);
                            TextBox textbox = new TextBox();
                            textbox.ID = c.TextBoxID;
                            if (policyExtendInformation != null)
                            {
                                textbox.Text = policyExtendInformation.Value;
                            }
                            if (c.IsLatin != null)
                            {
                                if ((bool)c.IsLatin)
                                {
                                    textbox.Attributes.Add("onkeyup", "toEnglish(this.id)");
                                }
                            }
                            tbValues.Add(textbox);
                            tableCellForth.Controls.Add(textbox);
                            if (c.HasRequredFieldValidator)
                            {
                                RequiredFieldValidator rfv = new RequiredFieldValidator();
                                rfv.ID                = "rfv" + textbox.ID;
                                rfv.ErrorMessage      = "*";
                                rfv.Display           = ValidatorDisplay.Dynamic;
                                rfv.ControlToValidate = textbox.ID;
                                tableCellForth.Controls.Add(rfv);
                            }
                            if (c.HasCompareValidator)
                            {
                                CompareValidator cv = new CompareValidator();
                                cv.ID                = "cv" + textbox.ID;
                                cv.ErrorMessage      = "*";
                                cv.Display           = ValidatorDisplay.Dynamic;
                                cv.ControlToValidate = textbox.ID;
                                cv.Operator          = ValidationCompareOperator.DataTypeCheck;
                                cv.Type              = Broker.DataAccess.VariableType.GetForVariableType(c.VariableTypeID);
                                tableCellForth.Controls.Add(cv);
                            }
                        }
                    }
                    counter++;
                }
            }
            pnlExtendControls.Controls.Add(table);
        }
    }
예제 #6
0
        public static void PrintAnex(Broker.DataAccess.Facture f)
        {
            List <PolicyItemFactureItem> lstPIFI = PolicyItemFactureItem.GetByFactureID(f.ID);
            PDFCreators creator = new PDFCreators(true, 25, 25, 15, 15);

            creator.SetDocumentHeaderFooter();
            creator.OpenPDF();
            creator.GetContentByte();
            creator.AddJDBLogoForFactures(10, 775);
            creator.SetTitleLeft8(" ");
            creator.SetTitleLeft8(" ");
            creator.SetTitleLeft8(" ");
            creator.SetTitleLeft8(" ");
            if (f.DocumentSubType.Code == Broker.DataAccess.DocumentSubType.FAKTURA_PROVIZIJA)
            {
                creator.SetTitleLeft8("   Жиро-сметка :  " + Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.ZIRO_SMETKA_ZA_OSIG_KOMPANII).Value);
            }
            else if (f.DocumentSubType.Code == DocumentSubType.FAKTURA_KLIENT)
            {
                creator.SetTitleLeft8("   Жиро-сметка :  " + Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.ZIRO_SMETKA).Value);
            }
            creator.SetTitleLeft8("   Депонент :  " + Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.DEPONENT).Value);
            creator.SetTitleLeft8("   ЕДБ :   " + Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.EDB).Value + "       " + "Матичен број :  " + Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.MATICEN_BROJ).Value);
            creator.SetTitleLeft8("  ");
            creator.SetTitleLeft8("Договорувач " + f.Client.Name + "                                                                                                             " + "Експозитура " + f.User.Branch.Name);
            creator.SetTitleLeft8("  ");
            creator.SetTitle("ДОГОВОР " + f.FactureNumber);
            creator.SetTitle("за плаќање на должна премија за осигурување");
            creator.SetTitle("(плаќање на рати)");
            creator.SetTitleLeft8("  ");
            creator.SetTitleLeft8("  ");
            creator.SetTitleLeft8("1.Премијата за осигурување ќе се плати на рати, како што следи:");
            string[]   headersRates          = { "Реден број", "Рок за плаќање", "Полиса", "Фактура број", "Износ" };
            float[]    widthPercentagesRates = { 10, 25, 25, 20, 20 };
            TypeCode[] typeCodesRates        = { TypeCode.Int32, TypeCode.String, TypeCode.String, TypeCode.String, TypeCode.Decimal };
            creator.CreateTable_Facture(headersRates.Length, headersRates, widthPercentagesRates);
            List <Rate> ratesForPrint = new List <Rate>();

            foreach (FactureItem fi in f.FactureItems)
            {
                List <PolicyItemFactureItem> list = lstPIFI.Where(p => p.FactureItemID == fi.ID).ToList();
                foreach (PolicyItemFactureItem pifi in list)
                {
                    string      polNumber = PolicyItem.Get(pifi.PolicyItemID).PolicyNumber;
                    List <Rate> rates     = Rate.GetByPolicyItemID(pifi.PolicyItemID);
                    rates = rates.OrderBy(c => c.Number).ToList();
                    ratesForPrint.AddRange(rates);
                }
            }
            ratesForPrint = ratesForPrint.OrderBy(c => c.Date).ToList();
            int counter = 1;

            foreach (Rate r in ratesForPrint)
            {
                object[] valuesRates = new object[headersRates.Length];
                valuesRates[0] = counter;
                valuesRates[1] = r.Date.ToShortDateString();
                valuesRates[2] = r.PolicyItem.PolicyNumber;
                valuesRates[3] = f.FactureNumber;
                valuesRates[4] = String.Format("{0:#,0.00}", r.Value) + " ДЕН.";
                creator.AddDataRowForFactures(valuesRates, headersRates.Length, typeCodesRates);
                counter++;
            }
            object[] values = new object[headersRates.Length];
            values[0] = "";
            values[1] = "";
            values[2] = "";
            values[3] = "Вкупно";
            values[4] = String.Format("{0:#,0.00}", f.TotalCost) + " ДЕН.";
            creator.AddDataRowForFactures(values, headersRates.Length, typeCodesRates);
            creator.AddTable();
            creator.SetTitleLeft8("2.Доколку настане осигуран случај - штета, независно од тоа што е договорено плаќање на рати, премијата за осигурување стасува за наплата веднаш до висината на надоместокот што треба да се исплати и ќе се наплати по пат на компензација.");
            creator.SetTitleLeft8("3.Ако премијата не се плати во договорените рокови од овој Договор, ќе се пресметува камата.");
            creator.SetTitleLeft8("4.Договорот е составен од три еднообразни примероци, од кои еден за осигуреникот, а два за осигурувачот.");
            creator.SetTitle(" ");
            creator.SetTitle(" ");
            creator.SetTitleCenter8("Во " + f.User.Branch.Municipality.Name + " на " + f.DateOfCreation.ToShortDateString());
            creator.SetTitle(" ");
            creator.SetTitle(" ");
            string brokerName = BrokerHouseInformation.GetBrokerHouseName();

            creator.SetTitleLeft8("         " + brokerName + "                                                                                                                           ДОГОВОРУВАЧ");
            creator.SetTitleLeft8(" ");
            creator.SetTitleLeft8("_________________________                                                                                                           ____________________");
            creator.FinishPDF_FileName("Aneks" + f.FactureNumber);
        }
예제 #7
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      = "Не постојат нефактурирани износи";
            }
        }
    }
예제 #8
0
    protected void btnCreate_Click(object sender, EventArgs e)
    {
        DateTime fromDate           = DateTime.Parse(tbFromDate.Text);
        DateTime toDate             = DateTime.Parse(tbToDate.Text);
        int      insuranceCompanyID = Convert.ToInt32(ddlInsuranceCompanies.SelectedValue);
        List <PolicyForSlipsInfo> lastPolicyForSlipsInfos = listPolicyForSlipsInfos;
        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);
            PolicyForSlipsInfo pfsi             = lastPolicyForSlipsInfos.Where(f => f.ID == factureInfoID).SingleOrDefault();
            pfsi.IsForFacturing = cbIsForFacturing.Checked;
        }
        listPolicyForSlipsInfos = lastPolicyForSlipsInfos;
        List <PolicyForSlipsInfo> listFactureInfo = listPolicyForSlipsInfos.Where(c => c.IsForFacturing == true).ToList();

        if (listFactureInfo.Count > 0)
        {
            BrokerageSlip bs = new BrokerageSlip();
            bs.BasisForCompensation = tbBasisForCompensation.Text;
            bs.Date               = DateTime.Today;
            bs.Description        = tbDescription.Text;
            bs.FromDate           = fromDate;
            bs.InsuranceCompanyID = insuranceCompanyID;
            bs.InsuranceRisks     = tbInsuranceRisks.Text;
            bs.InsuranceThings    = tbInsuranceThings.Text;
            if (listFactureInfo.Count == 1)
            {
                PolicyItem tmpPol = PolicyItem.Get(listFactureInfo[0].ID);
                if (tmpPol != null)
                {
                    bs.Insurer = tmpPol.Policy.Client1.Name;
                }
                else
                {
                    bs.Insurer = "ПО ПРИЛОГ ПОЛИСИ";
                }
            }
            else
            {
                bs.Insurer = "ПО ПРИЛОГ ПОЛИСИ";
            }
            bs.Number          = BrokerageSlip.GetNextNumber(insuranceCompanyID);
            bs.OtherConditions = tbOtherConditions.Text;
            bs.ToDate          = toDate;
            bs.Insert();
            Dictionary <int, List <decimal> > dic = new Dictionary <int, List <decimal> >();
            foreach (PolicyForSlipsInfo pfsi in listFactureInfo)
            {
                if (!dic.Keys.Contains(pfsi.InsuranceSubTypeID))
                {
                    List <decimal> brokPercentages = new List <decimal>();
                    if (pfsi.BrokerageID != null)
                    {
                        Brokerage brokerage = Brokerage.Get(pfsi.BrokerageID);
                        brokPercentages.Add(brokerage.PercentageForPrivates);
                        brokPercentages.Add(brokerage.PercentageForLaws);
                    }
                    else if (pfsi.PacketBrokerageID != null)
                    {
                        PacketsInsuranceSubType pist = PacketsInsuranceSubType.Get(pfsi.PacketBrokerageID);
                        brokPercentages.Add(pist.BrokeragePecentageForPrivates);
                        brokPercentages.Add(pist.BrokeragePecentageForLaws);
                    }
                    dic.Add(pfsi.InsuranceSubTypeID, brokPercentages);
                }
                BrokerageSlipPolicyItem bspi = new BrokerageSlipPolicyItem();
                bspi.BrokerageSlipID = bs.ID;
                bspi.PolicyItemID    = pfsi.ID;
                bspi.Insert();
                PolicyItem pItem = PolicyItem.Get(pfsi.ID);
                pItem.IsBrokerageSliped = true;
                PolicyItem.Table.Context.SubmitChanges();
            }
            foreach (KeyValuePair <int, List <decimal> > kvPair in dic)
            {
                BrokerageSlipInsuranceSubType bsist = new BrokerageSlipInsuranceSubType();
                bsist.BrokerageSlipID             = bs.ID;
                bsist.BrokeragePercentagePrivates = kvPair.Value[0];
                bsist.BrokeragePercentageLaws     = kvPair.Value[1];
                bsist.InsuranceSubTypeID          = kvPair.Key;
                bsist.Insert();
            }

            btnPrBrokSlip.Enabled        = true;
            ViewState["BrokerageSlipID"] = bs.ID;
            GXGridView1SelectedValue     = bs.ID;
        }
    }
예제 #9
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")
        {
        }
    }
예제 #10
0
        public static string DeletePolicy(int piID)
        {
            DataClassesDataContext dc = new DataClassesDataContext();
            string       retString    = "Полисата е избришана.";
            PolicyItem   pi           = PolicyItem.Get(piID);
            Distribution d            = Distribution.GetByNumberAndSubTypeAndCompany(pi.InsuranceSubTypeID, pi.PolicyNumber, pi.Policy.InsuranceCompanyID);
            Policy       p            = Policy.Get(pi.PolicyID);
            List <RollBackDistributionItem> listRDI = RollBackDistributionItem.Table.Where(c => c.PolicyItemID == pi.ID).ToList();

            if (listRDI.Count > 0)
            {
                retString = "Полисата е раздолжена и не може да се брише!";
                return(retString);
            }

            List <Rate> lstRates = Rate.GetByPolicyItemID(pi.ID);

            if (lstRates.Count > 0)
            {
                List <Payment> lstPayments = Payment.GetByRateID(lstRates[0].ID);
                if (lstPayments.Count > 0)
                {
                    if (lstPayments[0].IsFactured)
                    {
                        retString = "Полисата е фактурирана за брокеража и не може да се брише!";
                        return(retString);
                    }
                }
                foreach (Rate r in lstRates)
                {
                    List <Payment> lstP = Payment.GetByRateID(r.ID);
                    foreach (Payment pay in lstP)
                    {
                        List <PaymentsPerInsSubType> lstPPIST = PaymentsPerInsSubType.GetByPayment(pay.ID);
                        foreach (PaymentsPerInsSubType ppist in lstPPIST)
                        {
                            string queryppist = @"DELETE FROM PaymentsPerInsSubTypes WHERE ID = " + ppist.ID;
                            dc.ExecuteCommand(queryppist);
                            //ppist.Delete();
                        }
                        string queryppay = @"DELETE FROM Payments WHERE ID = " + pay.ID;
                        dc.ExecuteCommand(queryppay);
                        //pay.Delete();
                    }
                    string queryr = @"DELETE FROM Rates WHERE ID = " + r.ID;
                    dc.ExecuteCommand(queryr);
                    //r.Delete();
                }
                string querypei = @"DELETE FROM PolicyExtendInformations WHERE PolicyItemID = " + pi.ID;
                dc.ExecuteCommand(querypei);
                Broker.DataAccess.Facture facture = PolicyItemFactureItem.GetByPolicyItemID(pi.ID);
                if (facture != null)
                {
                    List <Broker.DataAccess.FactureItem> listFI = FactureItem.GetByFacture(facture.ID);
                    foreach (FactureItem fi in listFI)
                    {
                        string querypifi = @"DELETE FROM PolicyItemFactureItems WHERE FactureItemID = " + fi.ID;
                        dc.ExecuteCommand(querypifi);
                        string queryfi = @"DELETE FROM FactureItems WHERE ID = " + fi.ID;
                        dc.ExecuteCommand(queryfi);
                    }
                    string queryf = @"DELETE FROM Factures WHERE ID = " + facture.ID;
                    dc.ExecuteCommand(queryf);
                }

                string querypi = @"DELETE FROM PolicyItems WHERE ID = " + pi.ID;
                dc.ExecuteCommand(querypi);
                //pi.Delete();
                string queryp = @"DELETE FROM Policies WHERE ID = " + p.ID;
                dc.ExecuteCommand(queryp);
                //p.Delete();
                string queryd = @"UPDATE Distributions SET IsUsed = 0 WHERE ID = " + d.ID;
                dc.ExecuteCommand(queryd);
                //d.IsUsed = false;
                //Distribution.Table.Context.SubmitChanges();
            }

            return(retString);
        }
예제 #11
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      = "Не постојат нефактурирани износи";
        }
    }
예제 #12
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);
    }
예제 #13
0
        public static void PrintFinCardByPaidDates(DateTime fromDate, DateTime toDate, List <int> lstBranhces,
                                                   List <int> lstInsuranceCompanies, List <int> lstInsuranceSubTypes, List <int> lstUsers, List <int> lstMarketingAgents)
        {
            string      brokerName = BrokerHouseInformation.GetBrokerHouseName();
            PDFCreators creator    = new PDFCreators(true, 25, 25, 15, 15);

            creator.SetDocumentHeaderFooter();
            creator.OpenPDF();
            creator.GetContentByte();
            creator.AddJDBLogoForFactures(10, 775);
            creator.SetTitleLeft8(" ");
            creator.SetTitleLeft8(" ");
            creator.SetTitleLeft8(" ");
            creator.SetTitle("ФИНАНСОВА КАРТИЦА");
            creator.SetTitle("по датум на доспевање и уплата");
            creator.SetTitle("за период " + fromDate.ToShortDateString() + " - " + toDate.ToShortDateString());
            creator.SetTitleLeft10("Датум на печатење: " + DateTime.Today.ToShortDateString());

            decimal overallSaldo  = 0;
            decimal overallDebt   = 0;
            decimal overallDemand = 0;

            List <FinanceCardInfo> lstFCIByRates = FinanceCardController.GetByRateInPeriod(fromDate, toDate, lstBranhces, lstInsuranceCompanies,
                                                                                           lstInsuranceSubTypes, lstUsers, lstMarketingAgents);
            List <FinanceCardInfo> lstFCIByPayments = FinanceCardController.GetByPaymentInPeriod(fromDate, toDate, lstBranhces, lstInsuranceCompanies,
                                                                                                 lstInsuranceSubTypes, lstUsers, lstMarketingAgents);
            HashSet <int> lstPolicyIDs = new HashSet <int>();

            foreach (FinanceCardInfo fciR in lstFCIByRates)
            {
                if (!lstPolicyIDs.Contains(fciR.PolicyItemID))
                {
                    lstPolicyIDs.Add(fciR.PolicyItemID);
                }
            }
            foreach (FinanceCardInfo fciP in lstFCIByPayments)
            {
                if (!lstPolicyIDs.Contains(fciP.PolicyItemID))
                {
                    lstPolicyIDs.Add(fciP.PolicyItemID);
                }
            }

            foreach (int piID in lstPolicyIDs)
            {
                PolicyItem pi = PolicyItem.Get(piID);
                creator.SetTitleLeft10("Број на полиса: " + pi.Policy.PolicyItems[0].PolicyNumber);
                creator.SetTitleLeft10("Осигурителна компанија: " + pi.Policy.InsuranceCompany.ShortName);
                creator.SetTitleLeft10("Подкласа на осигурување: " + pi.Policy.PolicyItems[0].InsuranceSubType.ShortDescription);
                creator.SetTitleLeft10("Датум на полиса: " + pi.Policy.ApplicationDate.ToShortDateString());
                //decimal totalSaldo = 0;
                decimal totalDebtValue        = 0;
                decimal totalDemandValue      = 0;
                List <FinanceCardInfo> lst    = new List <FinanceCardInfo>();
                List <FinanceCardInfo> lstRat = lstFCIByRates.Where(c => c.PolicyItemID == piID).ToList();
                List <FinanceCardInfo> lstPay = lstFCIByPayments.Where(c => c.PolicyItemID == piID).ToList();
                if (lstRat != null)
                {
                    if (lstRat.Count > 0)
                    {
                        lst.AddRange(lstRat);
                    }
                }
                if (lstPay != null)
                {
                    if (lstPay.Count > 0)
                    {
                        lst.AddRange(lstPay);
                    }
                }
                for (int i = 0; i < lst.Count; i++)
                {
                    if (i == 0)
                    {
                        lst[i].SaldoValue = lst[i].DebtValue - lst[i].DemandValue;
                    }
                    if (i > 0)
                    {
                        lst[i].SaldoValue = lst[i - 1].SaldoValue + (lst[i].DebtValue - lst[i].DemandValue);
                    }
                }
                string[]   headers          = { "Дата", "Доспева", "Опис", "Должи", "Побарува", "Салдо" };
                float[]    widthPercentages = { 10, 10, 35, 15, 15, 15 };
                TypeCode[] typeCodes        = { TypeCode.String, TypeCode.String, TypeCode.String, TypeCode.Decimal, TypeCode.Decimal, TypeCode.Decimal };
                creator.CreateTable_Facture(headers.Length, headers, widthPercentages);
                foreach (FinanceCardInfo fci in lst)
                {
                    object[] values;
                    values            = new object[headers.Length];
                    values[0]         = fci.DocumentDate.ToShortDateString();
                    values[1]         = fci.PaidDate.ToShortDateString();
                    values[2]         = fci.Description;
                    values[3]         = String.Format("{0:#,0.00}", fci.DebtValue);
                    values[4]         = String.Format("{0:#,0.00}", fci.DemandValue);
                    values[5]         = String.Format("{0:#,0.00}", fci.SaldoValue);
                    totalDebtValue   += fci.DebtValue;
                    totalDemandValue += fci.DemandValue;
                    //totalSaldo += fci.SaldoValue;
                    creator.AddDataRowForFactures(values, headers.Length, typeCodes);
                }
                object[] valuesTot;
                valuesTot      = new object[headers.Length];
                valuesTot[0]   = "";
                valuesTot[1]   = "";
                valuesTot[2]   = "";
                valuesTot[3]   = String.Format("{0:#,0.00}", totalDebtValue);
                valuesTot[4]   = String.Format("{0:#,0.00}", totalDemandValue);
                valuesTot[5]   = String.Format("{0:#,0.00}", totalDebtValue - totalDemandValue);
                overallSaldo  += (totalDebtValue - totalDemandValue);
                overallDemand += totalDemandValue;
                overallDebt   += totalDebtValue;
                creator.AddDataRowForFactures(valuesTot, headers.Length, typeCodes);
                creator.AddTable();
            }
            creator.SetTitleRight("Должи: " + String.Format("{0:#,0.00}", overallDebt) + "  Побарува: " + String.Format("{0:#,0.00}", overallDemand) + "  Салдо: " + String.Format("{0:#,0.00}", (overallDebt - overallDemand)));
            creator.FinishPDF_FileName("FinCard");
        }