Beispiel #1
0
        public CashRegisterDrawer()
        {
            InitializeComponent();

            DataTable dtDrawer        = null;
            DataTable dtDrawerHistory = new DataTable();
            DataTable dtTemp          = null;

            try
            {
                dtDrawer = xmlData.Select("*", "", XmlData.Tables.CashRegisterDrawer);
            }
            catch (Exception ex)
            {
                Common.WriteToFile(ex);
            }

            if (dtDrawer != null)
            {
                cashDrawer = (VoodooPOS.objects.CashRegisterDrawer)Common.CreateObjects.FromDataRow(dtDrawer.Rows[0], new VoodooPOS.objects.CashRegisterDrawer());

                txtCurrentAmount.Text = cashDrawer.Amount.ToString("N");
            }

            try
            {
                foreach (string file in Directory.GetFiles(Application.StartupPath + "\\data\\logs", "CashDrawerHistory_*"))
                {
                    FileInfo fi = new FileInfo(file);

                    dtTemp = xmlData.Select("*", "DateCreated asc", "Data\\logs\\" + fi.Name.Replace(".xml", ""), "Data\\" + XmlData.Tables.CashRegisterDrawer.ToString());

                    if (dtTemp != null && dtTemp.Rows.Count > 0)
                    {
                        if (dtDrawerHistory.Rows.Count == 0)
                        {
                            dtDrawerHistory = dtTemp.Copy();
                        }
                        else
                        {
                            foreach (DataRow dr in dtTemp.Rows)
                            {
                                dtDrawerHistory.Rows.Add(dr.ItemArray);
                            }
                        }
                    }
                }

                dtDrawerHistory.DefaultView.Sort = "DateCreated desc";

                dgvDrawer.DataSource = dtDrawerHistory.DefaultView;
            }
            catch (Exception ex)
            {
                Common.WriteToFile(ex);
            }
        }
Beispiel #2
0
        private void populateSecurityLevels()
        {
            DataTable dtSecurityLevels = xmlData.Select("*", "SecurityLevel asc", XmlData.Tables._SecurityLevels);

            foreach (DataRow dr in dtSecurityLevels.Rows)
            {
                ddSecurityLevels.Items.Add(new VoodooPOS.objects.SecurityLevelClass(dr["SecurityLevel"].ToString() + "-" + dr["Name"].ToString(), int.Parse(dr["SecurityLevel"].ToString())));
            }
        }
Beispiel #3
0
        private void populateCategories()
        {
            DataTable dtCategories = xmlData.Select("*", "category asc", XmlData.Tables.Categories);

            ddCategories.DisplayMember = "category";
            ddCategories.ValueMember   = "id";

            ddCategories.DataSource = dtCategories;
        }
Beispiel #4
0
        private void populateGrid()
        {
            DataTable dtEmployees = xmlData.Select("*", "", XmlData.Tables.Employees);

            if (dtEmployees != null)
            {
                dgvEmployees.DataSource = dtEmployees;
            }
            else //no results
            {
            }
        }
Beispiel #5
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (txtUserName.Text.Trim().Length == 0)
            {
                MessageBox.Show("User Name is required");
            }
            else if (txtPassword.Text.Trim().Length == 0)
            {
                MessageBox.Show("Password is required");
            }
            else
            {
                UserName = txtUserName.Text.Trim();
                Password = txtPassword.Text.Trim();

                dtEmployee = xmlData.Select("username = '******' and password = '******'", "", XmlData.Tables.Employees);

                if (dtEmployee != null)
                {
                    Employee               = new Voodoo.Objects.Employee();
                    Employee.FirstName     = dtEmployee.Rows[0]["firstName"].ToString();
                    Employee.LastName      = dtEmployee.Rows[0]["lastName"].ToString();
                    Employee.EmailAddress  = dtEmployee.Rows[0]["emailAddress"].ToString();
                    Employee.PhoneNumber   = dtEmployee.Rows[0]["phoneNumber"].ToString();
                    Employee.UserName      = dtEmployee.Rows[0]["username"].ToString();
                    Employee.Password      = dtEmployee.Rows[0]["password"].ToString();
                    Employee.SecurityLevel = int.Parse(dtEmployee.Rows[0]["securityLevel"].ToString());
                    Employee.DateCreated   = DateTime.Parse(dtEmployee.Rows[0]["dateCreated"].ToString());

                    this.DialogResult = DialogResult.OK;
                }
                else
                {
                    MessageBox.Show("Invalid login");
                }

                this.Close();
            }
        }
Beispiel #6
0
        private void populateGiftCertificates()
        {
            ddGiftCertificates.Items.Clear();

            DataTable dtGiftCertificates = xmlData.Select("*", "datecreated asc", XmlData.Tables.GiftCertificates);
            DateTime  tempDate;
            double    price = 0;

            if (dtGiftCertificates != null)
            {
                foreach (DataRow dr in dtGiftCertificates.Rows)
                {
                    if (DateTime.TryParse(dr["DateCreated"].ToString(), out tempDate))
                    {
                        double.TryParse(dr["amount"].ToString(), out price);

                        GiftCertificate newGiftCertificate = new GiftCertificate();
                        newGiftCertificate = (GiftCertificate)Common.CreateObjects.FromDataRow(dr, newGiftCertificate);
                        //newGiftCertificate.ID = int.Parse(dr["id"].ToString());
                        //newGiftCertificate.Name = dr["name"].ToString();
                        //newGiftCertificate.Amount = price;
                        //newGiftCertificate.DateCreated = DateTime.Parse(dr["dateCreated"].ToString());

                        //if (dr["displayName"] != null && dr["displayName"].ToString().Length > 0)
                        //    newGiftCertificate.DisplayName = dr["displayName"].ToString();
                        //else
                        //    newGiftCertificate.DisplayName = dr["name"].ToString();

                        //ddGiftCertificates.Items.Add(tempDate.ToShortTimeString() + " " + price.ToString("C"));
                        ddGiftCertificates.Items.Add(newGiftCertificate);
                    }
                }
            }

            ddGiftCertificates.Items.Insert(0, "Choose Gift Certificate To View");
            ddGiftCertificates.SelectedIndex = 0;
        }
Beispiel #7
0
        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);
            }
            //});
        }
Beispiel #8
0
        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);
        }
Beispiel #9
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);
            }
        }