Exemplo n.º 1
0
        private HSN ConvertItemToHSN(DataRow item)
        {
            HSN hsn = new HSN();

            hsn.HSNNumber   = item.Field <string>("HSN");
            hsn.Description = item.Field <string>("Description");
            hsn.RateCGST    = Convert.ToDecimal(item.Field <string>("CGSTRate"));
            hsn.RateIGST    = Convert.ToDecimal(item.Field <string>("IGSTRate"));
            hsn.RateSGST    = Convert.ToDecimal(item.Field <string>("SGSTRate"));
            //hsn.PerUnitRate = Convert.ToDecimal(item.Field<string>("Rate"));
            hsn.UnitOfMeasurement = item.Field <string>("Unit");

            return(hsn);
        }
Exemplo n.º 2
0
        private Seller BindInvoice(DataSet dsInvoice)
        {
            Seller obj = new Seller();

            // Invoice inv = new Invoice();
            obj.CreateInvoice(obj, InvoiceType.B2BInvoice.ToString());
            #region B2B
            if (dsInvoice.Tables.Count > 0)
            {
                if (dsInvoice.Tables.Contains("SellerDtls"))
                {
                    if (dsInvoice.Tables[0].Rows.Count > 0)
                    {
                        //  // lblInvoiceNumber.Text = "Serial No. of Invoice : " + Convert.ToString(ds.Tables[0].Rows[0][0]);
                        //  //  lblInvoiceDate.Text = "Invoice Date : " + Convert.ToString(ds.Tables[0].Rows[0][1]);
                        //  lblSellerGSTIN.Text = "GSTIN : " + Convert.ToString(ds.Tables[0].Rows[0][2]);
                        //  lblSellerName.Text = "Name : " + Convert.ToString(ds.Tables[0].Rows[0][3]);
                        //  //  lblSellerAddress.Text = "Address : " + Convert.ToString(ds.Tables[0].Rows[0][4]);
                        ////  hdnSellerGSTN.Value = Convert.ToString(ds.Tables[0].Rows[0][2]);
                        obj.SellerInvoice = Convert.ToString(ds.Tables[0].Rows[0][0]);
                        obj.DateOfInvoice = Convert.ToString(ds.Tables[0].Rows[0][1]);

                        obj.GSTIN       = Convert.ToString(ds.Tables[0].Rows[0][2]);
                        obj.NameAsOnGST = Convert.ToString(ds.Tables[0].Rows[0][3]);
                        obj.Address     = Convert.ToString(ds.Tables[0].Rows[0][8]);
                        // obj.SellerStateCode = Convert.ToString(ds.Tables[0].Rows[0][6]);
                        obj.SellerStateName = Convert.ToString(ds.Tables[0].Rows[0][10]);


                        obj.Invoice.Freight = Convert.ToDecimal(ds.Tables[0].Rows[0][14]);
                        obj.Invoice.PackingAndForwadingCharges = Convert.ToDecimal(ds.Tables[0].Rows[0][16]);
                    }
                }
                else
                {
                    //lblMsg.Text = "System error occured during data population of SellerDtls table !!!";
                    //this.InvoicePreviewModalPopupExtender.Show();
                    //return;
                }
                if (ds.Tables.Contains("ReceiverDtls"))
                {
                    if (ds.Tables[1].Rows.Count > 0)
                    {
                        Reciever rec = new Reciever();
                        rec.GSTIN       = Convert.ToString(ds.Tables[1].Rows[0][1]);
                        rec.NameAsOnGST = Convert.ToString(ds.Tables[1].Rows[0][2]);
                        rec.Address     = Convert.ToString(ds.Tables[1].Rows[0][3]);
                        rec.StateCode   = Convert.ToString(ds.Tables[1].Rows[0][6]);
                        rec.StateName   = Convert.ToString(ds.Tables[1].Rows[0][5]);
                        obj.Reciever    = rec;
                    }
                }
                else
                {
                    //lblMsg.Text = "System error occured during data population of ReceiverDtls table !!!";
                    //this.InvoicePreviewModalPopupExtender.Show();
                    //return;
                }
                if (ds.Tables.Contains("ConsigneeDtls"))
                {
                    if (ds.Tables[2].Rows.Count > 0)
                    {
                        Consignee con = new Consignee();
                        con.GSTIN       = Convert.ToString(ds.Tables[2].Rows[0][1]);
                        con.NameAsOnGST = Convert.ToString(ds.Tables[2].Rows[0][2]);
                        con.Address     = Convert.ToString(ds.Tables[2].Rows[0][3]);
                        con.StateCode   = Convert.ToString(ds.Tables[2].Rows[0][6]);
                        con.StateName   = Convert.ToString(ds.Tables[2].Rows[0][5]);
                        obj.Consignee   = con;
                    }
                }
                else
                {
                    //lblMsg.Text = "System error occured during data population of ConsigneeDtls table !!!";
                    //this.InvoicePreviewModalPopupExtender.Show();
                    //return;
                }
                if (ds.Tables.Contains("InvoiceDtls"))
                {
                    //LineID,Description,HSN,Qty,Unit,Rate,Total,Discount,AmountWithTax,CGSTRate,CGSTAmt,SGSTRate,SGSTAmt,IGSTRate,IGSTAmt
                    DataTable dt     = ds.Tables["InvoiceDtls"];
                    HSN       hsn    = new HSN();
                    var       leItem = (from item in dt.AsEnumerable()
                                        select new LineEntry
                    {
                        LineID = Convert.ToInt32(item.Field <string>("LineID")),
                        //HSN=item..Select(new HSN{Description})
                        //HSN = new HSN().Description = item.Field<string>("Description"),
                        //HSN = new HSN().HSNNumber = item.Field<string>("HSN"),
                        HSN = ConvertItemToHSN(item),
                        Qty = Convert.ToInt32(item.Field <string>("Qty")),
                        //Unit = Convert.ToInt32(item.Field<string>("Unit")),
                        PerUnitRate = Convert.ToDecimal(item.Field <string>("Rate")),
                        TotalLineIDWise = Convert.ToDecimal(item.Field <string>("Total")),
                        Discount = Convert.ToDecimal(item.Field <string>("Discount")),
                        TaxValue = Convert.ToDecimal(item.Field <string>("TaxableValue")),
                        AmountWithTax = Convert.ToDecimal(item.Field <string>("AmountWithTax")),
                        AmtCGSTLineIDWise = Convert.ToDecimal(item.Field <string>("CGSTAmt")),
                        AmtSGSTLineIDWise = Convert.ToDecimal(item.Field <string>("SGSTAmt")),
                        AmtIGSTLineIDWise = Convert.ToDecimal(item.Field <string>("IGSTAmt"))
                    }).ToList();


                    obj.Invoice.LineEntry = leItem;
                }
                else
                {
                    //lblMsg.Text = "System error occured during data population of InvoiceDtls table !!!";
                    //this.InvoicePreviewModalPopupExtender.Show();
                    //return;
                }
                if (ds.Tables.Contains("AmountDtls"))
                {
                    obj.TotalAmount        = Convert.ToDecimal(ds.Tables[4].Rows[0][6]);
                    obj.TotalDiscount      = Convert.ToDecimal(ds.Tables[4].Rows[0][7]);
                    obj.TotalAmountWithTax = Convert.ToDecimal(ds.Tables[4].Rows[0][8]);
                    obj.TotalCGSTAmount    = Convert.ToDecimal(ds.Tables[4].Rows[0][10]);
                    obj.TotalSGSTAmount    = Convert.ToDecimal(ds.Tables[4].Rows[0][12]);
                    obj.TotalIGSTAmount    = Convert.ToDecimal(ds.Tables[4].Rows[0][14]);

                    if (ds.Tables[4].Rows.Count > 0)
                    {
                        HtmlTableRow tRow = new HtmlTableRow();
                        for (int j = 0; j <= 14; j++)
                        {
                            HtmlTableCell tb = new HtmlTableCell();
                            tb.InnerText = Convert.ToString(ds.Tables[4].Rows[0][j]);
                            tRow.Controls.Add(tb);
                        }
                        tblPreview.Rows.Add(tRow);
                    }
                }
                else
                {
                    //lblMsg.Text = "System error occured during data population of AmountDtls table !!!";
                    //this.InvoicePreviewModalPopupExtender.Show();
                    //return;
                }
                if (ds.Tables.Contains("AmountInWords"))
                {
                    if (ds.Tables[5].Rows.Count > 0)
                    {
                        obj.Invoice.TotalInvoiceValue = Convert.ToDecimal(ds.Tables[5].Rows[0][0]);
                        obj.Invoice.TotalInvoiceWords = Convert.ToString(ds.Tables[5].Rows[0][1]);
                    }
                }
                else
                {
                    //lblMsg.Text = "System error occured during data population of AmountInWords table !!!";
                    //this.InvoicePreviewModalPopupExtender.Show();
                    //return;
                }
            }
            else
            {
                //lblMsg.Text = "System Error !!!";
                //this.InvoicePreviewModalPopupExtender.Show();
                //return;
            }
            return(obj);

            #endregion
        }