public static RationCardDetail FetchFamilyCount(string custId) { ErrorEnum errType = ErrorEnum.Other; string errMsg = string.Empty; bool isSuccess = false; Exception errObj = new Exception(); int convertedNum = 0; RationCardDetail card = new RationCardDetail(); try { DataSet ds = DBoperationsManager.FetchFamilyCount(custId, out errType, out errMsg, out isSuccess, out errObj); if ((ds != null) && (ds.Tables.Count > 1)) { card.FamilyCount = (( //TOTAL_CARD_COUNT (ds.Tables[0].Rows.Count > 0) && Int32.TryParse(ds.Tables[0].Rows[0][0].ToString(), out convertedNum)) ? convertedNum : 0).ToString(); card.CardCount = (( //Active_CARD_COUNT (ds.Tables[1].Rows.Count > 0) && Int32.TryParse(ds.Tables[1].Rows[0][0].ToString(), out convertedNum)) ? convertedNum : 0).ToString(); } } catch (Exception ex) { Logger.LogError(ex); } return(card); }
private void grdVwSearchResult_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { _frmEntry = (FrmRationEntry)FormHelper.OpenFrmRationEntry(); try { Control ctrlsPanel = _frmEntry.Controls["pnlRationCardEntry"]; Control btnPanel = ctrlsPanel.Controls["panel3"]; Control ctrlsPanel2 = ctrlsPanel.Controls["panel2"]; Control grp1 = ctrlsPanel.Controls["groupBox1"]; Control grp3 = ctrlsPanel.Controls["groupBox3"]; string cardNo = grdVwSearchResult.Rows[e.RowIndex].Cells["Number"].Value.ToString(); grp1.Controls["txtCardNo"].Text = cardNo; grp1.Controls["lblIsEdit"].Text = "1"; string mobileNo = grdVwSearchResult.Rows[e.RowIndex].Cells["Mobile_No"].Value.ToString(); ComboBox cmbCat = (ComboBox)grp1.Controls["cmbCat"]; cmbCat.Text = grdVwSearchResult.Rows[e.RowIndex].Cells["Cat_Desc"].Value.ToString(); cmbCat.SelectedValue = grdVwSearchResult.Rows[e.RowIndex].Cells["Cat_Id"].Value.ToString(); cmbCat.SelectedIndex = Int32.Parse(((List <Category>)cmbCat.DataSource).FirstOrDefault(i => i.Cat_Id == grdVwSearchResult.Rows[e.RowIndex].Cells["Cat_Id"].Value.ToString()).Cat_Id) - 1; grp1.Controls["lblCardCatId"].Text = grdVwSearchResult.Rows[e.RowIndex].Cells["Cat_Id"].Value.ToString(); grp1.Controls["txtAdharOrEpic"].Text = grdVwSearchResult.Rows[e.RowIndex].Cells["Adhar_No"].Value.ToString(); grp3.Controls["txtCardHolderName"].Text = grdVwSearchResult.Rows[e.RowIndex].Cells["Name"].Value.ToString(); CheckBox hofCheck = (CheckBox)grp3.Controls["chkHof"]; hofCheck.Checked = grdVwSearchResult.Rows[e.RowIndex].Cells["Hof_Flag"].Value.ToString() == "True"; string hofName = grdVwSearchResult.Rows[e.RowIndex].Cells["Hof_Name"].Value.ToString(); grp3.Controls["cmbHof"].Text = hofName + " || " + cardNo + " || " + mobileNo; grp3.Controls["txtFatherName"].Text = grdVwSearchResult.Rows[e.RowIndex].Cells["Gaurdian_Name"].Value.ToString(); grp3.Controls["cmbRelHof"].Text = grdVwSearchResult.Rows[e.RowIndex].Cells["Relation_With_Hof"].Value.ToString(); grp3.Controls["cmbRel"].Text = grdVwSearchResult.Rows[e.RowIndex].Cells["Gaurdian_Relation"].Value.ToString(); string custId = grdVwSearchResult.Rows[e.RowIndex].Cells["Customer_Id"].Value.ToString(); RationCardDetail card = MasterDataHelper.FetchFamilyCount(custId); grp3.Controls["txtTotalActiveCards"].Text = card.FamilyCount; grp3.Controls["txtTotalCards"].Text = card.CardCount; //grp3.Controls["txtHofCardNo"].Text = grdVwSearchResult.Rows[e.RowIndex].Cells["CardCount"].Value.ToString(); DateTimePicker dt = (DateTimePicker)ctrlsPanel2.Controls["dateTimePicker1"]; dt.Value = DateTime.ParseExact(grdVwSearchResult.Rows[e.RowIndex].Cells["Card_Created_Date"].Value.ToString(), "d", CultureInfo.InvariantCulture); CheckBox active = (CheckBox)ctrlsPanel2.Controls["chkActive"]; active.Checked = grdVwSearchResult.Rows[e.RowIndex].Cells["ActiveCard"].Value.ToString() == "True"; ctrlsPanel2.Controls["txtMobileNo"].Text = mobileNo; ctrlsPanel2.Controls["txtAge"].Text = grdVwSearchResult.Rows[e.RowIndex].Cells["Age"].Value.ToString(); ctrlsPanel2.Controls["txtAddress"].Text = grdVwSearchResult.Rows[e.RowIndex].Cells["Address"].Value.ToString(); ctrlsPanel2.Controls["txtRemarks"].Text = grdVwSearchResult.Rows[e.RowIndex].Cells["Remarks"].Value.ToString(); ctrlsPanel2.Controls["lblRationCardId"].Text = grdVwSearchResult.Rows[e.RowIndex].Cells["RationCard_Id"].Value.ToString(); ctrlsPanel2.Controls["lblCustId"].Text = custId; btnPanel.Controls["btnDelete"].Enabled = true; } catch (Exception ex) { Logger.LogError(ex); } }
private Bill SaveBillToDrive() { var billObj = new Bill(); try { string googleDrivePath = ConfigManager.GetConfigValue("GoogleDrivePath"); string billSavePath = ConfigManager.GetConfigValue("BillSavePath"); _billSavePath = googleDrivePath + billSavePath + TimeStampHelper.GetDateStamp(); _fileName = "/" + TimeStampHelper.GetDateTimeStamp() + ".pdf"; if (!Directory.Exists(_billSavePath)) { Directory.CreateDirectory(_billSavePath); } FileStream flStrm = new FileStream(_billSavePath + _fileName, FileMode.Create); //Header iTextSharp.text.Image jpg = iTextSharp.text.Image.GetInstance(Directory.GetCurrentDirectory().Replace(@"bin\Debug", "") + @"\image\logo.jpg"); jpg.ScaleToFit(50f, 37f); jpg.SpacingBefore = 0f; jpg.SpacingAfter = 0f; jpg.Alignment = Element.ALIGN_CENTER; var para = new Paragraph(); para.MultipliedLeading = 1; para.SpacingBefore = 0; para.SpacingAfter = 0; if (_isShowLogoInBill) { para.Add(jpg); } para.Add(new Chunk(lblFpsDealer.Text + " || " + lblFPSCodeNo.Text + " || " + lblAddrLn1.Text + " || " + lblAddrLn2.Text + " || " + lblAddrLn3.Text + Environment.NewLine , CalculateFont(_billNotificationTxtSize))); //BillCounter PdfPTable billCounterTable = new PdfPTable(2) { WidthPercentage = 100 }; billCounterTable.SpacingBefore = 0f; billCounterTable.SpacingAfter = 0f; //billcounter _billObj.BillNumber = _totalBillCounter.ToString(); _billObj.BillSerialNumber = _dayBillCounterOrCount.ToString(); PdfPCell billCounterTableCell1 = new PdfPCell(new Phrase(lblBillNoText.Text + " " + lblCashMemoCounter.Text , CalculateFont(_billHeaderTxtSize))); //billCounterTableCell1.Colspan = 1; billCounterTableCell1.HorizontalAlignment = Element.ALIGN_LEFT; billCounterTableCell1.BorderWidth = 0f; //Serialnumber or DailyCounter PdfPCell billCounterTableCell2 = new PdfPCell(new Phrase(lblSerialText.Text + " " + lblSerialNumber.Text , CalculateFont(_billHeaderTxtSize))); //billCounterTableCell2.Colspan = 1; billCounterTableCell2.HorizontalAlignment = Element.ALIGN_RIGHT; billCounterTableCell2.BorderWidth = 0f; billCounterTable.Rows.Add(new PdfPRow(new PdfPCell[] { billCounterTableCell1, billCounterTableCell2 })); //Date PdfPCell billCounterTableCell3 = new PdfPCell(new Phrase(lblDt.Text , CalculateFont(_billHeaderTxtSize))); //billCounterTableCell3.Colspan = 1; billCounterTableCell3.HorizontalAlignment = Element.ALIGN_LEFT; billCounterTableCell3.BorderWidth = 0f; //Fortnight _billObj.Fortnight = TimeStampHelper.GetFortNight(lblDt.Text); PdfPCell billCounterTableCell4 = new PdfPCell(new Phrase("( " + TimeStampHelper.GetFortNightString(lblDt.Text) + " ) " , CalculateFont(_billHeaderTxtSize))); //billCounterTableCell3.Colspan = 1; billCounterTableCell4.HorizontalAlignment = Element.ALIGN_RIGHT; billCounterTableCell4.BorderWidth = 0f; billCounterTable.Rows.Add(new PdfPRow(new PdfPCell[] { billCounterTableCell3, billCounterTableCell4 })); billCounterTable.CompleteRow(); para.Add(billCounterTable); //Members _billObj.TotalCardServed = _memberCount; para.Add(new Chunk(Environment.NewLine + "Number of Unit : " + _memberCount , CalculateFont(_billPartHeadingTxtSize))); int totalCards = grdVwMembers.Rows.Count; int totalFamilyMember = grdVwMembers.Rows.Count; PdfPTable memberTable = new PdfPTable(1) { WidthPercentage = 100 }; memberTable.SpacingBefore = 0f; memberTable.SpacingAfter = 0f; //memberTable.TotalWidth = 226f; //memberTable.LockedWidth = true; string numbers = ""; foreach (DataGridViewRow item in grdVwMembers.Rows) { RationCardDetail lnItem = (RationCardDetail)item.DataBoundItem; numbers += ", " + lnItem.Number; } _billObj.RationcardNumbers = numbers.TrimStart(',', ' '); PdfPCell memberCell2 = new PdfPCell(new Phrase(numbers.TrimStart(',', ' ') + Environment.NewLine + Environment.NewLine , CalculateFont(_billTxtSize))); memberCell2.Colspan = 1; memberCell2.HorizontalAlignment = Element.ALIGN_LEFT; memberCell2.BorderWidth = 0f; memberTable.AddCell(memberCell2); para.Add(memberTable); //Items //para.Add(new Chunk(lblItemsText.Text // , new iTextSharp.text.Font(BaseFont.CreateFont(@"C:\Windows\Fonts\ARLRDBD.TTF", BaseFont.IDENTITY_H, // BaseFont.EMBEDDED), _billPartHeadingTxtSize))); PdfPTable itemTable = new PdfPTable(21) { WidthPercentage = 100 }; itemTable.SpacingBefore = 0f; itemTable.SpacingAfter = 0f; itemTable.TotalWidth = 226f; itemTable.LockedWidth = true; //HeaderCell PdfPCell headerCell0 = new PdfPCell(new Phrase("SlNo." , CalculateFont(_billTxtSize))); headerCell0.Colspan = 2; headerCell0.HorizontalAlignment = Element.ALIGN_LEFT; headerCell0.BorderWidth = 0f; itemTable.AddCell(headerCell0); PdfPCell headerCell1 = new PdfPCell(new Phrase("Commodity" , CalculateFont(_billTxtSize))); headerCell1.Colspan = 7; headerCell1.HorizontalAlignment = Element.ALIGN_LEFT; headerCell1.BorderWidth = 0f; itemTable.AddCell(headerCell1); PdfPCell headerCell2 = new PdfPCell(new Phrase("Quantity" , CalculateFont(_billTxtSize))); headerCell2.Colspan = 4; headerCell2.HorizontalAlignment = Element.ALIGN_LEFT; headerCell2.BorderWidth = 0f; itemTable.AddCell(headerCell2); PdfPCell headerCell3 = new PdfPCell(new Phrase("Rate" , CalculateFont(_billTxtSize))); headerCell3.Colspan = 4; headerCell3.HorizontalAlignment = Element.ALIGN_LEFT; headerCell3.BorderWidth = 0f; itemTable.AddCell(headerCell3); PdfPCell headerCell4 = new PdfPCell(new Phrase("Price" , CalculateFont(_billTxtSize))); headerCell4.Colspan = 4; headerCell4.HorizontalAlignment = Element.ALIGN_LEFT; headerCell4.BorderWidth = 0f; itemTable.AddCell(headerCell4); //PdfPCell headerCell5 = new PdfPCell(new Phrase("Discount" // , CalculateFont(_billTxtSize))); //headerCell5.Colspan = 2; //headerCell5.HorizontalAlignment = Element.ALIGN_LEFT; //headerCell5.BorderWidth = 0f; //itemTable.AddCell(headerCell5); int itemCount = 0; foreach (DataGridViewRow item in grdVwItems.Rows) { Product lnItem = (Product)item.DataBoundItem; //_billObj.BillDetails.Add(new BillDetails { ProductsSold = lnItem }); PdfPCell itemCell0 = new PdfPCell(new Phrase((itemCount + 1).ToString() , CalculateFont(_billTxtSize))); itemCell0.Colspan = 2; itemCell0.HorizontalAlignment = Element.ALIGN_LEFT; itemCell0.BorderWidth = 0f; itemTable.AddCell(itemCell0); PdfPCell itemCell1 = new PdfPCell(new Phrase(lnItem.Name , CalculateFont(_billTxtSize))); itemCell1.Colspan = 7; itemCell1.HorizontalAlignment = Element.ALIGN_LEFT; itemCell1.BorderWidth = 0f; itemTable.AddCell(itemCell1); PdfPCell itemCell2 = new PdfPCell(new Phrase(lnItem.ConsumptionQuantityToDisplay , CalculateFont(_billTxtSize))); itemCell2.Colspan = 4; itemCell2.HorizontalAlignment = Element.ALIGN_LEFT; itemCell2.BorderWidth = 0f; itemTable.AddCell(itemCell2); PdfPCell itemCell3 = new PdfPCell(new Phrase(lnItem.SellingRateInCurrentUomDisplay , CalculateFont(_billTxtSize))); itemCell3.Colspan = 4; itemCell3.HorizontalAlignment = Element.ALIGN_LEFT; itemCell3.BorderWidth = 0f; itemTable.AddCell(itemCell3); PdfPCell itemCell4 = new PdfPCell(new Phrase(lnItem.PriceToDisplay , CalculateFont(_billTxtSize))); itemCell4.Colspan = 4; itemCell4.HorizontalAlignment = Element.ALIGN_LEFT; itemCell4.BorderWidth = 0f; itemTable.AddCell(itemCell4); //PdfPCell itemCell5 = new PdfPCell(new Phrase(lnItem.DiscountToDisplay // , CalculateFont(_billTxtSize))); //itemCell5.Colspan = 2; //itemCell5.HorizontalAlignment = Element.ALIGN_LEFT; //itemCell5.BorderWidth = 0f; //itemTable.AddCell(itemCell5); itemCount++; } para.Add(itemTable); //Devider para.Add(new Chunk(" --------------------------------------------------------------------------------------------- " , CalculateFont(_billTxtSize))); float convertedNum = 0; //Total Price PdfPTable priceTable = new PdfPTable(2) { WidthPercentage = 80 }; priceTable.SpacingBefore = 0f; priceTable.SpacingAfter = 0f; //Total _billObj.TotalPrice = float.TryParse(lblCustomerToPayRs.Text, out convertedNum) ? convertedNum : 0; PdfPCell priceCell1 = new PdfPCell(new Phrase(lblTotal.Text , CalculateFont(_billPartHeadingTxtSize))); priceCell1.Colspan = 1; priceCell1.HorizontalAlignment = Element.ALIGN_LEFT; priceCell1.BorderWidth = 0f; PdfPCell priceCell2 = new PdfPCell(new Phrase(lblCustomerToPayRs.Text , CalculateFont(_billPartHeadingTxtSize))); priceCell2.Colspan = 1; priceCell2.HorizontalAlignment = Element.ALIGN_RIGHT; priceCell2.BorderWidth = 0f; priceTable.Rows.Add(new PdfPRow(new PdfPCell[] { priceCell1, priceCell2 })); //Total Roundedoff _billObj.TotalRoundedOff = float.TryParse(lblTotalRsRounded.Text, out convertedNum) ? convertedNum : 0; PdfPCell priceCell3 = new PdfPCell(new Phrase(lblTotalRoundedOff.Text , CalculateFont(_billPartHeadingTxtSize))); priceCell3.Colspan = 1; priceCell3.HorizontalAlignment = Element.ALIGN_LEFT; priceCell3.BorderWidth = 0f; PdfPCell priceCell4 = new PdfPCell(new Phrase(lblTotalRsRounded.Text , CalculateFont(_billPartHeadingTxtSize))); priceCell4.Colspan = 1; priceCell4.HorizontalAlignment = Element.ALIGN_RIGHT; priceCell4.BorderWidth = 0f; priceTable.Rows.Add(new PdfPRow(new PdfPCell[] { priceCell3, priceCell4 })); //Discount _billObj.TotalDiscount = float.TryParse(lblDiscount.Text, out convertedNum) ? convertedNum : 0; //PdfPCell priceCell5 = new PdfPCell(new Phrase(lblDiscountText.Text // , CalculateFont(_billPartHeadingTxtSize))); //priceCell5.Colspan = 1; //priceCell5.HorizontalAlignment = Element.ALIGN_LEFT; //priceCell5.BorderWidth = 0f; //PdfPCell priceCell6 = new PdfPCell(new Phrase(lblDiscount.Text // , CalculateFont(_billPartHeadingTxtSize))); //priceCell6.Colspan = 1; //priceCell6.HorizontalAlignment = Element.ALIGN_RIGHT; //priceCell6.BorderWidth = 0f; //priceTable.Rows.Add(new PdfPRow(new PdfPCell[] { priceCell5, priceCell6 })); //CustomerPaid _billObj.CustomerPaid = float.TryParse(txtCustPaid.Text, out convertedNum) ? convertedNum : 0; PdfPCell priceCell7 = new PdfPCell(new Phrase(lblCustomerPaid.Text , CalculateFont(_billPartHeadingTxtSize))); priceCell7.Colspan = 1; priceCell7.HorizontalAlignment = Element.ALIGN_LEFT; priceCell7.BorderWidth = 0f; PdfPCell priceCell8 = new PdfPCell(new Phrase(txtCustPaid.Text , CalculateFont(_billPartHeadingTxtSize))); priceCell8.Colspan = 1; priceCell8.HorizontalAlignment = Element.ALIGN_RIGHT; priceCell8.BorderWidth = 0f; priceTable.Rows.Add(new PdfPRow(new PdfPCell[] { priceCell7, priceCell8 })); //Balance _billObj.BalanceReturn = float.TryParse(lblBalRs.Text, out convertedNum) ? convertedNum : 0; PdfPCell priceCell9 = new PdfPCell(new Phrase(lblBalance.Text , CalculateFont(_billPartHeadingTxtSize))); priceCell9.Colspan = 1; priceCell9.HorizontalAlignment = Element.ALIGN_LEFT; priceCell9.BorderWidth = 0f; PdfPCell priceCell10 = new PdfPCell(new Phrase(lblBalRs.Text , CalculateFont(_billPartHeadingTxtSize))); priceCell10.Colspan = 1; priceCell10.HorizontalAlignment = Element.ALIGN_RIGHT; priceCell10.BorderWidth = 0f; priceTable.Rows.Add(new PdfPRow(new PdfPCell[] { priceCell9, priceCell10 })); priceTable.CompleteRow(); para.Add(priceTable); //Disclaimer para.Add(new Chunk(" ---------------------------------------------------------------------------------------------- " + Environment.NewLine + "N.B. Please check your item count and quantity, compare with bill and count your cash and balance before leaving the counter." , CalculateFont(_billNotificationTxtSize))); para.Add(new Chunk(Environment.NewLine)); _chnkHeight = 0; _chnkWidth = Utilities.MillimetersToPoints(80); while (true) { _chnkHeight += 10; iTextSharp.text.Document tmpPdfDoc = new iTextSharp.text.Document(new iTextSharp.text.Rectangle(_chnkWidth, _chnkHeight), 0, 0, 0, 0); PdfWriter tmpPdfWriter = PdfWriter.GetInstance(tmpPdfDoc, flStrm); tmpPdfDoc.Open(); tmpPdfDoc.Add(para); if (tmpPdfWriter.PageNumber == 1) { tmpPdfWriter.CloseStream = false; tmpPdfDoc.Close(); tmpPdfWriter.Close(); break; } tmpPdfWriter.CloseStream = false; tmpPdfDoc.Close(); tmpPdfWriter.Close(); } iTextSharp.text.Rectangle pgSize = new iTextSharp.text.Rectangle(_chnkWidth, _chnkHeight); iTextSharp.text.Document pdfDoc = new iTextSharp.text.Document(pgSize, 0, 0, 0, 0); PdfWriter pdfWriter = PdfWriter.GetInstance(pdfDoc, flStrm); pdfDoc.Open(); pdfDoc.Add(para); pdfWriter.CloseStream = true; pdfDoc.Close(); flStrm.Close(); pdfWriter.Close(); } catch (Exception ex) { Logger.LogError(ex); } return(_billObj); }