private void btnPaid_Click(object sender, EventArgs e) { try { long moneyPaid = long.Parse(txtMoneyPaid.Text); double changeToBeGiven = moneyPaid - this.subTotal; if (moneyPaid >= this.subTotal) { lblTotalGiven.Text = ConfigurationDAL.GetCurrentCurrency() + moneyPaid.ToString(); lblChangeToBePaid.Text = ConfigurationDAL.GetCurrentCurrency() + changeToBeGiven.ToString(); btnChangeGiven.Enabled = true; picStatusPayment.Image = global::Shop_Management_Solution.Properties.Resources._1_euro_rotating_lg_nwm1; lastInvoiceID = 0; if (changeToBeGiven > 0) { lblPaymentStatusText.Text = "Money Paid. Give change! "; lblPaymentStatusText.ForeColor = Color.Green; } else { lblPaymentStatusText.Text = "No! Change to give back"; lblPaymentStatusText.ForeColor = Color.ForestGreen; btnChangeGiven.Text = "Move to next"; } } else { throw new Exception("Money can't be less then bill"); } } catch (Exception ex) { MessageBox.Show(this, ex.Message.ToString(), "Error: Money Paid", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void updateTotalPrice(String quantity, String price, String action) { float actualQuantity = float.Parse(quantity); float actualPrice = NumberUtils.SafeParse(price); double totalPrice = actualPrice * actualQuantity; totalPrice = Math.Round(totalPrice, 2); if (action == "ADD") { this.saleTotalPrice = this.saleTotalPrice + totalPrice; this.saleCounter = this.saleCounter + actualQuantity; } else if (action == "REMOVE") { this.saleTotalPrice = this.saleTotalPrice - totalPrice; this.saleCounter = this.saleCounter - actualQuantity; } else { throw new Exception("Invalid Action"); } lblItemCount.Text = this.saleCounter.ToString(); lblTotalPrice.Text = ConfigurationDAL.GetCurrentCurrency() + " " + this.saleTotalPrice; }
private void frmSaleItem_Load(object sender, EventArgs e) { try { bool isExist = ShopDAL.isItemTypeExists(); if (isExist) { ShopDAL db = new ShopDAL(); DataSet ds = db.GetItemsType(); //Creating dictionary to handle available quantity of all items. It's made of pair (Type_ID, Quantity) quantitiesLeft = new Dictionary <string, string>(); foreach (DataRow dr in ds.Tables[0].Rows) { quantitiesLeft.Add(dr["Type_ID"].ToString(), ShopDAL.getStockInHandQuantity(long.Parse(dr["Type_ID"].ToString())).ToString()); } // Inserting Default Row for Selection DataRow defaultRow = ds.Tables[0].NewRow(); defaultRow["Type_ID"] = "0"; defaultRow["Name"] = "---------------- Select Item Type ----------------"; ds.Tables[0].Rows.InsertAt(defaultRow, 0); cmb_itemType.DataSource = ds.Tables[0]; cmb_itemType.DisplayMember = "Name"; cmb_itemType.ValueMember = "Type_ID"; cmb_itemType.SelectedIndex = 0; cmb_itemType.AutoCompleteMode = AutoCompleteMode.Append; cmb_itemType.AutoCompleteSource = AutoCompleteSource.ListItems; lstView_sales.Columns[0].Width = 0; lblItemCount.Text = "0"; lblTotalPrice.Text = ConfigurationDAL.GetCurrentCurrency() + " 0.00"; txtSalePrice.Text = "0"; } } catch (IndexOutOfRangeException ex) { MessageBox.Show(this, "Add atleast one item type to Sale Item(s)", "Error:Sale Item(s)", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } catch (Exception ex) { MessageBox.Show(this, ex.Message.ToString(), "Error:Sale Item(s)", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } //string[] row1 = { "CD-Software", "2", "30" }; //string[] row2 = { "CD-Software", "2", "30" }; /*lstView_sales.Items.Add("1").SubItems.AddRange(row1); * lstView_sales.Items.Add("1").SubItems.AddRange(row2); * * foreach(ListViewItem lvi in lstView_sales.Items) * { * MessageBox.Show(lvi.SubItems[3].Text); * }*/ }
private void frmSearchItem_Load(object sender, EventArgs e) { lblTotalProfit.Text = ConfigurationDAL.GetCurrentCurrency() + " 0.00"; try { bool isExist = ShopDAL.isItemTypeExists(); if (isExist) { ShopDAL db = new ShopDAL(); DataSet ds = db.GetItemsType(); DataRow defaultRow = ds.Tables[0].NewRow(); defaultRow["Type_ID"] = "0"; defaultRow["Name"] = "---------------- Select Item Type ----------------"; ds.Tables[0].Rows.InsertAt(defaultRow, 0); cmb_itemType.DataSource = ds.Tables[0]; cmb_itemType.DisplayMember = "Name"; cmb_itemType.ValueMember = "Type_ID"; cmb_itemType.SelectedIndex = 0; } } catch (IndexOutOfRangeException ex) { MessageBox.Show(this, "Add atleast one item type", "Error:Search Item(s)", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } catch (Exception ex) { MessageBox.Show(this, ex.Message.ToString(), "Error:Search Item(s)", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } setupGridColumns(); setupColumnsWidth(); }
private void currencySettingToolStripMenuItem_Click(object sender, EventArgs e) { frmSettings frmCurrency = new frmSettings(); frmCurrency.ShowDialog(); lblTotalGiven.Text = ConfigurationDAL.GetCurrentCurrency() + " 0.00"; lblTotalPrice.Text = ConfigurationDAL.GetCurrentCurrency() + " 0.00"; lblChangeToBePaid.Text = ConfigurationDAL.GetCurrentCurrency() + " 0.00"; }
private void btn_Clear_Click(object sender, EventArgs e) { dgSearchResults.Rows.Clear(); dgSearchResults.Columns.Clear(); setupGridColumns(); setupColumnsWidth(); lblSoldQuantity.Text = "0"; lblTotalProfit.Text = ConfigurationDAL.GetCurrentCurrency() + " 0.00 "; btPrev.Enabled = false; btNext.Enabled = false; lbPageInfo.Visible = false; }
private void frmMainMenu_Load(object sender, EventArgs e) { lblCurrentDateTime.Text = DateTime.Now.ToLongTimeString().ToString(); lblCurrentDate.Text = DateTime.Now.ToLongDateString().ToString(); objTimer.Interval = 1000; picStatusPayment.Image = global::Shop_Management_Solution.Properties.Resources.waiting_clock; lblTotalGiven.Text = ConfigurationDAL.GetCurrentCurrency() + " 0.00"; lblTotalPrice.Text = ConfigurationDAL.GetCurrentCurrency() + " 0.00"; lblChangeToBePaid.Text = ConfigurationDAL.GetCurrentCurrency() + " 0.00"; txtMoneyPaid.Enabled = false; objTimer.Tick += new EventHandler(_Timer_Tick); objTimer.Start(); }
private void setSummaryData() { double totalSoldQuantity = 0; decimal totalProfit = 0; String startDate = dpStartDate.Value.ToShortDateString(); String endDate = dpEndDate.Value.ToShortDateString(); long itemTypeId = long.Parse(cmb_itemType.SelectedValue.ToString()); totalRecords = ShopDAL.SearchTotalProfitSummary(startDate, endDate, itemTypeId, ref totalSoldQuantity, ref totalProfit); lblSoldQuantity.Text = totalSoldQuantity.ToString(); lblTotalProfit.Text = ConfigurationDAL.GetCurrentCurrency() + " " + totalProfit.ToString(); }
private void btn_SaleItem_Click(object sender, EventArgs e) { frmSaleItem frmSale = new frmSaleItem(); frmSale.ShowDialog(); lblTotalPrice.Text = ConfigurationDAL.GetCurrentCurrency() + frmSale.getSaleTotalPrice(); this.subTotal = frmSale.getSaleTotalPrice(); if (this.subTotal > 0) { btnPaid.Enabled = true; txtMoneyPaid.Enabled = true; picStatusPayment.Image = global::Shop_Management_Solution.Properties.Resources.recieve_cash; lblPaymentStatusText.Text = "Recieve Cash"; lblPaymentStatusText.ForeColor = Color.Green; } }
private void btnChangeGiven_Click(object sender, EventArgs e) { lblTotalPrice.Text = ConfigurationDAL.GetCurrentCurrency() + " 0.00"; lblChangeToBePaid.Text = ConfigurationDAL.GetCurrentCurrency() + " 0.00"; lblTotalGiven.Text = ConfigurationDAL.GetCurrentCurrency() + " 0.00"; btnChangeGiven.Text = "Change given (If any)"; lblPaymentStatusText.Text = "Ready! For Next Sale"; lblPaymentStatusText.ForeColor = Color.Red; this.subTotal = 0; txtMoneyPaid.Text = ""; btnPaid.Enabled = false; btnChangeGiven.Enabled = false; txtMoneyPaid.Enabled = false; picStatusPayment.Image = global::Shop_Management_Solution.Properties.Resources.waiting_clock; lastInvoiceID = 0; }
private void setInvoiceData(Graphics g, System.Drawing.Printing.PrintPageEventArgs e) { List <Sale> saleItems = this.getListofItemsToBeAdded(); // Set Invoice Table: string FieldValue = ""; int CurrentRecord = 0; int RecordsPerPage = 20; // twenty items in a page decimal Amount = 0; bool StopReading = false; // Set Table Head: int xItemName = leftMargin; currentY = currentY + invoiceFontHeight; g.DrawString("Item Name", invoiceFont, blueBrush, xItemName, currentY); int xQuantity = xItemName + (int)g.MeasureString("Quantity", invoiceFont).Width + 72; g.DrawString("Quantity", invoiceFont, blueBrush, xQuantity, currentY); int xUnitPrice = xQuantity + (int)g.MeasureString("Unit Price", invoiceFont).Width + 72; g.DrawString("Unit Price", invoiceFont, blueBrush, xUnitPrice, currentY); currentY = currentY + invoiceFontHeight + 8; foreach (Sale item in saleItems) { FieldValue = item.ItemName; g.DrawString(FieldValue, invoiceFont, blackBrush, xItemName, currentY); FieldValue = item.Quantity + " " + item.UomName; g.DrawString(FieldValue, invoiceFont, blackBrush, xQuantity, currentY); FieldValue = ConfigurationDAL.GetCurrentCurrency() + " " + string.Format("{0:N2}", item.SalePrice); g.DrawString(FieldValue, invoiceFont, blackBrush, xUnitPrice, currentY); currentY = currentY + invoiceFontHeight; } setinvoiceTotal(g); g.Dispose(); }
private void frmSettings_Load(object sender, EventArgs e) { txtCurrencySybmol.Text = ConfigurationDAL.GetCurrentCurrency(); txtShopName.Text = ConfigurationDAL.GetShopName(); txtAddress.Text = ConfigurationDAL.GetCurrentAddress(); try { string defaultFileName = System.Reflection.Assembly.GetExecutingAssembly().Location; string directory = System.IO.Path.GetDirectoryName(defaultFileName); string path = directory + "\\Images\\Header.JPG"; picHeaderImage.Image = ImageUtilities.ResizeImage(new Bitmap(path), 280, 70); txtFileImage.Text = path; } catch (Exception ex) { DebugUtil.genericShow(ex.Message.ToString()); } }
private void performSearch(int startRecordNo, int noOfRecords) { try { String startDate = dpStartDate.Value.ToShortDateString(); String endDate = dpEndDate.Value.ToShortDateString(); long itemTypeId = long.Parse(cmb_itemType.SelectedValue.ToString()); DataTable resultTable = ShopDAL.SearchTotalProfitDS(startDate, endDate, itemTypeId, startRecordNo, noOfRecords).Tables[0]; String[] dataFromTable; //DebugUtil.displayDataSetContents(resultTable.DataSet); dgSearchResults.Columns.Clear(); dgSearchResults.Columns.Add("dcNo", "S.No."); setupGridColumns(); setupColumnsWidth(); int i = startRecordNo + 1; foreach (DataRow dr in resultTable.Rows) { dataFromTable = new String[] { i.ToString(), dr[0].ToString(), dr[1].ToString(), ConfigurationDAL.GetCurrentCurrency() + " " + decimal.Round(decimal.Parse(dr[2].ToString()), 2).ToString(), ConfigurationDAL.GetCurrentCurrency() + " " + decimal.Round(decimal.Parse(dr[3].ToString()), 2).ToString(), dr[4].ToString(), ConfigurationDAL.GetCurrentCurrency() + " " + decimal.Round(decimal.Parse(dr[5].ToString()), 2).ToString(), ConfigurationDAL.GetCurrentCurrency() + " " + decimal.Round(decimal.Parse(dr[6].ToString()), 2).ToString(), ConfigurationDAL.GetCurrentCurrency() + " " + decimal.Round(decimal.Parse(dr[7].ToString()), 2).ToString() }; dgSearchResults.Rows.Add(dataFromTable); i++; } } catch (Exception ex) { dgSearchResults.ClearSelection(); MessageBox.Show(ex.Message); } }
private void setinvoiceTotal(Graphics g) { string fieldValue = ""; string totalQuantity = this.saleCounter.ToString("0.00"); string totalPrice = ConfigurationDAL.GetCurrentCurrency() + " " + this.saleTotalPrice.ToString(); this.saleCounter.ToString(); // Draw line: currentY = currentY + 8; g.DrawLine(new Pen(Brushes.Black), leftMargin, currentY, rightMargin, currentY); invoiceFontHeight = (int)(invoiceFont.GetHeight(g)); // Set Total Quantity: currentX = leftMargin; currentY = currentY + 8; fieldValue = "Total Quantity: " + totalQuantity; g.DrawString(fieldValue, invoiceFont, blackBrush, currentX, currentY); // Set Total Price: currentX = currentX + (int)g.MeasureString(fieldValue, invoiceFont).Width + 25; fieldValue = "Total Price: " + totalPrice; g.DrawString(fieldValue, invoiceFont, blackBrush, currentX, currentY); }
private void btnSaveAsPDF_Click(object sender, EventArgs e) { try { List <Sale> saleItems = this.getListofItemsToBeAdded(); if (saleItems.Count >= 1) { string path = ""; FileDialog dialog = new SaveFileDialog(); dialog.Title = "Save file as..."; long nextInvoiceId = DBUtil.GetNextID("Sale_ID", "Sales"); dialog.FileName = "Sale_No_" + nextInvoiceId.ToString() + "_Dated_" + System.DateTime.Now.Day.ToString() + "-" + System.DateTime.Now.Month.ToString() + "-" + System.DateTime.Now.Year.ToString(); dialog.RestoreDirectory = true; dialog.Filter = "Adobe Acrobat Reader PDF (*.pdf)|*.*"; DialogResult result = dialog.ShowDialog(); if (result == DialogResult.OK) { String saleDate = dateOfSale.Text; long invoiceID = ShopDAL.SaleItems(saleDate, saleItems); path = dialog.FileName; Document myDocument = new Document(PageSize.A4.Rotate()); // step 2: // Now create a writer that listens to this doucment and writes the document to desired Stream. PdfWriter.GetInstance(myDocument, new FileStream(path + ".pdf", FileMode.Create)); // step 3: Open the document now using myDocument.Open(); // step 4: Now add some contents to the document PdfPTable table = new PdfPTable(6); table.WidthPercentage = 50; dateOfSale.Format = DateTimePickerFormat.Long; String displayDate = dateOfSale.Text; //String displayDate = System.DateTime.Now.ToLongDateString() + " " + System.DateTime.Now.ToLongTimeString(); // Printing Header PdfPCell cellShopName = new PdfPCell(new Paragraph(ConfigurationDAL.GetShopName(), new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 14))); table.HorizontalAlignment = Element.ALIGN_LEFT; cellShopName.Colspan = 6; cellShopName.BackgroundColor = new BaseColor(204, 204, 204); cellShopName.BorderColor = new BaseColor(204, 204, 204); cellShopName.HorizontalAlignment = Element.ALIGN_CENTER; table.AddCell(cellShopName); PdfPCell cellAddress = new PdfPCell(new Paragraph("Address: " + ConfigurationDAL.GetCurrentAddress())); cellAddress.Colspan = 6; cellAddress.BackgroundColor = new BaseColor(204, 204, 204); cellAddress.BorderColor = new BaseColor(204, 204, 204); cellAddress.HorizontalAlignment = Element.ALIGN_CENTER; table.AddCell(cellAddress); PdfPCell cellCurrentDate = new PdfPCell(new Paragraph("Dated: " + displayDate)); cellCurrentDate.Colspan = 6; cellCurrentDate.BackgroundColor = new BaseColor(204, 204, 204); cellCurrentDate.BorderColor = new BaseColor(204, 204, 204); cellCurrentDate.HorizontalAlignment = Element.ALIGN_CENTER; table.AddCell(cellCurrentDate); PdfPCell cellInvoiceID = new PdfPCell(new Paragraph("Invoice ID: " + invoiceID.ToString())); cellInvoiceID.Colspan = 6; cellInvoiceID.BackgroundColor = new BaseColor(204, 204, 204); cellInvoiceID.BorderColor = new BaseColor(204, 204, 204); cellInvoiceID.HorizontalAlignment = Element.ALIGN_LEFT; table.AddCell(cellInvoiceID); // Printing Items PdfPCell cellItemHeader = new PdfPCell(new Paragraph("Item")); cellItemHeader.Colspan = 2; table.AddCell(cellItemHeader); PdfPCell cellQuantityHeader = new PdfPCell(new Paragraph("Quantity")); cellQuantityHeader.Colspan = 2; table.AddCell(cellQuantityHeader); PdfPCell cellPriceHeader = new PdfPCell(new Paragraph("Unit Price")); cellPriceHeader.Colspan = 2; table.AddCell(cellPriceHeader); foreach (Sale item in saleItems) { PdfPCell cellItemName = new PdfPCell(new Paragraph(item.ItemName)); cellItemName.Colspan = 2; table.AddCell(cellItemName); PdfPCell cellQuantity = new PdfPCell(new Paragraph(item.Quantity.ToString() + " " + item.UomName)); cellQuantity.Colspan = 2; table.AddCell(cellQuantity); string pricewithUnit = ConfigurationDAL.GetCurrentCurrency() + " " + string.Format("{0:N2}", item.SalePrice); PdfPCell cellPrice = new PdfPCell(new Paragraph(pricewithUnit)); cellPrice.Colspan = 2; table.AddCell(cellPrice); } // Printing Total Quantity and Price PdfPCell cellTotalQtyHeader = new PdfPCell(new Paragraph("Total Quantity ")); cellTotalQtyHeader.Colspan = 2; cellTotalQtyHeader.HorizontalAlignment = Element.ALIGN_RIGHT; cellTotalQtyHeader.BackgroundColor = new BaseColor(200, 200, 200); table.AddCell(cellTotalQtyHeader); PdfPCell cellTotalQtyValue = new PdfPCell(new Paragraph(this.saleCounter.ToString())); cellTotalQtyValue.BackgroundColor = new BaseColor(200, 200, 200); table.AddCell(cellTotalQtyValue); PdfPCell cellTotalPriceHeader = new PdfPCell(new Paragraph("Total Price")); cellTotalPriceHeader.BackgroundColor = new BaseColor(200, 200, 200); table.AddCell(cellTotalPriceHeader); PdfPCell cellTotalPriceValue = new PdfPCell(new Paragraph(ConfigurationDAL.GetCurrentCurrency() + " " + this.saleTotalPrice.ToString())); cellTotalPriceValue.Colspan = 2; cellTotalPriceValue.BackgroundColor = new BaseColor(200, 200, 200); table.AddCell(cellTotalPriceValue); // Printing XtraWebApps Footer PdfPCell cellFooter = new PdfPCell(new Paragraph("Shop Management Solution by www.DeluxeWebApps.com", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 10))); cellFooter.Colspan = 6; cellFooter.HorizontalAlignment = Element.ALIGN_CENTER; table.AddCell(cellFooter); // Add cells to table and close it. myDocument.Add(table); myDocument.Close(); //Launch the PDF Generated. System.Diagnostics.Process.Start(path + ".pdf"); this.Close(); MessageBox.Show(this, "Item sold successfully.", "Sale Item(s)", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { throw new Exception("Please add some item(s) in list"); } } catch (DocumentException de) { MessageBox.Show(de.Message); } catch (IOException ioe) { MessageBox.Show(ioe.Message); } catch (Exception ex) { MessageBox.Show(this, ex.Message.ToString(), "Error: Sale Item(s)", MessageBoxButtons.OK, MessageBoxIcon.Error); } }