Ejemplo n.º 1
0
        public void Save(bool modifyPurchases = false)
        {
            dbConnect dbCon     = new dbConnect();
            Int32     receiptid = this.ORNumber;

            if (dbCon.CreateReceipt(ref receiptid, this.CashierName, this.TotalAmountDue, this.CashTendered, this.SeniorDiscount, this.ItemDiscount, this.Accountid, this.TransDate) == false)
            {
                return;
            }
            if (this.ORNumber != receiptid || this.ORNumber == receiptid && modifyPurchases)
            {
                this.ORNumber = receiptid;

                dbCon.RemoveFromHistory(this._ORNumber);
                foreach (KeyValuePair <string, clsPurchasedItem> purchaseditem in _lstPurchasedItems)
                {
                    if (purchaseditem.Value.Qty > 0)
                    {
                        purchaseditem.Value.ORNumber = this.ORNumber;
                        if (dbCon.AddTransaction(purchaseditem.Value))
                        {
                            clsProductItem prod = clsProductItem.SearchProduct(purchaseditem.Value.BarCode);
                            prod.QtySold += purchaseditem.Value.Qty;
                            prod.Save();
                        }
                    }
                }
            }
            this.ORNumber = receiptid;

            dbCon.Close();
        }
Ejemplo n.º 2
0
        public static clsProductItem SearchProduct(string barcode)
        {
            dbConnect      connect = new dbConnect();
            clsProductItem item    = connect.GetProductItem(barcode);

            connect.Close();
            return(item);
        }
Ejemplo n.º 3
0
        public string UpdateInventoryFromTemp(List <clsProductItem> lstProdItems, string username)
        {
            Receipt      m_receipt = new Receipt();
            frmTempTrans tmp       = new frmTempTrans(clsUsers.GetUser(username));

            if (tmp.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                if (tmp.SelectedTempOR != null)
                {
                    m_receipt = tmp.SelectedTempOR;
                }
            }

            Dictionary <string, clsProductItem> dicProd = new Dictionary <string, clsProductItem>();

            foreach (clsProductItem c in lstProdItems)
            {
                if (dicProd.ContainsKey(c.BarCode) == false)
                {
                    dicProd.Add(c.BarCode.Trim(), c);
                }
            }
            frmProgress progress = new frmProgress(lstProdItems.Count);

            progress.Caption       = "Update in Progress";
            progress.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            progress.Show();

            foreach (KeyValuePair <string, clsPurchasedItem> p in m_receipt.PurchasedItems)
            {
                progress.Val++;
                if (dicProd.ContainsKey(p.Key))
                {
                    clsProductItem prod = dicProd[p.Key];
                    if (prod.StocksRemainingQty != p.Value.Qty)
                    {
                        double addQtyToInventory = p.Value.Qty - prod.StocksRemainingQty;

                        clsInventory itemIventory = new clsInventory();
                        itemIventory.BarCode   = prod.BarCode;
                        itemIventory.Capital   = prod.Capital;
                        itemIventory.Quantity  = addQtyToInventory;
                        itemIventory.DateAdded = DateTime.Now;
                        itemIventory.Remarks   = string.Format("{0}: TotInv={1} + {2}", username, prod.StocksRemainingQty, addQtyToInventory);
                        itemIventory.Save();

                        prod.TotalInventoryQty += addQtyToInventory;
                        prod.Save();
                    }
                }
                progress.Close();
                m_receipt.DeleteTempReceipt();
            }
            return("");
        }
Ejemplo n.º 4
0
 public clsPurchasedItem(clsProductItem item, bool iswholesale = false)
 {
     _Amount      = iswholesale? item.WSAmount:item.Amount;
     _Qty         = 1;
     _Unit        = item.Unit;
     _Description = item.Description;
     _BarCode     = item.BarCode;
     _IsWholeSale = iswholesale;
     _UserID      = item.UserID;
     _Discount    = 0;
     _Capital     = item.Capital;
     _InStorage   = item.InStorage;
     _Category    = item.Category;
 }
Ejemplo n.º 5
0
        public string UpdateInventory(string filename, List <clsProductItem> lstProdItems, string username)
        {
            Workbook  xlsBook  = new Workbook();
            Worksheet xlsSheet = null;

            if (File.Exists(filename))
            {
                xlsBook.LoadFromFile(filename);
            }

            Dictionary <string, clsProductItem> dicProd = new Dictionary <string, clsProductItem>();

            foreach (clsProductItem c in lstProdItems)
            {
                if (dicProd.ContainsKey(c.BarCode) == false)
                {
                    dicProd.Add(c.BarCode.Trim(), c);
                }
            }
            Dictionary <int, string> categories = dbConnect.GetCategories();

            foreach (Worksheet sheet in xlsBook.Worksheets)
            {
                xlsSheet = sheet;
                if (xlsSheet[1, 1].Value.Trim() == "Barcode" && xlsSheet[1, 2].Value.Trim() == "Description" &&
                    xlsSheet[1, 3].Value.Trim() == "Capital" && xlsSheet[1, 4].Value.Trim() == "Retail Amount" && xlsSheet[1, 5].Value.Trim() == "Wholesale Amount" &&
                    xlsSheet[1, 6].Value.Trim() == "Category" && xlsSheet[1, 7].Value.Trim() == "Total Inventory" && xlsSheet[1, 8].Value.Trim() == "Quantity Sold" &&
                    xlsSheet[1, 9].Value.Trim() == "Remaining Quantity" && xlsSheet[1, 10].Value.Trim() == "Actual Qty" && xlsSheet[1, 11].Value.Trim() == "Difference")
                {
                    int ctr = 2;

                    frmProgress progress = new frmProgress(lstProdItems.Count);
                    progress.Caption       = "Update in Progress";
                    progress.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
                    progress.Show();

                    while (xlsSheet[ctr, 1].Value != "")
                    {
                        progress.Val += 1;
                        if (dicProd.ContainsKey(xlsSheet[ctr, 1].Value.Trim()))
                        {
                            clsProductItem prod = dicProd[xlsSheet[ctr, 1].Value.Trim()];
                            try
                            {
                                double addQtyToInventory = Convert.ToDouble(xlsSheet[ctr, 10].Value) - prod.StocksRemainingQty;
                                if (prod.Description != xlsSheet[ctr, 2].Value.Trim() || prod.Capital != double.Parse(xlsSheet[ctr, 3].Value.Trim()) ||
                                    prod.Amount != double.Parse(xlsSheet[ctr, 4].Value.Trim()) || prod.WSAmount != double.Parse(xlsSheet[ctr, 5].NumberText) ||
                                    Convert.ToDouble(xlsSheet[ctr, 10].Value) != prod.StocksRemainingQty || xlsSheet[ctr, 6].Value.Trim() != prod.Category)
                                {
                                    if (Convert.ToDouble(xlsSheet[ctr, 10].Value) - prod.StocksRemainingQty != 0)
                                    {
                                        clsInventory itemIventory = new clsInventory();
                                        itemIventory.BarCode   = prod.BarCode;
                                        itemIventory.Capital   = prod.Capital;
                                        itemIventory.Quantity  = addQtyToInventory;
                                        itemIventory.DateAdded = DateTime.Now;
                                        itemIventory.Remarks   = string.Format("{0}: TotInv={1} + {2}", username, prod.StocksRemainingQty, addQtyToInventory);
                                        itemIventory.Save();

                                        prod.Description        = xlsSheet[ctr, 2].Value.Trim();
                                        prod.Capital            = double.Parse(xlsSheet[ctr, 3].Value.Trim());
                                        prod.Amount             = double.Parse(xlsSheet[ctr, 4].Value.Trim());
                                        prod.WSAmount           = double.Parse(xlsSheet[ctr, 5].NumberText);
                                        prod.TotalInventoryQty += addQtyToInventory;
                                        if (categories.ContainsValue(xlsSheet[ctr, 6].Value.Trim()) == false)
                                        {
                                            dbConnect.AddCategory(xlsSheet[ctr, 6].Value.Trim());
                                            categories = dbConnect.GetCategories();
                                        }

                                        if (categories != null && categories.ContainsValue(xlsSheet[ctr, 6].Value.Trim()))
                                        {
                                            foreach (KeyValuePair <int, string> str in categories)
                                            {
                                                if (str.Value == xlsSheet[ctr, 6].Value.Trim())
                                                {
                                                    prod.CategoryId = str.Key;
                                                    break;
                                                }
                                            }
                                        }

                                        prod.Save();
                                    }
                                }
                            }
                            catch { }
                        }
                        else
                        {
                            clsProductItem proditem = new clsProductItem();
                            proditem.BarCode       = xlsSheet[ctr, 1].Value.Trim().ToUpper();
                            proditem.Description   = xlsSheet[ctr, 2].Value.Trim();
                            proditem.Amount        = double.Parse(xlsSheet[ctr, 4].Value.Trim());
                            proditem.WSAmount      = double.Parse(xlsSheet[ctr, 5].Value.Trim());
                            proditem.WSMinimum     = 0;
                            proditem.Capital       = double.Parse(xlsSheet[ctr, 3].Value.Trim());
                            proditem.Imagepath     = "";
                            proditem.Unit          = "pc";
                            proditem.InStorage     = 0;
                            proditem.CriticalLevel = 5;
                            proditem.QtySold       = 0;

                            clsInventory itemIventory = new clsInventory();
                            itemIventory.BarCode   = proditem.BarCode;
                            itemIventory.Capital   = proditem.Capital;
                            itemIventory.DateAdded = DateTime.Now;
                            itemIventory.Quantity  = Convert.ToDouble(xlsSheet[ctr, 10].Value);
                            itemIventory.Remarks   = string.Format("{0}: TotInv={1} + {2}", username, 0, itemIventory.Quantity);
                            itemIventory.Save();
                            proditem.TotalInventoryQty = itemIventory.Quantity;
                            if (categories.ContainsValue(xlsSheet[ctr, 6].Value.Trim()) == false)
                            {
                                dbConnect.AddCategory(xlsSheet[ctr, 6].Value.Trim());
                                categories = dbConnect.GetCategories();
                            }
                            if (categories != null && categories.ContainsValue(xlsSheet[ctr, 6].Value.Trim()))
                            {
                                foreach (KeyValuePair <int, string> str in categories)
                                {
                                    if (str.Value == xlsSheet[ctr, 6].Value.Trim())
                                    {
                                        proditem.CategoryId = str.Key;
                                        break;
                                    }
                                }
                            }
                            proditem.Save();
                        }
                        ctr++;
                    }
                    progress.Close();
                }

                break;
            }

            return("");
        }