Пример #1
0
        private void addCategoryToItem(int itemID, int categoryID)
        {
            //categories
            DataTable dtcategories = xmlData.Select("categoryID = " + categoryID + " and inventoryItemID = " + itemID, "", "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      = (int)ddCategories.SelectedValue;
                categoryForItem.InventoryItemID = itemID;

                xmlData.Insert(categoryForItem, "data\\" + XmlData.Tables.L_inventoryItemsToCategories.ToString());
            }
        }
Пример #2
0
        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);
            }
        }