/// <summary> /// Fill dropdown with dates of available transactions /// </summary> private void populateTransactionTimes() { if (ddTransactionDates.SelectedItem != null && ddTransactionDates.SelectedIndex > 0) { dgvReport.DataSource = null; Voodoo.Objects.InventoryItem item = null; DataTable dtInventory = xmlData.Select("*", "datecreated asc", "data\\logs\\Transactions_" + ddTransactionDates.SelectedItem, "data\\InventoryItems"); DateTime tempDate; double price = 0; if (dtInventory != null) { pnlNoResults.Visible = false; dgvReport.DataSource = dtInventory; getTotal(); populateGeneralInfo(dtInventory); } else { pnlNoResults.Visible = true; } } }
private void btnCheckout_Click(object sender, EventArgs e) { double.TryParse(txtCashTendered.Text, out cashTendered); change = cashTendered - total; lblChange.Text = change.ToString("N2"); if (change >= 0) { common.OpenDrawer(); btnCheckout.Enabled = false; btnCancel.Text = "Done"; ArrayList cartToSave = arCart; Voodoo.Objects.InventoryItem newCart = new Voodoo.Objects.InventoryItem(); newCart.Name = "New Cart_" + ((CashRegister)this.Owner).Employee.ID.ToString() + "_" + DateTime.Now.ToShortTimeString(); newCart.Description = "Cash Transaction"; newCart.Tax = tax; newCart.Price = total; cartToSave.Insert(0, newCart); common.RecordTransaction(cartToSave); cartToSave.Remove(newCart); } else { MessageBox.Show("There is still a balance of " + change.ToString()); } }
private void btnSave_Click(object sender, EventArgs e) { int quantity = 0; double price = 0; int id = -1; newItem = new Voodoo.Objects.InventoryItem(); while (id < 500) { id = DateTime.Now.Millisecond; } newItem.ID = id; newItem.UPC = txtUpc.Text; newItem.Name = txtName.Text; newItem.Description = txtDescription.Text; newItem.Manufacturer = txtManufacturer.Text; newItem.Color = txtColor.Text; newItem.Model = txtModel.Text; double.TryParse(txtPrice.Text.Trim(), out price); newItem.Price = price; int.TryParse(txtQuantity.Text.Trim(), out quantity); newItem.Quantity = quantity; newItem.Size = txtSize.Text; this.DialogResult = DialogResult.OK; this.Close(); }
public Reports() { InitializeComponent(); DataTable dtInventoryItems = xmlData.Select("*", "name asc", XmlData.Tables.InventoryItems); Voodoo.Objects.InventoryItem item; if (dtInventoryItems != null) { double price = 0; bool onSale = false; double salePrice = 0; foreach (DataRow dr in dtInventoryItems.Rows) { //item = (InventoryItem)dr; item = new Voodoo.Objects.InventoryItem(); item.Name = dr["name"].ToString(); item.UPC = dr["UPC"].ToString(); item.ID = int.Parse(dr["id"].ToString()); double.TryParse(dr["price"].ToString(), out price); item.Price = price; bool.TryParse(dr["onSale"].ToString(), out onSale); item.OnSale = onSale; double.TryParse(dr["salePrice"].ToString(), out salePrice); item.SalePrice = salePrice; ddInventoryItems.Items.Add(item); } } item = new Voodoo.Objects.InventoryItem(); item.Name = "Select an Item to view"; item.UPC = ""; item.ID = -1; ddInventoryItems.Items.Insert(0, item); ddInventoryItems.SelectedIndex = 0; //dtInventoryItems.DefaultView.Sort = "name asc"; //dgvReport.DataSource = dtInventoryItems; //ddInventoryItems.DataSource = dtInventoryItems; //start with displaying the end of day report endOfDayToolStripMenuItem_Click(null, null); common.inventoryUpdated += new Common.InventoryUpdated(common_inventoryUpdated); //set background image //if (File.Exists(Application.StartupPath + Properties.Settings.Default.BackgroundImagePath)) // this.BackgroundImage = Image.FromFile(Application.StartupPath + Properties.Settings.Default.BackgroundImagePath); }
public InventoryItemInfo(Voodoo.Objects.InventoryItem itemToDisplay) { InitializeComponent(); xmlData = new XmlData(Application.StartupPath); NewItem = itemToDisplay; }
private void getAllTransactions(TransactionType transactionType) { DataTable dtTempTable = new DataTable(); DataTable dtMonthlyTransactions = new DataTable(); if (!File.Exists(Application.StartupPath + "\\data\\logs")) { Directory.CreateDirectory(Application.StartupPath + "\\data\\logs"); } foreach (string name in Directory.GetFiles(Application.StartupPath + "\\data\\logs")) { if (name.Contains("\\Transactions_")) { DataTable dtTransactions = xmlData.Select("*", "datecreated asc", "logs\\Transactions_" + name.Substring(name.LastIndexOf("_") + 1).ToLower().Replace(".xml", ""), "InventoryItems"); if (dtMonthlyTransactions.Columns.Count == 0) { dtMonthlyTransactions = dtTransactions.Clone(); } if (dtTransactions != null) { Voodoo.Objects.InventoryItem currentTransactions = new Voodoo.Objects.InventoryItem(); switch (transactionType) { case TransactionType.Cash: case TransactionType.Credit: currentTransactions.Price = getTotal(dtTransactions, transactionType); break; default: currentTransactions.Price = getTotal(dtTransactions); break; } currentTransactions.Name = name.Replace(Application.StartupPath + "\\data\\logs\\Transactions_", ""); DataRow drNew = dtMonthlyTransactions.NewRow(); Type type = currentTransactions.GetType(); var properties = type.GetProperties(); foreach (PropertyInfo property in properties) { drNew[property.Name] = property.GetValue(currentTransactions, null).ToString(); } drNew["DateCreated"] = DateTime.Now; dtMonthlyTransactions.Rows.Add(drNew); } } } dgvReport.DataSource = dtMonthlyTransactions; }
private void populateInventoryDD() { txtSearchBox.Text = ""; ddInventory.Text = ""; ddInventory.Items.Clear(); Voodoo.Objects.InventoryItem item = null; //dtInventoryItems = xmlData.Select("*", "name asc", XmlData.Tables.InventoryItems); double salePrice = 0; double price = 0; bool onSale = false; if (dtInventoryItems == null) { getInventory(); } if (dtInventoryItems != null) { foreach (DataRow dr in dtInventoryItems.Rows) { //item = (Voodoo.Objects.InventoryItem)dr; item = new Voodoo.Objects.InventoryItem(); item.Name = dr["name"].ToString(); item.UPC = dr["UPC"].ToString(); item.ID = int.Parse(dr["id"].ToString()); double.TryParse(dr["price"].ToString(), out price); item.Price = price; bool.TryParse(dr["onSale"].ToString(), out onSale); item.OnSale = onSale; double.TryParse(dr["salePrice"].ToString(), out salePrice); item.SalePrice = salePrice; ddInventory.Items.Add(item); } } item = new Voodoo.Objects.InventoryItem(); item.Name = "Select/Scan an Item"; item.UPC = ""; item.ID = -1; ddInventory.Items.Insert(0, item); ddInventory.SelectedIndex = 0; }
private void dgvEmployees_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { try { if (dgvEmployees.SelectedCells.Count > 0 && dgvEmployees.Rows[dgvEmployees.SelectedCells[0].RowIndex].Cells["items"].Value != null) { Voodoo.Objects.InventoryItem itemToEdit = common.FindItemInInventory(int.Parse(dgvEmployees.Rows[dgvEmployees.SelectedCells[0].RowIndex].Cells["id"].Value.ToString())); EmployeeEdit employeeEditWindow = new EmployeeEdit(dgvEmployees.Rows[dgvEmployees.SelectedCells[0].RowIndex]); employeeEditWindow.ShowDialog(this); } } catch (Exception ex) { Common.WriteToFile(ex); } }
public void PrintLabel(Voodoo.Objects.InventoryItem ItemToPrint) { itemToPrint = ItemToPrint; LabelTemplate labelTemplate = new LabelTemplate(); if (labelTemplate.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (itemToPrint.Quantity > 0 && labelTemplate.SelectedColumnIndex >= 0 && labelTemplate.SelectedRowIndex >= 0) { labelRow = labelTemplate.SelectedRowIndex; labelColumn = labelTemplate.SelectedColumnIndex; numLabelColumns = labelTemplate.NumberOfColumns; PrintDocument labelDoc; // Create the document and name it labelDoc = new PrintDocument(); labelDoc.DocumentName = "Pricing Label"; labelDoc.DefaultPageSettings.Landscape = false; labelDoc.PrintPage += new PrintPageEventHandler(this.printTheLabel); PaperSize paperSize = new PaperSize("Label", 850, 1100); //full 8.5 x 11 page //PaperSize paperSize = new PaperSize("Label", 83, 366); labelDoc.DefaultPageSettings.PaperSize = paperSize; Margins margins = new Margins(10, 5, 35, 15); labelDoc.DefaultPageSettings.Margins = margins; labelDoc.PrinterSettings.PrinterName = "HP Deskjet D4200 series"; #if DEBUG // Preview document System.Windows.Forms.PrintPreviewDialog printPreviewDialog1 = new System.Windows.Forms.PrintPreviewDialog(); printPreviewDialog1.Document = labelDoc; printPreviewDialog1.ShowDialog(); #else //print with no preview labelDoc.Print(); #endif //Dispose of document when done printing labelDoc.Dispose(); } } }
public InventoryItemEdit(Voodoo.Objects.InventoryItem itemToEdit) { InitializeComponent(); common = new Common(Application.StartupPath); common.inventoryUpdated += new Common.InventoryUpdated(common_inventoryUpdated); xmlData = new XmlData(Application.StartupPath); NewItem = itemToEdit; populateCategories(); //set background image if (File.Exists(Application.StartupPath + Properties.Settings.Default.BackgroundImagePath)) { this.BackgroundImage = Image.FromFile(Application.StartupPath + Properties.Settings.Default.BackgroundImagePath); } }
private void dgvItemsToDisplay_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { try { if (dgvItemsToDisplay.SelectedCells.Count > 0 && dgvItemsToDisplay.Rows[dgvItemsToDisplay.SelectedCells[0].RowIndex].Cells["items"].Value != null) { Voodoo.Objects.InventoryItem itemToEdit = common.FindItemInInventory(int.Parse(dgvItemsToDisplay.Rows[dgvItemsToDisplay.SelectedCells[0].RowIndex].Cells["id"].Value.ToString())); editItemWindow = new InventoryItemEdit(itemToEdit); editItemWindow.inventoryUpdated += new InventoryItemEdit.InventoryUpdated(getInventory); editItemWindow.ShowDialog(); populateTransactionDates(); } } catch (Exception ex) { Common.WriteToFile(ex); } }
private void ddInventoryItems_SelectedIndexChanged(object sender, EventArgs e) { //display transaction history for selected item DataTable dtTransactions = null; DataTable dtTemp = null; Voodoo.Objects.InventoryItem selectedItem = (Voodoo.Objects.InventoryItem)ddInventoryItems.SelectedItem; if (selectedItem.ID > -1) { //look through all transactions for the one selected foreach (string file in Directory.GetFiles(Application.StartupPath + "\\data\\logs", "Transactions_*")) { FileInfo fi = new FileInfo(file); dtTemp = xmlData.Select("id = " + selectedItem.ID.ToString(), "", "data\\logs\\" + fi.Name.Replace(".xml", ""), "data\\InventoryItems"); if (dtTemp != null && dtTemp.Rows.Count > 0) { if (dtTransactions == null || dtTransactions.Rows.Count == 0) { dtTransactions = dtTemp.Copy(); } else { foreach (DataRow dr in dtTemp.Rows) { dtTransactions.Rows.Add(dr.ItemArray); } } } } if (dtTransactions != null) { dtTransactions.DefaultView.Sort = "DateCreated desc"; } dgvReport.DataSource = dtTransactions; } }
private void btnCheckout_Click(object sender, EventArgs e) { double.TryParse(txtCashTendered.Text, out cashTendered); change = cashTendered - total; //if (cartTotal > 4.99) //{ //open drawer common.OpenDrawer(); ArrayList cartToSave = arCart; Voodoo.Objects.InventoryItem newCart = new Voodoo.Objects.InventoryItem(); newCart.Name = "New Cart_" + ((CashRegister)this.Owner).Employee.ID.ToString() + "_" + DateTime.Now.ToShortTimeString(); newCart.Description = "Cash for " + cashTendered.ToString("N2") + " and Credit Transaction for " + change.ToString("N2"); newCart.Price = total; cartToSave.Insert(0, newCart); common.RecordTransaction(cartToSave); //updateGiftCertificates(); cartToSave.Remove(newCart); btnCancel.Text = "Done"; ////clear cart //if (MessageBox.Show("Would you like to clear the cart?", "Clear Cart?", MessageBoxButtons.YesNo) == DialogResult.Yes) //{ // arCart.Clear(); // //displayCart(); //} //populateTransactionDates(); //} //else // MessageBox.Show("There is a $5 minimum on credit card transactions"); }
private void setCurrentItem(Voodoo.Objects.InventoryItem item) { lblName.Text = item.Name; lblDescription.Text = item.Description; lblPrice.Text = "$" + item.Price.ToString("N2"); txtQuantity.Text = item.Quantity.ToString(); if (System.IO.File.Exists(item.PicturePath)) { pictureBox1.BackgroundImage = new Bitmap(item.PicturePath); } else { pictureBox1.BackgroundImage = new Bitmap(Application.StartupPath + "\\data\\inventoryImages\\imageNotAvailable.jpg"); } txtDiscountPrice.Text = item.Price.ToString(); txtUpc.Text = item.UPC; currentItem = item; }
private void btnPrintLabel_Click(object sender, EventArgs e) { saveCurrentItem(); Voodoo.Objects.InventoryItem itemToPrint = new Voodoo.Objects.InventoryItem(); itemToPrint = newItem; int numLabels = 0; double price = 0; int.TryParse(txtPrintQuantity.Text.Trim(), out numLabels); itemToPrint.Quantity = numLabels; itemToPrint.Name = txtLabelName.Text.Trim(); double.TryParse(txtLabelPrice.Text.Trim(), out price); itemToPrint.Price = price; Printer printer = new Printer(Application.StartupPath); printer.PrintLabel(itemToPrint); }
private void btnSearch_Click(object sender, EventArgs e) { ddSearchString = txtSearchBox.Text.Trim(); if (ddSearchString.Trim().Length > 0) { ddInventory.Items.Clear(); if (ddSearchString.Length > txtSearchBox.Text.Length + 1) { ddSearchString = txtSearchBox.Text; } Voodoo.Objects.InventoryItem inventoryItemToAdd = new Voodoo.Objects.InventoryItem(); foreach (DataRow dr in dtInventoryItems.Rows) { if (dr["Name"].ToString().ToLower().ToString().StartsWith(ddSearchString, true, System.Globalization.CultureInfo.InvariantCulture) || dr["Name"].ToString().ToLower().ToString().Contains(" " + ddSearchString.ToLower())) { ddInventory.Items.Add(common.FindItemInInventory(int.Parse(dr["id"].ToString()))); } } Voodoo.Objects.InventoryItem item = new Voodoo.Objects.InventoryItem(); item.Name = "Select a FILTERED Item"; item.UPC = ""; item.ID = -1; ddInventory.Items.Insert(0, item); ddInventory.SelectedIndex = 0; } else { populateInventoryDD(); } }
public Discount(Voodoo.Objects.InventoryItem item) { InitializeComponent(); setCurrentItem(item); }
private void btnSave_Click(object sender, EventArgs e) { try { int quantity = 0; double price = 0; double wholesalePrice = 0; double salePrice = 0; //CashRegister register = (CashRegister)this.ParentForm; newItem = new Voodoo.Objects.InventoryItem(); newItem.ID = 999999; newItem.UPC = txtUpc.Text; newItem.Name = txtName.Text; newItem.Description = txtDescription.Text; newItem.Manufacturer = txtManufacturer.Text; newItem.Color = txtColor.Text; newItem.Model = txtModel.Text; newItem.Status = ddStatus.SelectedText; newItem.OnSale = chbOnSale.Checked; newItem.Active = chbActive.Checked; newItem.DisplayOnWeb = chbDisplayOnWeb.Checked; double.TryParse(txtPrice.Text.Trim(), out price); newItem.Price = price; double.TryParse(txtSalePrice.Text.Trim(), out salePrice); newItem.SalePrice = salePrice; double.TryParse(txtWholesalePrice.Text.Trim(), out wholesalePrice); newItem.WholesalePrice = wholesalePrice; int.TryParse(txtQuantity.Text.Trim(), out quantity); newItem.Quantity = quantity; newItem.Size = txtSize.Text; if (System.IO.File.Exists(txtPicturePath.Text.Trim())) { System.IO.FileInfo picturePath = new System.IO.FileInfo(txtPicturePath.Text.Trim()); string newPicturePath = Application.StartupPath + "\\data\\inventoryImages\\" + picturePath.Name; if (!System.IO.File.Exists(newPicturePath)) { newItem.PicturePath = txtPicturePath.Text.Trim(); if (newItem.PicturePath.Length > 0 && !newItem.PicturePath.ToLower().Contains(Application.StartupPath.ToLower() + "\\data\\inventoryimages"))//copy picture to application path { newItem.PicturePath = Application.StartupPath + "\\data\\inventoryImages\\" + picturePath.Name; if (!System.IO.File.Exists(newItem.PicturePath)) { System.IO.File.Copy(picturePath.FullName, newItem.PicturePath); } } } } newItem.ID = common.AddItemToInventory(newItem); foreach (DataRowView dr in lbCategories.Items) { int categoryID = -1; categoryID = int.Parse(dr["id"].ToString()); //categories DataTable dtcategories = xmlData.Select("categoryID = " + categoryID + " and inventoryItemID = " + newItem.ID, "", "data\\" + XmlData.Tables.L_inventoryItemsToCategories.ToString()); if (dtcategories == null) //these values are not in the db { //create new record VoodooPOS.objects.L_inventoryItemsToCategories categoryForItem = new VoodooPOS.objects.L_inventoryItemsToCategories(); categoryForItem.CategoryID = categoryID; categoryForItem.InventoryItemID = newItem.ID; xmlData.Insert(categoryForItem, "data\\" + XmlData.Tables.L_inventoryItemsToCategories.ToString()); } } this.DialogResult = DialogResult.OK; this.Close(); } catch (Exception ex) { Common.WriteToFile(ex); //MessageBox.Show(ex.Message + Environment.NewLine + ex.StackTrace); } }
private void displayInventory() { //Invoke((MethodInvoker)delegate //{ try { dgvItemsToDisplay.Rows.Clear(); Voodoo.Objects.InventoryItem item = null; DataTable dtInventory = xmlData.Select("*", "name asc", XmlData.Tables.InventoryItems); if (dtInventory != null) { foreach (DataRow dr in dtInventory.Rows) { double price = 0; int quantity = 0; int n = dgvItemsToDisplay.Rows.Add(); dgvItemsToDisplay.Rows[n].Cells["id"].Value = dr["id"].ToString(); dgvItemsToDisplay.Rows[n].Cells["UPC"].Value = dr["upc"].ToString(); dgvItemsToDisplay.Rows[n].Cells["quantity"].Value = dr["quantity"].ToString(); dgvItemsToDisplay.Rows[n].Cells["items"].Value = dr["name"].ToString(); double.TryParse(dr["price"].ToString(), out price); int.TryParse(dr["quantity"].ToString(), out quantity); dgvItemsToDisplay.Rows[n].Cells["price"].Value = price.ToString("C"); dgvItemsToDisplay.Rows[n].Cells["subtotal"].Value = (price * quantity).ToString("C"); //featuredItem DataTable dtFeaturedItemIds = xmlData.Select("InventoryItemID = " + dr["id"], "", "data\\" + XmlData.Tables.L_InventoryItemsToFeaturedItems.ToString()); if (dtFeaturedItemIds != null) { dgvItemsToDisplay.Rows[n].Cells["featuredItem"].Value = true; } else { dgvItemsToDisplay.Rows[n].Cells["featuredItem"].Value = false; } //on sale Item DataTable dtOnSaleItemIds = xmlData.Select("InventoryItemID = " + dr["id"], "", "data\\" + XmlData.Tables.L_InventoryItemsToSalesCalendar.ToString()); if (dtOnSaleItemIds != null) { dgvItemsToDisplay.Rows[n].Cells["onsale"].Value = true; } else { dgvItemsToDisplay.Rows[n].Cells["onsale"].Value = false; } } } } catch (Exception ex) { Common.WriteToFile(ex); } //}); }
private void printTheLabel(object sender, PrintPageEventArgs e) { if (itemToPrint != null && itemToPrint.Quantity > 0) { int rowHeight = 100; int columnWidth = 280; int totalSpaces = 200; switch (numLabelColumns) { case (3): rowHeight = 100; columnWidth = 280; totalSpaces = 200; for (int x = 1; x <= itemToPrint.Quantity; x++) { labelCounter++; if (itemToPrint.Name.Length > 9) { totalSpaces = 150; } else { totalSpaces = 200; } Font myFont = new Font("Times New Roman", 12, FontStyle.Regular); //print name Rectangle productName; if (totalSpaces > itemToPrint.Name.Length) { totalSpaces = totalSpaces - itemToPrint.Name.Length; } if (itemToPrint.Name.Length > 20) { productName = new Rectangle(labelColumn * columnWidth + e.MarginBounds.X + (totalSpaces / 2), labelRow * rowHeight + e.MarginBounds.Y + 20, 165, 40); } else { productName = new Rectangle(labelColumn * columnWidth + e.MarginBounds.X + (totalSpaces / 2), labelRow * rowHeight + e.MarginBounds.Y + 20, 165, 20); } e.Graphics.DrawString(itemToPrint.Name, myFont, Brushes.Black, productName); totalSpaces = 200; totalSpaces = totalSpaces - itemToPrint.Price.ToString("C").Length; //print price Rectangle productPrice = new Rectangle(labelColumn * columnWidth + e.MarginBounds.X + (totalSpaces / 2), productName.Y + productName.Height + 10, 175, 20); e.Graphics.DrawString(itemToPrint.Price.ToString("C"), myFont, Brushes.Black, productPrice); labelColumn++; if (labelColumn > 2) { labelColumn = 0; labelRow++; } } break; case (4): rowHeight = 50; columnWidth = 200; totalSpaces = 175; for (int x = 1; x <= itemToPrint.Quantity; x++) { labelCounter++; if (itemToPrint.Name.Length > 9) { totalSpaces = 100; } else { totalSpaces = 175; } Font myFont = new Font("Times New Roman", 11, FontStyle.Regular); //print name Rectangle productName; if (totalSpaces > itemToPrint.Name.Length) { totalSpaces = totalSpaces - itemToPrint.Name.Length; } //if (itemToPrint.Name.Length > 20) // productName = new Rectangle(labelColumn * columnWidth + e.MarginBounds.X + (totalSpaces / 2), labelRow * rowHeight + e.MarginBounds.Y + 20, 175, int.Parse(Math.Round(myFont.GetHeight() * 2,0).ToString())); //else productName = new Rectangle(labelColumn * columnWidth + e.MarginBounds.X + (totalSpaces / 2), labelRow * rowHeight + e.MarginBounds.Y + 20, 175, int.Parse(Math.Round(myFont.GetHeight(), 0).ToString())); e.Graphics.DrawString(itemToPrint.Name, myFont, Brushes.Black, productName); totalSpaces = 175; totalSpaces = totalSpaces - itemToPrint.Price.ToString("C").Length; //print price Rectangle productPrice = new Rectangle(labelColumn * columnWidth + e.MarginBounds.X + (totalSpaces / 2), productName.Y + productName.Height, 175, int.Parse(Math.Round(myFont.GetHeight(), 0).ToString())); e.Graphics.DrawString(itemToPrint.Price.ToString("C"), myFont, Brushes.Black, productPrice); labelColumn++; if (labelColumn > numLabelColumns - 1) { labelColumn = 0; labelRow++; } } break; } itemToPrint = null; } ////save the new default row and column //objects.LabelPrintingSettings settings = new VoodooPOS.objects.LabelPrintingSettings(); //settings.ID = 1; //settings.DateCreated = DateTime.Now; //settings.NumColumns = numLabelColumns; //settings.StartingColumnIndex = labelColumn; //settings.StartingRowIndex = labelRow; //xmlData.Insert(settings, XmlData.Tables.LabelPrintingSettings); }