Exemplo n.º 1
0
        protected void Button_Create_Inv_Click(object sender, EventArgs e)
        {
            BackEndObjects.Invoice invObj = new BackEndObjects.Invoice();

            invObj.setInvoiceId(new Id().getNewId(BackEndObjects.Id.ID_TYPE_INV_ID_STRING));
            invObj.setRespEntityId(Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString());
            invObj.setInvComments(TextBox_TnC.Text);
            invObj.setInvoiceDate(TextBox_Inv_Date.Text);
            invObj.setDeliveryStatus(BackEndObjects.DeliveryStat.DELIV_STAT_UNDELIVERED);
            invObj.setInvoiceType(BackEndObjects.InvoiceType.INVOICE_TYPE_TAX_INVOICE);
            invObj.setPaymentStatus(BackEndObjects.PaymentStat.PAYMENT_STAT_INCOMPLETE);
            invObj.setPolicyNo(TextBox_Policy_No.Text);
            invObj.setRFQId(Request.QueryString.GetValues("rfId")[0]);
            invObj.setShipVia(TextBox_Ship_Via.Text);
            invObj.setTaxableAmnt(float.Parse(TextBox_Taxable_Amount.Text));
            invObj.setTotalAmount(float.Parse(Label_Total_Amount_Value.Text));
            //For invoice in auto-created mode, the invoice no and invoice id will be same
            invObj.setInvoiceNo(invObj.getInvoiceId());
            invObj.setCreationMode(BackEndObjects.Invoice.INVOICE_CREATION_MODE_AUTO);

            ArrayList invTaxComp = new ArrayList();

            foreach (GridViewRow gVR in GridView_Inv_Tax_Comp.Rows)
            {
                BackEndObjects.InvoiceComponents invCompObj = new BackEndObjects.InvoiceComponents();

                invCompObj.setInvoice_Id(invObj.getInvoiceId());
                invCompObj.setSection_type(BackEndObjects.InvoiceComponents.INVOICE_SECTION_TYPE_TAX);
                invCompObj.setSection_type_name(((Label)gVR.Cells[0].FindControl("Label_Name")).Text);
                invCompObj.setSection_value(((TextBox)gVR.Cells[0].FindControl("TextBox_Value")).Text);

                invTaxComp.Add(invCompObj);
            }

            try
            {
                BackEndObjects.Invoice.insertInvoiceDB(invObj);
                BackEndObjects.InvoiceComponents.insertInvoiceComponentListDB(invTaxComp);
                Label_INV_Creation_Stat.Visible   = true;
                Label_INV_Creation_Stat.ForeColor = System.Drawing.Color.Green;
                Label_INV_Creation_Stat.Text      = "Invoice Created Successfully";
                Label_INV_No.Text         = invObj.getInvoiceId();
                Button_Create_Inv.Enabled = false;
            }
            catch (Exception ex)
            {
                Label_INV_Creation_Stat.Visible   = true;
                Label_INV_Creation_Stat.ForeColor = System.Drawing.Color.Red;
                Label_INV_Creation_Stat.Text      = "Invoice Creation Failed";
            }
        }
Exemplo n.º 2
0
        protected void loadInvTaxCompGrid(String invId)
        {
            String context = Request.QueryString.GetValues("context")[0];

            DataTable dt = new DataTable();

            dt.Columns.Add("Hidden");
            dt.Columns.Add("Comp_Name");
            dt.Columns.Add("Comp_Value");

            DataTable dtComplete = new DataTable();

            dtComplete.Columns.Add("Hidden");
            dtComplete.Columns.Add("Comp_Name");
            dtComplete.Columns.Add("Comp_Value");

            float totalTaxPerc = 0;

            if (invId == null || invId.Equals(""))
            {
                totalTaxPerc = getTotalTaxCompGridandTaxPerc(dt);
                dtComplete   = dt;
            }
            else
            {
                //If invoice was already created populate the tax component values from the invoice component table
                ArrayList invTaxCompList = BackEndObjects.InvoiceComponents.getInvoiceComponentByInvIdandSecType(invId, BackEndObjects.InvoiceComponents.INVOICE_SECTION_TYPE_TAX);

                for (int i = 0; i < invTaxCompList.Count; i++)
                {
                    dt.Rows.Add();

                    BackEndObjects.InvoiceComponents invCompObj = (BackEndObjects.InvoiceComponents)invTaxCompList[i];

                    dt.Rows[i]["Hidden"] = invCompObj.getInvoice_Id();
                    //Component name is the section type name
                    dt.Rows[i]["Comp_Name"]  = invCompObj.getSection_type_name();
                    dt.Rows[i]["Comp_Value"] = invCompObj.getSection_value();

                    totalTaxPerc += float.Parse(invCompObj.getSection_value());
                }
            }

            if (dtComplete.Rows.Count == 0)
            {
                getTotalTaxCompGridandTaxPerc(dtComplete);
            }

            GridView_Inv_Tax_Complete_List.DataSource = dtComplete;
            GridView_Inv_Tax_Complete_List.DataBind();
            GridView_Inv_Tax_Complete_List.Columns[1].Visible = false;



            Session[SessionFactory.ALL_SALE_ALL_POTENTIAL_CREATE_INV_TOTAL_TAX_COMP_GRID] = dtComplete;

            if (dt.Rows.Count > 0)
            {
                GridView_Inv_Tax_Comp.DataSource = dt;
                GridView_Inv_Tax_Comp.DataBind();
                GridView_Inv_Tax_Comp.Visible            = true;
                GridView_Inv_Tax_Comp.Columns[1].Visible = false;

                //Hide the delete link if the context is client
                if (context.Equals("client"))
                {
                    GridView_Inv_Tax_Comp.Columns[0].Visible = false;

                    foreach (GridViewRow gVR in GridView_Inv_Tax_Comp.Rows)
                    {
                        ((TextBox)gVR.Cells[0].FindControl("TextBox_Value")).Enabled = false;
                    }
                }

                Session[SessionFactory.ALL_SALE_ALL_POTENTIAL_CREATE_INV_TAX_COMP_DATA_GRID]  = dt;
                Session[SessionFactory.ALL_SALE_ALL_POTENTIAL_CREATE_INV_TOTAL_TAX_COMP_PERC] = totalTaxPerc;
            }
            else
            {
                Label_No_Tax_Comp_Warning.Visible = true;
                Label_No_Tax_Comp_Warning.Text    = "Tax components for invoice not defined for your organization - set it up from Administration screen";
            }
        }