private void btnSave_Click(object sender, EventArgs e) { if (cashDrawer == null) { cashDrawer = new VoodooPOS.objects.CashRegisterDrawer(); cashDrawer.Amount = double.Parse(txtCurrentAmount.Text); cashDrawer.Description = "Cart File didn't exist. Cart Created"; CashDrawerChangeReason reasonForm = new CashDrawerChangeReason(); reasonForm.ShowDialog(); cashDrawer.ReasonForChange = reasonForm.ReasonForChange; xmlData.Insert(cashDrawer, XmlData.Tables.CashRegisterDrawer); } else { double origAmount = cashDrawer.Amount; cashDrawer.Amount = double.Parse(txtCurrentAmount.Text); CashDrawerChangeReason reasonForm = new CashDrawerChangeReason(); reasonForm.ShowDialog(); cashDrawer.ReasonForChange = reasonForm.ReasonForChange; xmlData.Update(cashDrawer, XmlData.Tables.CashRegisterDrawer); cashDrawer.Description = "Drawer amount changed manually from " + origAmount.ToString("C") + " to " + cashDrawer.Amount.ToString("C"); } Common common = new Common(Application.StartupPath); common.WriteToLog("CashDrawerHistory", cashDrawer); this.Close(); }
private void btnSave_Click(object sender, EventArgs e) { Employee = new Voodoo.Objects.Employee(); Employee.ID = employeeID; Employee.FirstName = txtFirstName.Text; Employee.LastName = txtLastName.Text; Employee.EmailAddress = txtEmail.Text; Employee.PhoneNumber = txtPhone.Text; Employee.UserName = txtUsername.Text; Employee.Password = txtPassword.Text; Employee.SecurityLevel = int.Parse(ddSecurityLevels.SelectedValue.ToString()); Employee.DateCreated = DateTime.Parse(txtDateCreated.Text); xmlData.Update(Employee, XmlData.Tables.Employees); this.Close(); }
private void btnActivate_Click(object sender, EventArgs e) { //activate certificate currentGiftCertificate.Status = GiftCertificate.GiftCertificateStatus.Active.ToString(); xmlData.Update(currentGiftCertificate, XmlData.Tables.GiftCertificates); //record the activity for this gift certificate GiftCertificateActivity giftCertificateActivity = new GiftCertificateActivity(); giftCertificateActivity.Activity = "Gift certificate activated"; giftCertificateActivity.GiftCertificateID = currentGiftCertificate.ID; giftCertificateActivity.BeginningBalance = currentGiftCertificate.Amount; giftCertificateActivity.EndingBalance = currentGiftCertificate.Amount; xmlData.Insert(giftCertificateActivity, XmlData.Tables.GiftCertificateActivity); //this.Close(); }
private void saveCurrentItem() { int quantity = 0; double price = 0; double wholesalePrice = 0; double salePrice = 0; //CashRegister register = (CashRegister)this.ParentForm; 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; double.TryParse(txtWholesalePrice.Text.Trim(), out wholesalePrice); newItem.WholesalePrice = wholesalePrice; double.TryParse(txtSalePrice.Text.Trim(), out salePrice); newItem.SalePrice = salePrice; newItem.OnSale = chbOnSale.Checked; newItem.Active = chbActive.Checked; newItem.DisplayOnWeb = chbDisplayOnWeb.Checked; int.TryParse(txtQuantity.Text.Trim(), out quantity); newItem.Quantity = quantity; newItem.Size = txtSize.Text; newItem.PicturePath = txtPicturePath.Text.Trim(); if (newItem.PicturePath.Length > 0 && !newItem.PicturePath.ToLower().Contains(Application.StartupPath.ToLower() + "\\data\\inventoryimages"))//copy picture to application path { System.IO.FileInfo picturePath = new System.IO.FileInfo(txtPicturePath.Text.Trim()); newItem.PicturePath = Application.StartupPath + "\\data\\inventoryImages\\" + picturePath.Name; if (!System.IO.File.Exists(newItem.PicturePath)) { System.IO.File.Copy(picturePath.FullName, newItem.PicturePath); } } common.UpdateItemInInventory(newItem); //featured DataTable dtFeatured = xmlData.Select("InventoryItemID = " + newItem.ID, "", "data\\" + XmlData.Tables.L_InventoryItemsToFeaturedItems.ToString()); if (dtFeatured != null) { if (chbFeatured.Checked) { //update the existing record L_inventoryItemsToFeaturedItems featuredItem = new L_inventoryItemsToFeaturedItems(); featuredItem.Active = chbFeatured.Checked; featuredItem.ExpirationDate = (DateTime)dtFeatured.Rows[0]["ExpirationDate"]; featuredItem.ID = newItem.ID; featuredItem.InventoryItemID = (int)dtFeatured.Rows[0]["InventoryItemID"]; xmlData.Update(featuredItem, XmlData.Tables.L_InventoryItemsToFeaturedItems); } else { xmlData.Delete("InventoryItemID = '" + newItem.ID + "'", XmlData.Tables.L_InventoryItemsToFeaturedItems); } } else if (chbFeatured.Checked) { //create new record L_inventoryItemsToFeaturedItems featuredItem = new L_inventoryItemsToFeaturedItems(); featuredItem.Active = chbFeatured.Checked; featuredItem.InventoryItemID = newItem.ID; xmlData.Insert(featuredItem, "data\\" + XmlData.Tables.L_InventoryItemsToFeaturedItems.ToString()); } //on sale DataTable dtSalesInfo = xmlData.Select("InventoryItemID = " + newItem.ID, "", "data\\" + XmlData.Tables.L_InventoryItemsToSalesCalendar.ToString()); if (dtSalesInfo != null) { if (chbOnSale.Checked) { //update the existing record L_inventoryItemsToSalesCalendar saleItem = new L_inventoryItemsToSalesCalendar(); saleItem.StartDate = dateTimePickerStartDate.Value; saleItem.EndDate = dateTimePickerEndDate.Value; saleItem.ID = newItem.ID; saleItem.InventoryItemID = (int)dtSalesInfo.Rows[0]["InventoryItemID"]; xmlData.Update(saleItem, XmlData.Tables.L_InventoryItemsToFeaturedItems); } else //the item used to be on sale and now it isn't - delete the record { xmlData.Delete("InventoryItemID = '" + newItem.ID + "'", XmlData.Tables.L_InventoryItemsToSalesCalendar); } } else if (chbOnSale.Checked)//the item is on sale - create a new record { //create new record L_inventoryItemsToSalesCalendar saleItem = new L_inventoryItemsToSalesCalendar(); saleItem.StartDate = dateTimePickerStartDate.Value; saleItem.EndDate = dateTimePickerEndDate.Value; saleItem.InventoryItemID = newItem.ID; xmlData.Insert(saleItem, "data\\" + XmlData.Tables.L_InventoryItemsToSalesCalendar.ToString()); } //quick buttons DataTable dtQuickButtons = xmlData.Select("InventoryItemID = " + newItem.ID, "", "data\\" + XmlData.Tables.L_InventoryItemsToQuickButtons.ToString()); if (dtQuickButtons != null) { if (cbQuickButton.Checked) { //update the existing record L_InventoryItemsToQuickButtons quickButtonItem = new L_InventoryItemsToQuickButtons(); quickButtonItem.ID = newItem.ID; quickButtonItem.InventoryItemID = (int)dtSalesInfo.Rows[0]["InventoryItemID"]; xmlData.Update(quickButtonItem, XmlData.Tables.L_InventoryItemsToQuickButtons); } else //delete record { xmlData.Delete("InventoryItemID = '" + newItem.ID + "'", XmlData.Tables.L_InventoryItemsToQuickButtons); } } else if (cbQuickButton.Checked) { //create new record L_InventoryItemsToQuickButtons quickButtonItem = new L_InventoryItemsToQuickButtons(); quickButtonItem.InventoryItemID = newItem.ID; xmlData.Insert(quickButtonItem, "data\\" + XmlData.Tables.L_InventoryItemsToQuickButtons.ToString()); } }