public void GenerateReceipt(DocumentStockReceiptList stockReceipt) { string fPath = string.Empty, subF_Path = string.Empty, fileName = string.Empty, filePath = string.Empty; StreamWriter streamWriter = null; bool isDuplicate = false; try { fileName = stockReceipt.ReceivingCode + GlobalVariable.DocumentReceiptFileName; fPath = GlobalVariable.ReportPath + "Reports"; report.CreateFolderIfnotExists(fPath); // create a new folder if not exists subF_Path = fPath + "//" + stockReceipt.UserID; //ManageReport.GetDateForFolder(); report.CreateFolderIfnotExists(subF_Path); //delete file if exists filePath = subF_Path + "//" + fileName + ".txt"; report.DeleteFileIfExists(filePath); // isDuplicate = ReceiptId == "0" ? false : true; isDuplicate = stockReceipt.UnLoadingSlip == null ? false : stockReceipt.UnLoadingSlip.ToUpper() == "Y" ? true : false; streamWriter = new StreamWriter(filePath, true); AddDocHeaderForReceipt(streamWriter, stockReceipt, isDuplicate); AddDetails(streamWriter, stockReceipt); AddFooter(streamWriter, stockReceipt); } catch (Exception ex) { AuditLog.WriteError(ex.Message + " " + ex.StackTrace); } finally { streamWriter.Flush(); streamWriter.Close(); fPath = string.Empty; fileName = string.Empty; streamWriter = null; } }
/// <summary> /// Add header for document receipt /// </summary> /// <param name="streamWriter">Stream writer to write the text file.</param> /// <param name="stockReceipt"></param> /// <param name="isDuplicate"></param> public void AddDocHeaderForReceipt(StreamWriter streamWriter, DocumentStockReceiptList stockReceipt, bool isDuplicate = false) { streamWriter.WriteLine("|----------------------------------------------------------------------------------------------------------|"); streamWriter.WriteLine("| |"); streamWriter.WriteLine("| |"); streamWriter.WriteLine("| TAMILNADU CIVIL SUPPLIES CORPORATION |"); streamWriter.Write("| "); streamWriter.Write(report.StringFormatWithoutPipe("REGION : ", 9, 1)); streamWriter.Write(report.StringFormat(stockReceipt.RegionName, 53, 2)); streamWriter.WriteLine(""); streamWriter.WriteLine("| |"); streamWriter.WriteLine("| |"); if (isDuplicate) { streamWriter.WriteLine("| STOCK RECEIPT ACKNOWLEDGMENT DUPLICATE COPY |"); } else { streamWriter.WriteLine("| STOCK RECEIPT ACKNOWLEDGMENT |"); } streamWriter.WriteLine("|----------------------------------------------------------------------------------------------------------|"); streamWriter.Write("|ACKNOWLEDGEMENT NO:"); streamWriter.Write(report.StringFormatWithoutPipe(stockReceipt.SRNo, 21, 2)); streamWriter.Write("ALLOTMENT/RELEASE ORDER: "); streamWriter.Write(report.StringFormatWithoutPipe(stockReceipt.OrderNo + " " + stockReceipt.PAllotment, 16, 2)); streamWriter.Write("GATE PASS : "******"", 10, 2)); streamWriter.Write("|"); streamWriter.WriteLine(" "); streamWriter.Write("| DATE:"); streamWriter.Write(report.StringFormatWithoutPipe(report.FormatDate(stockReceipt.SRDate.ToString()), 21, 2)); streamWriter.Write(report.StringFormatWithoutPipe("DATE: ", 25, 1)); streamWriter.Write(report.StringFormatWithoutPipe(report.FormatDate(stockReceipt.OrderDate.ToString()), 38, 2)); streamWriter.Write("|"); streamWriter.WriteLine(" "); streamWriter.Write("|PERIOD OF ALLOTMENT:"); streamWriter.Write(report.StringFormatWithoutPipe(report.FormatDate(stockReceipt.SRDate.ToString()), 30, 2)); streamWriter.Write("Transaction Type: "); streamWriter.Write(report.StringFormatWithoutPipe(stockReceipt.TransactionName, 36, 2)); streamWriter.Write("|"); streamWriter.WriteLine(" "); streamWriter.Write("|RECEIVING GODOWN:"); streamWriter.Write(report.StringFormatWithoutPipe(stockReceipt.GodownName, 30, 2)); streamWriter.Write("DEPOSITOR'S NAME:"); streamWriter.Write(report.StringFormatWithoutPipe(stockReceipt.DepositorName, 40, 2)); streamWriter.Write("|"); streamWriter.WriteLine(" "); streamWriter.WriteLine("|----------------------------------------------------------------------------------------------------------|"); streamWriter.WriteLine("||--------------------------------------------------------------------------------------------------------||"); streamWriter.WriteLine("||SNo |STACK NO |COMMODITY | SCHEME |UNIT WEIGHT |NO.OF | Gross NET |% OF ||"); streamWriter.WriteLine("|| | | | | | UNIT| WEIGHT in Kgs/NOs |MOISTURE||"); streamWriter.WriteLine("||--------------------------------------------------------------------------------------------------------||"); }
public void AddFooter(iTextSharp.text.Document doc, DocumentStockReceiptList stockReceipt) { //GetDate() ManageSQLConnection manageSQL = new ManageSQLConnection(); DateTime dateTime = manageSQL.GetSRTime(stockReceipt.SRNo); string receiptDateTime = report.FormatDate(stockReceipt.SRDate.ToString()) + " " + report.GetCurrentTime(dateTime); Paragraph FSSAI = new Paragraph(" Prepared DateTime:" + receiptDateTime + " Download DateTime:" + DateTime.Now.ToString("dd-MMM-yyyy hh:mm:ss") + " User : " + stockReceipt.UserID, NormalFont); FSSAI.Alignment = Element.ALIGN_LEFT; doc.Add(FSSAI); }
public void AddRemarks(iTextSharp.text.Document doc, DocumentStockReceiptList stockReceipt) { Paragraph FSSAI = new Paragraph(" REMARKS ", FSSAIFont); FSSAI.Alignment = Element.ALIGN_LEFT; doc.Add(FSSAI); FSSAI = new Paragraph(" " + stockReceipt.Remarks, NormalFont); FSSAI.Alignment = Element.ALIGN_LEFT; doc.Add(FSSAI); AddSpace(doc); }
private string GetWTCode(DocumentStockReceiptList stockReceipt) { try { return(stockReceipt.ItemList[0].WTCode); } catch (Exception ex) { AuditLog.WriteError("GetWTCode : " + ex.Message); return("0"); } }
public Tuple <bool, string, string> InsertReceiptData(DocumentStockReceiptList stockReceipt) { ManageSQLConnection manageSQL = new ManageSQLConnection(); var result = manageSQL.InsertReceiptSrDetailEntry(stockReceipt); //if(result!=null) //{ // string SrNo = result.Item1; // string RowId = result.Item2; // return true; //} return(result); }
public Tuple <bool, string, string> Post(DocumentStockReceiptList stockReceipt = null) { ManageDocumentReceipt documentReceipt = new ManageDocumentReceipt(); if (stockReceipt.Type == 2) { ManageSQLConnection manageSQLConnection = new ManageSQLConnection(); documentReceipt.GenerateReceipt(stockReceipt); //update print if (stockReceipt.UnLoadingSlip == "N" || string.IsNullOrEmpty(stockReceipt.UnLoadingSlip)) { List <KeyValuePair <string, string> > sqlParameters = new List <KeyValuePair <string, string> >(); sqlParameters.Add(new KeyValuePair <string, string>("@SRNo", stockReceipt.SRNo)); manageSQLConnection.UpdateValues("UpdateSRDetailsUnLoading", sqlParameters); } return(new Tuple <bool, string, string>(true, "Print Generated Sucessfully", "")); } else { ManageSQLConnection manageSQLConnection = new ManageSQLConnection(); List <KeyValuePair <string, string> > sqlParameters = new List <KeyValuePair <string, string> >(); sqlParameters.Add(new KeyValuePair <string, string>("@GCode", stockReceipt.ReceivingCode)); var result = manageSQLConnection.GetDataSetValues("AllowDocumentEntry", sqlParameters); ManageReport manageReport = new ManageReport(); if (manageReport.CheckDataAvailable(result)) { if (stockReceipt.SRNo.Trim() != "0" && stockReceipt.SRNo.Trim() != "-") { List <KeyValuePair <string, string> > sqlParameters1 = new List <KeyValuePair <string, string> >(); sqlParameters1.Add(new KeyValuePair <string, string>("@Type", "1")); sqlParameters1.Add(new KeyValuePair <string, string>("@DocNumber", stockReceipt.SRNo.Trim())); var result1 = manageSQLConnection.GetDataSetValues("CheckDocumentEdit", sqlParameters1); if (!manageReport.CheckDataAvailable(result1)) { return(new Tuple <bool, string, string>(false, GlobalVariable.DocumentEditPermission, "")); } // CheckDocumentEdit } else if (documentReceipt.CheckSRUpdateStatus(stockReceipt.SRNo)) { return(new Tuple <bool, string, string>(false, GlobalVariable.DocumentEditByHO, "")); } StockReceipt receipt = new StockReceipt(); return(receipt.InsertReceiptData(stockReceipt)); } else { return(new Tuple <bool, string, string>(false, "Permission not Granted", "")); } } }
/// <summary> /// Add footer for document receipt /// </summary> /// <param name="streamWriter"></param> /// <param name="stockReceipt"></param> public void AddFooter(StreamWriter streamWriter, DocumentStockReceiptList stockReceipt) { //GetDate() ManageSQLConnection manageSQL = new ManageSQLConnection(); DateTime dateTime = manageSQL.GetSRTime(stockReceipt.SRNo); streamWriter.WriteLine("|----------------------------------------------------------------------------------------------------------|"); streamWriter.Write("|T.MEMO/IN.NO:"); streamWriter.Write(report.StringFormatWithoutPipe(stockReceipt.TruckMemoNo, 19, 2)); streamWriter.Write("LORRY NO : "); streamWriter.Write(report.StringFormatWithoutPipe(stockReceipt.LNo, 14, 2)); streamWriter.Write("TC NAME : "); streamWriter.Write(report.StringFormatWithoutPipe(stockReceipt.TransporterName, 25, 2)); streamWriter.Write("|"); streamWriter.WriteLine(" "); streamWriter.Write("|T.MEMO/IN.DT:"); streamWriter.Write(report.StringFormatWithoutPipe(report.FormatDate(stockReceipt.TruckMemoDate.ToString()), 19, 2)); streamWriter.Write("LORRY FROM : "); streamWriter.Write(report.StringFormatWithoutPipe(stockReceipt.LFrom, 56, 2)); streamWriter.Write("|"); streamWriter.WriteLine(" "); streamWriter.WriteLine("| |"); streamWriter.Write("|MODE OF WEIGHMENT: "); streamWriter.Write(report.StringFormatWithoutPipe(GetWTCode(stockReceipt), 13, 2)); streamWriter.Write("WAGON NO : "); streamWriter.Write(report.StringFormatWithoutPipe("-", 14, 2)); streamWriter.Write("RR NO : "); streamWriter.Write(report.StringFormatWithoutPipe(stockReceipt.MTransport, 25, 2)); streamWriter.Write("|"); streamWriter.WriteLine(" "); streamWriter.WriteLine("| |"); streamWriter.WriteLine("|" + report.StringFormatWithoutPipe(GlobalVariable.FSSAI1, 105, 2) + "|"); streamWriter.WriteLine("|" + report.StringFormatWithoutPipe(GlobalVariable.FSSAI2, 105, 2) + "|"); streamWriter.WriteLine("|" + report.StringFormatWithoutPipe(GlobalVariable.FSSAI3, 105, 2) + "|"); streamWriter.WriteLine("| |"); streamWriter.WriteLine("| Sign. of the Authorised Person. GODOWN INCHARGE |"); streamWriter.WriteLine("| |"); streamWriter.WriteLine("|REMARKS |"); streamWriter.WriteLine("| " + report.StringFormatWithoutPipe(stockReceipt.Remarks, 102, 2) + "|"); report.AddMoreContent(streamWriter, stockReceipt.Remarks, 102, 3); streamWriter.WriteLine("|----------------------------------------------------------------------------------------------------------|"); string receiptDateTime = report.FormatDate(stockReceipt.SRDate.ToString()) + " " + report.GetCurrentTime(dateTime); streamWriter.WriteLine(" Prepared DateTime:" + receiptDateTime + " Printing DateTime:" + DateTime.Now.ToString("dd-MMM-yyyy hh:mm:ss")); streamWriter.WriteLine((char)12); }
public Tuple <bool, string> Post(DocumentStockReceiptList stockReceipt = null) { //Check valid user details. ManageSQLConnection manageSQLConnection = new ManageSQLConnection(); ManageReport manage = new ManageReport(); List <KeyValuePair <string, string> > sqlParameters1 = new List <KeyValuePair <string, string> >(); sqlParameters1.Add(new KeyValuePair <string, string>("@UserName", stockReceipt.UserID)); DataSet ds = new DataSet(); ds = manageSQLConnection.GetDataSetValues("GetDocumentDownloadUser", sqlParameters1); if (manage.CheckDataAvailable(ds)) { ManagePDFGeneration managePDF = new ManagePDFGeneration(); var result = managePDF.GeneratePDF(stockReceipt); if (result.Item1) { List <KeyValuePair <string, string> > sqlParameters = new List <KeyValuePair <string, string> >(); sqlParameters.Add(new KeyValuePair <string, string>("@Doc", stockReceipt.SRNo)); sqlParameters.Add(new KeyValuePair <string, string>("@Status", "1")); manageSQLConnection.UpdateValues("UpdateSRDetailStatus", sqlParameters); List <KeyValuePair <string, string> > InsertParameter = new List <KeyValuePair <string, string> >(); InsertParameter.Add(new KeyValuePair <string, string>("@GCode", stockReceipt.ReceivingCode)); InsertParameter.Add(new KeyValuePair <string, string>("@RCode", stockReceipt.RCode)); InsertParameter.Add(new KeyValuePair <string, string>("@DocNumber", stockReceipt.SRNo)); InsertParameter.Add(new KeyValuePair <string, string>("@UserName", stockReceipt.UserID)); InsertParameter.Add(new KeyValuePair <string, string>("@DocType", "1")); manageSQLConnection.InsertData("InsertDocumentDownloadLog", InsertParameter); } return(result); } else { List <KeyValuePair <string, string> > InsertParameter = new List <KeyValuePair <string, string> >(); InsertParameter.Add(new KeyValuePair <string, string>("@GCode", stockReceipt.ReceivingCode)); InsertParameter.Add(new KeyValuePair <string, string>("@RCode", stockReceipt.RCode)); InsertParameter.Add(new KeyValuePair <string, string>("@DocNumber", stockReceipt.SRNo)); InsertParameter.Add(new KeyValuePair <string, string>("@UserName", stockReceipt.UserID)); InsertParameter.Add(new KeyValuePair <string, string>("@DocType", "2")); manageSQLConnection.InsertData("InsertDocumentDownloadLog", InsertParameter); // return(new Tuple <bool, string>(false, "Please contact HO")); } }
/// <summary> /// Add receipt item details /// </summary> /// <param name="streamWriter"></param> /// <param name="stockReceipt"></param> public void AddDetails(StreamWriter streamWriter, DocumentStockReceiptList stockReceipt) { int i = 0; foreach (var item in stockReceipt.ItemList) { i = i + 1; streamWriter.Write("||"); streamWriter.Write(report.StringFormat(i.ToString(), 4, 2)); streamWriter.Write(report.StringFormat(item.TStockNo, 11, 2)); streamWriter.Write(report.StringFormat(item.CommodityName, 20, 2)); streamWriter.Write(report.StringFormat(item.SchemeName, 14, 2)); streamWriter.Write(report.StringFormat(item.PackingName, 13, 2)); streamWriter.Write(report.StringFormat(item.NoPacking.ToString(), 6, 1)); streamWriter.Write(report.StringFormat(report.DecimalformatForWeight(item.GKgs.ToString()), 10, 1)); streamWriter.Write(report.StringFormat(report.DecimalformatForWeight(item.Nkgs.ToString()), 10, 1)); streamWriter.Write(report.StringFormat(item.Moisture.ToString(), 8, 1) + "|"); streamWriter.WriteLine(" "); } }
public void AddLorryInfo(iTextSharp.text.Document doc, DocumentStockReceiptList stockReceipt) { PdfPTable table = new PdfPTable(6); table.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER; //table.setBorder(Border.NO_BORDER); //set overall width table.WidthPercentage = 100f; table.DefaultCell.Padding = 10; //set column widths int[] firstTablecellwidth = { 12, 18, 15, 25, 12, 18 }; table.SetWidths(firstTablecellwidth); PdfPCell cell = new PdfPCell(new Phrase("T.MEMO/IN.NO:", NormalFont)); cell.HorizontalAlignment = Element.ALIGN_LEFT; cell.BorderWidth = 0; table.AddCell(cell); cell = new PdfPCell(new Phrase(stockReceipt.TruckMemoNo, NormalFont)); cell.HorizontalAlignment = Element.ALIGN_LEFT; cell.BorderWidth = 0; table.AddCell(cell); cell = new PdfPCell(new Phrase("LORRY NO : " + stockReceipt.LNo, NormalFont)); cell.HorizontalAlignment = Element.ALIGN_LEFT; cell.Colspan = 2; cell.BorderWidth = 0; table.AddCell(cell); cell = new PdfPCell(new Phrase("TC NAME : " + stockReceipt.TransporterName, NormalFont)); cell.HorizontalAlignment = Element.ALIGN_LEFT; cell.BorderWidth = 0; cell.Colspan = 2; table.AddCell(cell); cell = new PdfPCell(new Phrase("T.MEMO/IN.DT:", NormalFont)); cell.HorizontalAlignment = Element.ALIGN_LEFT; cell.BorderWidth = 0; table.AddCell(cell); cell = new PdfPCell(new Phrase(report.FormatDate(stockReceipt.TruckMemoDate.ToString()), NormalFont)); cell.HorizontalAlignment = Element.ALIGN_LEFT; cell.BorderWidth = 0; table.AddCell(cell); cell = new PdfPCell(new Phrase("LORRY FROM : " + stockReceipt.LFrom, NormalFont)); cell.HorizontalAlignment = Element.ALIGN_LEFT; cell.BorderWidth = 0; cell.Colspan = 4; table.AddCell(cell); cell = new PdfPCell(new Phrase("MODE OF WEIGHMENT : " + GetWTCode(stockReceipt), NormalFont)); cell.HorizontalAlignment = Element.ALIGN_LEFT; cell.BorderWidth = 0; cell.Colspan = 2; table.AddCell(cell); cell = new PdfPCell(new Phrase("WAGON NO : -", NormalFont)); cell.HorizontalAlignment = Element.ALIGN_LEFT; cell.Colspan = 2; cell.BorderWidth = 0; table.AddCell(cell); cell = new PdfPCell(new Phrase("RR NO : " + stockReceipt.MTransport, NormalFont)); cell.HorizontalAlignment = Element.ALIGN_LEFT; cell.BorderWidth = 0; cell.Colspan = 4; table.AddCell(cell); doc.Add(table); }
public void AddDetails(iTextSharp.text.Document doc, DocumentStockReceiptList stockReceipt) { //streamWriter.WriteLine("||SNo |STACK NO |COMMODITY | SCHEME |UNIT WEIGHT |NO.OF UNIT | Gross WEIGHT NET |% OF MOISTURE ||"); //streamWriter.WriteLine("|| | | | | | UNIT| WEIGHT in Kgs/NOs |MOISTURE||"); PdfPTable table = new PdfPTable(9); table.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER; //set overall width table.WidthPercentage = 100f; //set column widths int[] firstTablecellwidth = { 5, 8, 20, 12, 18, 7, 10, 10, 10 }; table.SetWidths(firstTablecellwidth); PdfPCell cell = new PdfPCell(new Phrase("SNo", NormalFont)); cell.HorizontalAlignment = Element.ALIGN_CENTER; table.AddCell(cell); cell = new PdfPCell(new Phrase("STACK NO", NormalFont)); cell.HorizontalAlignment = Element.ALIGN_CENTER; table.AddCell(cell); cell = new PdfPCell(new Phrase("COMMODITY", NormalFont)); cell.HorizontalAlignment = Element.ALIGN_CENTER; table.AddCell(cell); cell = new PdfPCell(new Phrase("SCHEME", NormalFont)); cell.HorizontalAlignment = Element.ALIGN_CENTER; table.AddCell(cell); cell = new PdfPCell(new Phrase("UNIT WEIGHT", NormalFont)); cell.HorizontalAlignment = Element.ALIGN_CENTER; table.AddCell(cell); cell = new PdfPCell(new Phrase("NO.OF UNIT", NormalFont)); cell.HorizontalAlignment = Element.ALIGN_CENTER; table.AddCell(cell); cell = new PdfPCell(new Phrase("Gross WEIGHT", NormalFont)); cell.HorizontalAlignment = Element.ALIGN_CENTER; table.AddCell(cell); cell = new PdfPCell(new Phrase("NET WEIGHT", NormalFont)); cell.HorizontalAlignment = Element.ALIGN_CENTER; table.AddCell(cell); cell = new PdfPCell(new Phrase("% OF MOISTURE", NormalFont)); cell.HorizontalAlignment = Element.ALIGN_CENTER; table.AddCell(cell); int i = 0; foreach (var item in stockReceipt.ItemList) { i++; cell = new PdfPCell(new Phrase(i.ToString(), NormalFont)); cell.HorizontalAlignment = Element.ALIGN_CENTER; table.AddCell(cell); cell = new PdfPCell(new Phrase(item.TStockNo, NormalFont)); cell.HorizontalAlignment = Element.ALIGN_LEFT; table.AddCell(cell); cell = new PdfPCell(new Phrase(item.CommodityName, NormalFont)); cell.HorizontalAlignment = Element.ALIGN_LEFT; table.AddCell(cell); cell = new PdfPCell(new Phrase(item.SchemeName, NormalFont)); cell.HorizontalAlignment = Element.ALIGN_LEFT; table.AddCell(cell); cell = new PdfPCell(new Phrase(item.PackingName, NormalFont)); cell.HorizontalAlignment = Element.ALIGN_LEFT; table.AddCell(cell); cell = new PdfPCell(new Phrase(item.NoPacking.ToString(), NormalFont)); cell.HorizontalAlignment = Element.ALIGN_RIGHT; table.AddCell(cell); cell = new PdfPCell(new Phrase(report.DecimalformatForWeight(item.GKgs.ToString()), NormalFont)); cell.HorizontalAlignment = Element.ALIGN_RIGHT; table.AddCell(cell); cell = new PdfPCell(new Phrase(report.DecimalformatForWeight(item.Nkgs.ToString()), NormalFont)); cell.HorizontalAlignment = Element.ALIGN_RIGHT; table.AddCell(cell); cell = new PdfPCell(new Phrase(item.Moisture.ToString(), NormalFont)); cell.HorizontalAlignment = Element.ALIGN_RIGHT; table.AddCell(cell); } doc.Add(table); }
public Tuple <bool, string> GeneratePDF(DocumentStockReceiptList stockReceipt = null) { string fPath = string.Empty, subF_Path = string.Empty, fileName = string.Empty, filePath = string.Empty; try { fileName = stockReceipt.ReceivingCode + GlobalVariable.ReceiptAckFileName; fPath = GlobalVariable.ReportPath + "Reports"; report.CreateFolderIfnotExists(fPath); // create a new folder if not exists subF_Path = fPath + "//" + stockReceipt.UserID; //ManageReport.GetDateForFolder(); report.CreateFolderIfnotExists(subF_Path); //delete file if exists filePath = subF_Path + "//" + fileName + ".pdf"; report.DeleteFileIfExists(filePath); iTextSharp.text.Document document = new iTextSharp.text.Document(PageSize.A4, 5f, 5f, 5f, 5f); //Create PDF Table FileStream fs = new FileStream(filePath, FileMode.Create); //Create a PDF file in specific path PdfWriter writer = PdfWriter.GetInstance(document, fs); // Add meta information to the document document.AddAuthor("Dulasiayya from BonTon"); document.AddCreator("Acknolowdgement for particuar document"); document.AddKeywords("TNCSC- Webcopy "); document.AddSubject("Document subject - Ack Web Copy "); document.AddTitle("The document title - PDF creation for Receipt Document"); //Open the PDF document document.Open(); string imagePath = GlobalVariable.ReportPath + "layout\\images\\dashboard\\tncsc-logo.PNG"; iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(imagePath); img.Alignment = Element.ALIGN_CENTER; img.ScaleToFit(80f, 60f); imagePath = GlobalVariable.ReportPath + "layout\\images\\dashboard\\watermark.PNG"; iTextSharp.text.Image imgWaterMark = iTextSharp.text.Image.GetInstance(imagePath); imgWaterMark.ScaleToFit(300, 450); imgWaterMark.Alignment = iTextSharp.text.Image.UNDERLYING; imgWaterMark.SetAbsolutePosition(120, 450); document.Add(imgWaterMark); //|----------------------------------------------------------------------------------------------------------| //Create the table PdfPTable table = new PdfPTable(2); table.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER; //table.setBorder(Border.NO_BORDER); //set overall width table.WidthPercentage = 100f; //set column widths int[] firstTablecellwidth = { 20, 80 }; table.SetWidths(firstTablecellwidth); //iTextSharp.text.Font fontTable = FontFactory.GetFont("Arial", "16", iTextSharp.text.Font.NORMAL); PdfPCell cell = new PdfPCell(img); cell.Rowspan = 3; cell.BorderWidth = 0; // cell.Border = (Border.NO_BORDER); table.AddCell(cell); PdfPCell cell1 = new PdfPCell(new Phrase("TAMILNADU CIVIL SUPPLIES CORPORATION")); cell1.HorizontalAlignment = Element.ALIGN_CENTER; cell1.BorderWidth = 0; table.AddCell(cell1); cell1 = new PdfPCell(new Phrase("Region Name : " + stockReceipt.RegionName)); cell1.HorizontalAlignment = Element.ALIGN_CENTER; cell1.BorderWidth = 0; table.AddCell(cell1); cell1 = new PdfPCell(new Phrase("")); cell1.BorderWidth = 0; table.AddCell(cell1); document.Add(table); Paragraph heading = new Paragraph(" STOCK RECEIPT ACKNOWLEDGMENT WEB COPY"); heading.Alignment = Element.ALIGN_CENTER; document.Add(heading); AddSpace(document); AddHRLine(document); //add header values AddheaderValues(document, stockReceipt); AddSpace(document); AddDetails(document, stockReceipt); AddSpace(document); AddLorryInfo(document, stockReceipt); AddSpace(document); AddFSSAI(document); AddSign(document, stockReceipt.ReceivingCode); AddSpace(document); AddRemarks(document, stockReceipt); AddSpace(document); AddHRLine(document); AddFooter(document, stockReceipt); //Add border to page PdfContentByte content = writer.DirectContent; Rectangle rectangle = new Rectangle(document.PageSize); rectangle.Left += document.LeftMargin; rectangle.Right -= document.RightMargin; rectangle.Top -= document.TopMargin; rectangle.Bottom += document.BottomMargin; content.SetColorStroke(BaseColor.Black); content.Rectangle(rectangle.Left, rectangle.Bottom, rectangle.Width, rectangle.Height); content.Stroke(); // Close the document document.Close(); // Close the writer instance writer.Close(); // Always close open filehandles explicity fs.Close(); } catch (Exception ex) { AuditLog.WriteError(" GeneratePDF : " + ex.Message + " " + ex.StackTrace); return(new Tuple <bool, string>(false, "Please Contact system Admin")); } return(new Tuple <bool, string>(true, "Print Generated Successfully")); }
public void AddheaderValues(iTextSharp.text.Document doc, DocumentStockReceiptList stockReceipt) { PdfPTable table = new PdfPTable(6); table.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER; //table.setBorder(Border.NO_BORDER); //set overall width table.WidthPercentage = 100f; //set column widths int[] firstTablecellwidth = { 20, 20, 20, 20, 10, 10 }; table.SetWidths(firstTablecellwidth); PdfPCell cell = new PdfPCell(new Phrase("ACKNOWLEDGEMENT NO:", NormalFont)); cell.HorizontalAlignment = Element.ALIGN_RIGHT; cell.BorderWidth = 0; table.AddCell(cell); cell = new PdfPCell(new Phrase(stockReceipt.SRNo, NormalFont)); cell.HorizontalAlignment = Element.ALIGN_LEFT; cell.BorderWidth = 0; table.AddCell(cell); cell = new PdfPCell(new Phrase("ALLOTMENT/RELEASE ORDER:" + stockReceipt.OrderNo + " " + stockReceipt.PAllotment, NormalFont)); cell.HorizontalAlignment = Element.ALIGN_LEFT; cell.Colspan = 4; cell.BorderWidth = 0; table.AddCell(cell); cell = new PdfPCell(new Phrase("DATE:", NormalFont)); cell.HorizontalAlignment = Element.ALIGN_RIGHT; cell.BorderWidth = 0; table.AddCell(cell); cell = new PdfPCell(new Phrase(report.FormatDate(stockReceipt.SRDate.ToString()), NormalFont)); cell.HorizontalAlignment = Element.ALIGN_LEFT; cell.BorderWidth = 0; table.AddCell(cell); cell = new PdfPCell(new Phrase("DATE:", NormalFont)); cell.HorizontalAlignment = Element.ALIGN_RIGHT; cell.BorderWidth = 0; table.AddCell(cell); cell = new PdfPCell(new Phrase(report.FormatDate(stockReceipt.OrderDate.ToString()), NormalFont)); cell.HorizontalAlignment = Element.ALIGN_LEFT; cell.BorderWidth = 0; table.AddCell(cell); cell = new PdfPCell(new Phrase("GATE PASS:"******"", NormalFont)); cell.HorizontalAlignment = Element.ALIGN_LEFT; cell.BorderWidth = 0; table.AddCell(cell); cell = new PdfPCell(new Phrase("PERIOD OF ALLOTMENT:", NormalFont)); cell.HorizontalAlignment = Element.ALIGN_RIGHT; cell.BorderWidth = 0; table.AddCell(cell); cell = new PdfPCell(new Phrase(report.FormatDate(stockReceipt.SRDate.ToString()), NormalFont)); cell.HorizontalAlignment = Element.ALIGN_LEFT; cell.BorderWidth = 0; table.AddCell(cell); cell = new PdfPCell(new Phrase("Transaction Type:", NormalFont)); cell.HorizontalAlignment = Element.ALIGN_RIGHT; cell.BorderWidth = 0; table.AddCell(cell); cell = new PdfPCell(new Phrase(stockReceipt.TransactionName, NormalFont)); cell.HorizontalAlignment = Element.ALIGN_LEFT; cell.BorderWidth = 0; cell.Colspan = 3; table.AddCell(cell); cell = new PdfPCell(new Phrase("RECEIVING GODOWN:", NormalFont)); cell.HorizontalAlignment = Element.ALIGN_RIGHT; cell.BorderWidth = 0; table.AddCell(cell); cell = new PdfPCell(new Phrase(stockReceipt.GodownName, NormalFont)); cell.HorizontalAlignment = Element.ALIGN_LEFT; cell.BorderWidth = 0; table.AddCell(cell); cell = new PdfPCell(new Phrase("DEPOSITOR'S NAME:", NormalFont)); cell.HorizontalAlignment = Element.ALIGN_RIGHT; cell.BorderWidth = 0; table.AddCell(cell); cell = new PdfPCell(new Phrase(stockReceipt.DepositorName, NormalFont)); cell.HorizontalAlignment = Element.ALIGN_LEFT; cell.BorderWidth = 0; cell.Colspan = 3; table.AddCell(cell); doc.Add(table); }
public Tuple <bool, string, string> InsertReceiptSrDetailEntry(DocumentStockReceiptList receiptList) { SqlTransaction objTrans = null; string RowID = string.Empty, SRNo = string.Empty; bool isNewDoc = true; using (sqlConnection = new SqlConnection(GlobalVariable.ConnectionString)) { DataSet ds = new DataSet(); sqlCommand = new SqlCommand(); try { if (receiptList.SRNo.Length > 5) { isNewDoc = false; } if (sqlConnection.State == 0) { sqlConnection.Open(); } objTrans = sqlConnection.BeginTransaction(); sqlCommand.Transaction = objTrans; sqlCommand.Connection = sqlConnection; sqlCommand.CommandText = "InsertSRDetails"; sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.Parameters.AddWithValue("@SRDate", receiptList.SRDate); sqlCommand.Parameters.AddWithValue("@Trcode", receiptList.Trcode); sqlCommand.Parameters.AddWithValue("@Pallotment", receiptList.PAllotment); sqlCommand.Parameters.AddWithValue("@OrderNo", receiptList.OrderNo); sqlCommand.Parameters.AddWithValue("@OrderDate", receiptList.OrderDate); sqlCommand.Parameters.AddWithValue("@ReceivingCode", receiptList.ReceivingCode); sqlCommand.Parameters.AddWithValue("@IssuingCode", receiptList.DepositorCode); sqlCommand.Parameters.AddWithValue("@TruckMemoNo", receiptList.TruckMemoNo); sqlCommand.Parameters.AddWithValue("@TruckMemoDate", receiptList.TruckMemoDate); sqlCommand.Parameters.AddWithValue("@GServiceable", "0"); sqlCommand.Parameters.AddWithValue("@GUnserviceable", "0"); sqlCommand.Parameters.AddWithValue("@GPatches", "0"); sqlCommand.Parameters.AddWithValue("@RCode", receiptList.RCode); sqlCommand.Parameters.AddWithValue("@IssuerType", receiptList.DepositorType); sqlCommand.Parameters.AddWithValue("@ExportFlag", "N"); sqlCommand.Parameters.AddWithValue("@Unloadingslip", receiptList.UnLoadingSlip); sqlCommand.Parameters.AddWithValue("@Acknowledgementslip", "F"); sqlCommand.Parameters.AddWithValue("@Suspnstack", "-"); sqlCommand.Parameters.AddWithValue("@Suspnseaccno", "-"); sqlCommand.Parameters.AddWithValue("@Gunnyutilised", "0"); sqlCommand.Parameters.AddWithValue("@GunnyReleased", "0"); sqlCommand.Parameters.AddWithValue("@Flag1", "-"); sqlCommand.Parameters.AddWithValue("@Flag2", "-"); sqlCommand.Parameters.AddWithValue("@SRNo1", receiptList.SRNo); sqlCommand.Parameters.AddWithValue("@RowId1", receiptList.RowId); sqlCommand.Parameters.Add("@SRNo", SqlDbType.NVarChar, 13); sqlCommand.Parameters.Add("@RowId", SqlDbType.NVarChar, 30); sqlCommand.Parameters["@SRNo"].Direction = ParameterDirection.Output; sqlCommand.Parameters["@RowId"].Direction = ParameterDirection.Output; sqlCommand.ExecuteNonQuery(); RowID = (string)sqlCommand.Parameters["@RowId"].Value; SRNo = (string)sqlCommand.Parameters["@SRNO"].Value; //Generate the report file. receiptList.SRNo = SRNo; ManageDocumentReceipt documentReceipt = new ManageDocumentReceipt(); Task.Run(() => documentReceipt.GenerateReceipt(receiptList)); if (isNewDoc) { ManageIssuesAbstractPrint issuesAbstractPrint = new ManageIssuesAbstractPrint(); if (issuesAbstractPrint.GPSInsert(receiptList.Trcode)) // ACK only Transfer and Internal Transfer { ManageDataTransfer dataTransfer = new ManageDataTransfer(); DataTransferEntity transferEntity = new DataTransferEntity(); transferEntity.DocNumber = SRNo; transferEntity.DocDate = receiptList.SRDate; transferEntity.DocType = 1; transferEntity.TripType = 3; transferEntity.RCode = receiptList.RCode; transferEntity.GCode = receiptList.ReceivingCode; transferEntity.G2GStatus = 4; transferEntity.GPSStatus = 0; // dataTransfer.InsertDataTransfer(transferEntity); Task.Run(() => dataTransfer.InsertDataTransfer(transferEntity)); } } //Delete Sr Item Details sqlCommand.Parameters.Clear(); sqlCommand.Dispose(); sqlCommand = new SqlCommand(); sqlCommand.Transaction = objTrans; sqlCommand.Connection = sqlConnection; sqlCommand.CommandText = "DeleteSRDetails"; sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.Parameters.AddWithValue("@SRNo", SRNo); sqlCommand.ExecuteNonQuery(); ////Insert data into SR Item details List <StockReceiptItemList> stockReceiptItems = new List <StockReceiptItemList>(); stockReceiptItems = receiptList.ItemList; foreach (var item in stockReceiptItems) { sqlCommand.Parameters.Clear(); sqlCommand.Dispose(); sqlCommand = new SqlCommand(); sqlCommand.Transaction = objTrans; sqlCommand.Connection = sqlConnection; sqlCommand.CommandText = "InsertSRItemDetails"; sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.Parameters.AddWithValue("@RowId", RowID); sqlCommand.Parameters.AddWithValue("@SRNo", SRNo); sqlCommand.Parameters.AddWithValue("@TStockNo", item.TStockNo); sqlCommand.Parameters.AddWithValue("@ICode", item.ICode); sqlCommand.Parameters.AddWithValue("@IPCode", item.IPCode); sqlCommand.Parameters.AddWithValue("@NoPacking", item.NoPacking); sqlCommand.Parameters.AddWithValue("@WTCode", item.WTCode); sqlCommand.Parameters.AddWithValue("@GKgs", item.GKgs); sqlCommand.Parameters.AddWithValue("@Nkgs", item.Nkgs); sqlCommand.Parameters.AddWithValue("@Moisture", item.Moisture); sqlCommand.Parameters.AddWithValue("@Scheme", item.Scheme); sqlCommand.Parameters.AddWithValue("@RCode", receiptList.RCode); sqlCommand.Parameters.AddWithValue("@ExportFlag", "N"); sqlCommand.Parameters.AddWithValue("@flag1", item.StackYear); //sqlCommand.Parameters.AddWithValue("@Flag2", "-"); sqlCommand.ExecuteNonQuery(); } ////Insert SRT Details table sqlCommand.Parameters.Clear(); sqlCommand.Dispose(); sqlCommand = new SqlCommand(); sqlCommand.Transaction = objTrans; sqlCommand.Connection = sqlConnection; sqlCommand.CommandText = "InsertSRTDetails"; sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.Parameters.AddWithValue("@RowId", RowID); sqlCommand.Parameters.AddWithValue("@SRNo", SRNo); sqlCommand.Parameters.AddWithValue("@Remarks", receiptList.Remarks); sqlCommand.Parameters.AddWithValue("@RCode", receiptList.RCode); sqlCommand.Parameters.AddWithValue("@LNo", receiptList.LNo); sqlCommand.Parameters.AddWithValue("@TransportMode", receiptList.MTransport); sqlCommand.Parameters.AddWithValue("@LFrom", receiptList.LFrom); sqlCommand.Parameters.AddWithValue("@TransporterName", receiptList.TransporterName); sqlCommand.Parameters.AddWithValue("@LWBillNo", receiptList.LWBNo); sqlCommand.Parameters.AddWithValue("@LWBillDate", receiptList.LWBDate); sqlCommand.Parameters.AddWithValue("@LDate", receiptList.LDate); sqlCommand.Parameters.AddWithValue("@ExportFlag", "N"); sqlCommand.ExecuteNonQuery(); objTrans.Commit(); return(new Tuple <bool, string, string>(true, GlobalVariable.SavedMessage + SRNo, SRNo)); } catch (Exception ex) { AuditLog.WriteError(ex.Message + " : " + ex.StackTrace); objTrans.Rollback(); return(new Tuple <bool, string, string>(false, GlobalVariable.ErrorMessage, "")); } finally { sqlConnection.Close(); sqlCommand.Dispose(); ds.Dispose(); dataAdapter = null; } } }