示例#1
0
        public ActionResult DownloadPdf(string Pm, string id)
        {
            using (MemoryStream stream = new System.IO.MemoryStream())
            {
                string LogoPath           = Convert.ToString(Session["LogoPath"]);
                var    base64DecodedBytes = System.Convert.FromBase64String(Pm);
                string BillNoValue        = System.Text.Encoding.UTF8.GetString(base64DecodedBytes);
                // string CurrentPartyCode = "";
                try
                {
                    //CurrentPartyCode = (Session["LoginUser"] as User).PartyCode;

                    DistributorBillModel model = objTransacManager.getInvoice(BillNoValue, "", "F");
                    if (model == null)
                    {
                        model = new DistributorBillModel();
                    }
                    if (model.BillNo != null)
                    {
                        string    result = string.Empty;
                        ConnModel objCon;
                        objCon = (System.Web.HttpContext.Current.Session["ConModel"] as ConnModel);
                        if (objCon.CompID == "1008")
                        {
                            result = RazorViewToString.RenderRazorViewToString(this, "../Transaction/InvoicePrint-Sunvis", model);
                        }
                        else
                        {
                            result = RazorViewToString.RenderRazorViewToString(this, "../Transaction/InvoicePrint", model);
                        }
                        //string imagePath = System.Web.HttpContext.Current.Server.MapPath("~/images");
                        //imagePath = Path.Combine(imagePath, "logo.png");

                        result = result.Replace("/images/logo.png", LogoPath);

                        StringReader sr     = new StringReader(result);
                        Document     pdfDoc = new Document(PageSize.A4, 25f, 25f, 0f, 0f);
                        PdfWriter    writer = PdfWriter.GetInstance(pdfDoc, stream);
                        pdfDoc.Open();
                        XMLWorkerHelper.GetInstance().ParseXHtml(writer, pdfDoc, sr);
                        pdfDoc.Close();
                        return(File(stream.ToArray(), "application/pdf", "Invoice_" + model.BillNo + ".pdf"));
                    }
                    else
                    {
                        string imagePath = System.Web.HttpContext.Current.Server.MapPath("~/images");
                        imagePath = Path.Combine(imagePath, "NoImage.jpg");

                        //result = result.Replace("/images/NoImage.jpg", imagePath);
                        return(File(imagePath, "Invoice.pdf"));
                    }
                }
                catch (Exception ex)
                {
                }
            }
            return(null);
        }
示例#2
0
        public ActionResult DownloadPdf(string Pm, string id)
        {
            using (MemoryStream stream = new System.IO.MemoryStream())
            {
                var    base64DecodedBytes  = System.Convert.FromBase64String(Pm);
                string BillNoValue         = System.Text.Encoding.UTF8.GetString(base64DecodedBytes);
                string CurrentPartyCode    = "";
                DistributorBillModel model = objTransacManager.getInvoice(BillNoValue, CurrentPartyCode, id);
                if (model == null)
                {
                    model = new DistributorBillModel();
                }
                if (model.BillNo != null)
                {
                    string result = RazorViewToString.RenderRazorViewToString(this, "../Transaction/InvoicePrint", model);

                    string imagePath = System.Web.HttpContext.Current.Server.MapPath("~/images");
                    imagePath = Path.Combine(imagePath, "logo.png");

                    result = result.Replace("/images/logo.png", imagePath);

                    StringReader sr     = new StringReader(result);
                    Document     pdfDoc = new Document(PageSize.A4, 25f, 25f, 0f, 0f);
                    PdfWriter    writer = PdfWriter.GetInstance(pdfDoc, stream);
                    pdfDoc.Open();
                    XMLWorkerHelper.GetInstance().ParseXHtml(writer, pdfDoc, sr);
                    pdfDoc.Close();
                    return(File(stream.ToArray(), "application/pdf", "Invoice_" + model.BillNo + ".pdf"));
                }
                else
                {
                    string imagePath = System.Web.HttpContext.Current.Server.MapPath("~/images");
                    imagePath = Path.Combine(imagePath, "NoImage.jpg");

                    //result = result.Replace("/images/NoImage.jpg", imagePath);
                    return(File(imagePath, "Invoice.pdf"));
                }
            }
        }
示例#3
0
 public ResponseDetail SavePurchaseInvoice(DistributorBillModel objModel)
 {
     return(objTransacAPI.SavePurchaseInvoice(objModel));
 }
示例#4
0
        public DistributorBillModel getInvoice(string BillNo, string CurrentPartyCode, string id)
        {
            DistributorBillModel objResponse = objTransacAPI.getInvoice(BillNo, CurrentPartyCode, id);

            return(objResponse);
        }
示例#5
0
 public List <OfferProduct> CheckForExtraPVOffer(DistributorBillModel objModel)
 {
     return(objTransacAPI.CheckForExtraPVOffer(objModel));
 }
示例#6
0
        public ResponseDetail SaveDistributorBill(DistributorBillModel objModel)
        {
            ResponseDetail objResponse = objTransacAPI.SaveDistributorBill(objModel);

            return(objResponse);
        }
示例#7
0
        public ResponseDetail CheckForOffer(DistributorBillModel objModel)
        {
            ResponseDetail objResponse = objTransacAPI.CheckForOffer(objModel);

            return(objResponse);
        }
示例#8
0
        public ResponseDetail CheckForOfferNew(DistributorBillModel objModel)
        {
            ResponseDetail objResponse = new ResponseDetail();

            try
            {
                VisionOffer monthOfferList  = new VisionOffer();
                VisionOffer EarlyRiserOffer = null;
                VisionOffer FirstBillOffer  = null;
                var         CurrentDate     = DateTime.Now;
                using (var entity = new InventoryEntities(enttConstr))
                {
                    string OfferDatePart = ""; int OfferID = 0; string FreeProdIDs = ""; string FreeProdQtys = ""; string confProdIDs = ""; string ConfProdQtys = ""; string offerbillvalue = "0";

                    //if (objModel.objCustomer.IsFirstBill)
                    //{
                    if (!string.IsNullOrEmpty(objModel.objCustomer.Doj))
                    {
                        DateTime dateofjoining = Convert.ToDateTime(objModel.objCustomer.Doj);
                        DateTime checkDate     = dateofjoining.AddDays(30);
                        //if (CurrentDate <= checkDate)
                        //{
                        //FirstBillOffer = (from r in entity.VisionOffers where r.OfferType.ToUpper() == "OFFERONVALUE" && r.OfferBillType.ToUpper()=="FIRSTBILL" && r.ActiveStatus.ToUpper() == "Y" && r.SortFirstBy.ToLower() == "B" && r.OfferOnValue <= objModel.objProduct.TotalNetPayable && r.OfferOnBV <= objModel.objProduct.TotalBV select r).OrderByDescending(o => o.OfferOnBV).FirstOrDefault();
                        FirstBillOffer = (from r in entity.VisionOffers where r.OfferType.ToUpper() == "OFFERONVALUE" && r.ActiveStatus.ToUpper() == "Y" && r.SortFirstBy.ToUpper() == "B" && r.OfferOnValue <= objModel.objProduct.TotalNetPayable && r.OfferOnBV <= objModel.objProduct.TotalBV select r).OrderByDescending(o => o.OfferOnBV).FirstOrDefault();
                        if (FirstBillOffer != null)
                        {
                            if (CurrentDate.Date >= FirstBillOffer.OfferFromDt.Date && CurrentDate.Date <= FirstBillOffer.OfferToDt.Date)
                            {
                                objResponse.ResponseStatus = "Success";
                            }
                            OfferDatePart  = FirstBillOffer.OfferDatePart;
                            OfferID        = FirstBillOffer.OfferId;
                            FreeProdIDs    = FirstBillOffer.FreeProdIDs; FreeProdQtys = FirstBillOffer.FreeProdQtys.ToString();
                            confProdIDs    = FirstBillOffer.ConfFreeProdIDs; ConfProdQtys = FirstBillOffer.ConfFreeProdQtys;
                            offerbillvalue = FirstBillOffer.OfferOnValue.ToString();
                        }
                        //}
                    }
                    //}
                    if (FirstBillOffer == null)
                    {
                        EarlyRiserOffer = (from r in entity.VisionOffers where r.OfferType.ToUpper() == "OFFERONVALUE" && r.ActiveStatus.ToUpper() == "Y" && r.SortFirstBy.ToUpper() != "B" && r.OfferDatePart == "D" && r.OfferOnValue <= objModel.objProduct.TotalNetPayable && r.OfferOnBV <= objModel.objProduct.TotalBV select r).OrderByDescending(o => o.OfferOnValue).FirstOrDefault();

                        if (EarlyRiserOffer != null)
                        {
                            if (CurrentDate.Date >= EarlyRiserOffer.OfferFromDt.Date && CurrentDate.Date <= EarlyRiserOffer.OfferToDt.Date)
                            {
                                if (CurrentDate.Date.Day >= EarlyRiserOffer.OfferStartDay && CurrentDate.Date.Day <= EarlyRiserOffer.OfferEndDay)
                                {
                                    objResponse.ResponseStatus = "Success";
                                    OfferDatePart  = EarlyRiserOffer.OfferDatePart;
                                    OfferID        = EarlyRiserOffer.OfferId;
                                    FreeProdIDs    = EarlyRiserOffer.FreeProdIDs; FreeProdQtys = EarlyRiserOffer.FreeProdQtys.ToString();
                                    confProdIDs    = EarlyRiserOffer.ConfFreeProdIDs; ConfProdQtys = EarlyRiserOffer.ConfFreeProdQtys;
                                    offerbillvalue = EarlyRiserOffer.OfferOnValue.ToString();
                                }
                            }
                        }
                        else
                        {
                            monthOfferList = (from r in entity.VisionOffers where r.OfferType.ToUpper() == "OFFERONVALUE" && r.ActiveStatus.ToUpper() == "Y" && r.SortFirstBy.ToUpper() != "B" && r.OfferDatePart == "R" && r.OfferOnValue <= objModel.objProduct.TotalNetPayable && r.OfferOnBV <= objModel.objProduct.TotalBV select r).OrderByDescending(o => o.OfferOnValue).FirstOrDefault();
                            if (monthOfferList != null)
                            {
                                if (CurrentDate.Date >= monthOfferList.OfferFromDt.Date && CurrentDate.Date <= monthOfferList.OfferToDt.Date)
                                {
                                    objResponse.ResponseStatus = "Success";
                                }
                                OfferDatePart  = monthOfferList.OfferDatePart;
                                OfferID        = monthOfferList.OfferId;
                                FreeProdIDs    = monthOfferList.FreeProdIDs; FreeProdQtys = monthOfferList.FreeProdQtys.ToString();
                                confProdIDs    = monthOfferList.ConfFreeProdIDs; ConfProdQtys = monthOfferList.ConfFreeProdQtys;
                                offerbillvalue = monthOfferList.OfferOnValue.ToString();
                            }
                        }
                    }
                    if (objResponse.ResponseStatus == "Success")
                    {
                        var    freeproduct = FreeProdIDs.Split(',');
                        string productList = string.Empty;
                        //string Quant = string.Empty;
                        foreach (var prod in freeproduct)
                        {
                            if (prod != "")
                            {
                                var product = (from r in entity.M_ProductMaster where r.ProdId == prod select r.ProductName).FirstOrDefault();
                                productList += product + "~" + prod + ",";
                            }
                        }
                        if (productList.Length > 0)
                        {
                            productList = productList.Substring(0, productList.Length - 1);
                        }
                        string confproductList = ""; string confproductQtyList = "";
                        if (confProdIDs != "")
                        {
                            string[] confproduct    = confProdIDs.Split(',');
                            string[] confproductQty = ConfProdQtys.Split(',');
                            for (int i = 0; i < confproduct.Length; i++)
                            {
                                string ProdID_ = confproduct[i];
                                var    product = (from r in entity.M_ProductMaster where r.ProdId == ProdID_ select r.ProductName).FirstOrDefault();
                                confproductList    += product + "~" + confproduct[i] + ",";
                                confproductQtyList += confproductQty[i].ToString() + ",";
                            }
                            confproductList = confproductList.Substring(0, confproductList.Length - 1);
                        }
                        objResponse.ResponseMessage = OfferDatePart + "δ" + OfferID.ToString() + "δ" + productList + "δ" + FreeProdQtys.ToString() + "δ" + confproductList + "δ" + confproductQtyList + "δ" + offerbillvalue;
                    }
                    else
                    {
                        objResponse.ResponseMessage = "NoOffer";
                    }
                }
            }
            catch (Exception ex)
            {
                objResponse.ResponseStatus  = "FAILED";
                objResponse.ResponseMessage = "Something went wrong";
            }
            return(objResponse);
        }
示例#9
0
        public ResponseDetail SaveBillDetail(DistributorBillModel model)
        {
            ResponseDetail objResponse = objTransacRepo.SaveBillDetail(model);

            return(objResponse);
        }
示例#10
0
        public ResponseDetail SaveIssueSampleProducts(DistributorBillModel products)
        {
            ResponseDetail objResponse = objTransacRepo.SaveIssueSampleProducts(products);

            return(objResponse);
        }