示例#1
0
文件: Mapper.cs 项目: SJ-E/AMDSystems
 public static ip_quote_items MapUpdate(IPQuoteItemsModel iPQuoteItemsModel, ip_quote_items ipQuoteItemsDB)
 {
     ipQuoteItemsDB.item_description     = iPQuoteItemsModel.item_description == null?"": iPQuoteItemsModel.item_description;
     ipQuoteItemsDB.item_discount_amount = iPQuoteItemsModel.item_discount_amount == null?0: iPQuoteItemsModel.item_discount_amount;
     ipQuoteItemsDB.item_quantity        = iPQuoteItemsModel.item_quantity == null?0: iPQuoteItemsModel.item_quantity;
     return(ipQuoteItemsDB);
 }
示例#2
0
文件: Mapper.cs 项目: SJ-E/AMDSystems
 public static ip_quote_items Map(IPQuoteItemsModel iPQuoteItemsModel, ip_quote_items ipQuoteItemsDB)
 {
     ipQuoteItemsDB.item_description     = iPQuoteItemsModel.item_description;
     ipQuoteItemsDB.item_discount_amount = iPQuoteItemsModel.item_discount_amount;
     ipQuoteItemsDB.item_product_id      = iPQuoteItemsModel.item_product_id;
     ipQuoteItemsDB.item_quantity        = iPQuoteItemsModel.item_quantity;
     return(ipQuoteItemsDB);
 }
示例#3
0
        public void Update(IPQuoteItemsModel iPQuoteItemsModel)
        {
            if (iPQuoteItemsModel == null)
            {
                //throw new ArgumentNullException(nameof(iPQuoteItemsModel));
            }

            var ipQuoteItemsDB = AMDSystemsEntities.ip_quote_items.Where(qi => qi.item_id == iPQuoteItemsModel.item_id).FirstOrDefault();

            Mapper.Map(iPQuoteItemsModel, ipQuoteItemsDB);
            AMDSystemsEntities.SaveChanges();
        }
示例#4
0
        public void Add(IPQuoteItemsModel iPQuoteItemsModel)
        {
            if (iPQuoteItemsModel == null)
            {
                //throw new ArgumentNullException(nameof(iPQuoteItemsModel));
            }
            iPQuoteItemsModel.item_date_added = DateTime.Now;
            ip_quote_items ipQuoteItemsDB = Mapper.Map(iPQuoteItemsModel, new ip_quote_items());

            AMDSystemsEntities.ip_quote_items.Add(ipQuoteItemsDB);
            AMDSystemsEntities.SaveChanges();
        }
示例#5
0
 public ActionResult UpdateQuoteItem(IPQuoteItemsModel model)
 {
     return(View());
 }
示例#6
0
        public FileResult ViewDownload(int id)
        {
            string GridHtml, HTMLcontent = string.Empty, taxContent = string.Empty, tablecontent = string.Empty;


            var invoiceModel = quoteService.FilterIPInvoice(id);

            int     ClientID = invoiceModel.client_id;
            decimal taxtotal = 0;


            //List<IPQuoteItemsModel> lsQuotesModel = invoiceModel.quote_items.ToList();

            List <IPQuoteItemsModel> lsQuotesModel = new List <IPQuoteItemsModel>();

            IPQuoteItemsModel quoteitem = new IPQuoteItemsModel();

            quoteitem.item_name            = "Test";
            quoteitem.item_description     = "desc";
            quoteitem.item_quantity        = 15;
            quoteitem.item_price           = 15;
            quoteitem.item_discount_amount = 5;
            quoteitem.item_tax_rate_id     = 4;

            lsQuotesModel.Add(quoteitem);
            quoteitem                      = new IPQuoteItemsModel();
            quoteitem.item_name            = "Test";
            quoteitem.item_description     = "desc";
            quoteitem.item_quantity        = 15;
            quoteitem.item_price           = 15;
            quoteitem.item_discount_amount = 5;
            quoteitem.item_tax_rate_id     = 4;
            lsQuotesModel.Add(quoteitem);

            tablecontent = tablecontent + HTMLTableHeader();

            if (lsQuotesModel.Count > 0)
            {
                TaxSummarylist = new Hashtable();

                foreach (IPQuoteItemsModel quoteitems in lsQuotesModel)
                {
                    tablecontent = tablecontent + "<tr> ";
                    tablecontent = tablecontent + "<td> " + quoteitems.item_id + "</td>";
                    tablecontent = tablecontent + "<td> " + quoteitems.item_name + "</td>";
                    tablecontent = tablecontent + "<td> " + quoteitems.item_description + "</td>";
                    tablecontent = tablecontent + "<td> " + quoteitems.item_quantity + "</td>";
                    tablecontent = tablecontent + "<td> " + quoteitems.item_price + "</td>";
                    tablecontent = tablecontent + "<td> " + quoteitems.item_discount_amount + "</td>";
                    tablecontent = tablecontent + "<td> " + quoteitems.item_tax_rate_id + "</td>";
                    tablecontent = tablecontent + "<td> " + ((quoteitems.item_price * quoteitems.item_quantity) - quoteitems.item_discount_amount).ToString() + "</td>";
                    tablecontent = tablecontent + "</tr> ";

                    if (!TaxSummarylist.ContainsKey(quoteitems.item_tax_rate_id))
                    {
                        TaxSummarylist.Add(quoteitems.item_tax_rate_id, (quoteitems.item_price * quoteitems.item_quantity) - quoteitems.item_discount_amount);
                    }
                    else
                    {
                        taxtotal = Convert.ToDecimal(TaxSummarylist[quoteitems.item_tax_rate_id]);
                        TaxSummarylist.Remove(quoteitems.item_tax_rate_id);
                        TaxSummarylist.Add(quoteitems.item_tax_rate_id, taxtotal + ((quoteitems.item_price * quoteitems.item_quantity) - quoteitems.item_discount_amount));
                    }
                }
            }


            // taxContent
            if (invoiceModel.quote_amount != null)
            {
                taxContent = taxContent + "<tr class=\"rtl\"> <td> Sub Total </td> <td> " + invoiceModel.quote_amount.quote_item_subtotal.ToString() + "</td>";
                taxContent = taxContent + "<tr class=\"rtl\"> <td> Total Discount </td> <td> " + invoiceModel.quote_amount.quote_discount.ToString() + "</td>";
                taxContent = taxContent + "<tr class=\"rtl\"> <td> CGST </td> <td> " + invoiceModel.quote_amount.quote_tax_total / 2 + "</td>";
                taxContent = taxContent + "<tr class=\"rtl\"> <td> SGST </td> <td> " + invoiceModel.quote_amount.quote_tax_total / 2 + "</td>";
                taxContent = taxContent + "<tr class=\"rtl\"> <td> Total </td> <td> " + invoiceModel.quote_amount.quote_total.ToString() + "</td>";
            }
            else
            {
                taxContent = taxContent + "<tr  class=\"rtl\"> <td> Sub Total </td> <td> " + "1000.00" + "</td> </tr>";
                taxContent = taxContent + "<tr class=\"rtl\"> <td> Total Discount </td> <td> " + "10.00" + "</td> </tr>";
                taxContent = taxContent + "<tr class=\"rtl\"> <td> CGST </td> <td> " + "10.00" + "</td> </tr>";
                taxContent = taxContent + "<tr class=\"rtl\"> <td> SGST </td> <td> " + "10.00" + "</td> </tr>";
                taxContent = taxContent + "<tr class=\"rtl\"> <td> Total </td> <td> " + "1010.00" + "</td> </tr>";
            }



            GridHtml = HTMLcontent;

            StringBuilder HTMLbuilder = new StringBuilder();

            HTMLbuilder.Append(HTMLContentBuilder().ToString());

            HTMLbuilder.Append("<table>");
            HTMLbuilder.Append("<tr>");
            //Company Details
            HTMLbuilder.Append("<td>");
            //Company Logo
            HTMLbuilder.Append("<img src=\"" + Server.MapPath("~/Content/") + "logo.jpg\" alt=\"Smiley face\" height=\"150\" width=\"150\"/>");
            HTMLbuilder.Append("</td>");
            HTMLbuilder.Append("<td class=\"rtl\">");
            HTMLbuilder.Append("Company Name <br/>");
            HTMLbuilder.Append("Address line1 <br/>");
            HTMLbuilder.Append("Address line1 <br/>");
            HTMLbuilder.Append("City <br/>");
            HTMLbuilder.Append("</td>");

            HTMLbuilder.Append("</tr>");
            HTMLbuilder.Append("</table>");

            HTMLbuilder.Append("<table>");
            HTMLbuilder.Append("<tr>");
            //Client Details
            HTMLbuilder.Append("<td>");
            HTMLbuilder.Append(GetClientDetails(Convert.ToInt32(ClientID)).ToString());
            HTMLbuilder.Append("</td>");
            // Invoice Details
            HTMLbuilder.Append("<td class=\"rtl\">");
            HTMLbuilder.Append("Invoice Number: " + invoiceModel.quote_number + "<br/>");
            HTMLbuilder.Append("Date: " + invoiceModel.quote_date_created.ToString("dd/MM/yyyy") + "<br/>");
            HTMLbuilder.Append("");
            HTMLbuilder.Append("</td>");

            HTMLbuilder.Append("</tr>");
            HTMLbuilder.Append("</table>");

            HTMLbuilder.Append("<table>");
            HTMLbuilder.Append(tablecontent);
            HTMLbuilder.Append("</table>");

            HTMLbuilder.Append("<table>");
            HTMLbuilder.Append(taxContent);
            HTMLbuilder.Append("</table>");

            if (invoiceModel.taxType != null)
            {
                isIGST = false;
            }
            else
            {
                isIGST = true;
            }

            HTMLbuilder.Append(TaxSummary());

            HTMLbuilder.Append("</div>");
            HTMLbuilder.Append("</body>");
            HTMLbuilder.Append("</html>");

            GridHtml = HTMLbuilder.ToString();

            StringReader sr = new StringReader(GridHtml);

            System.IO.FileStream fs       = new FileStream(Server.MapPath("~/PDFDownloads") + "\\" + id.ToString() + ".pdf", FileMode.Create);
            Document             document = new Document(PageSize.A4, 25, 25, 30, 30);
            PdfWriter            writer   = PdfWriter.GetInstance(document, fs);

            document.Open();
            XMLWorkerHelper.GetInstance().ParseXHtml(writer, document, sr);
            document.Close();
            writer.Close();
            fs.Close();


            //byte[] fileBytes = System.IO.File.ReadAllBytes(Server.MapPath("../PDF/" + InvoiceNumber+ ".pdf"));
            string fullPath = Path.Combine(Server.MapPath("~/PDFDownloads"), id.ToString() + ".pdf");
            string fileName = id.ToString() + ".pdf";

            return(File(fullPath, "application/pdf", fileName));
        }