Example #1
0
 public void DeleteCart(object sender, System.EventArgs e)
 {
     try
     {
         string item_name         = pos.DGV_Items.Rows[pos.DGV_Items.SelectedRows[0].Index].Cells[5].FormattedValue.ToString().Trim();
         int    IndexToStockModel = StockModel.getCode().IndexOf(
             POS_Model.getCode()[
                 POS_Model.getPOS_itemID().IndexOf(
                     pos.DGV_Items.Rows[pos.DGV_Items.SelectedRows[0].Index].Cells[5].FormattedValue.ToString())
             ]
             );
         StockModel.getUnitLeft()[IndexToStockModel] =
             int.Parse(StockModel.getUnitLeft()[StockModel.getStockID().IndexOf(pos.DGV_Items.Rows[pos.DGV_Items.SelectedRows[0].Index].Cells[0].FormattedValue.ToString())].ToString()) +
             int.Parse(pos.DGV_Items.Rows[pos.DGV_Items.SelectedRows[0].Index].Cells[3].FormattedValue.ToString());
         POS_Model.DeleteItemStock(
             POS_Model.getPOS_itemID().IndexOf(
                 pos.DGV_Items.Rows[pos.DGV_Items.SelectedRows[0].Index].Cells[5].FormattedValue.ToString().Trim()
                 )
             );
         MessageBox.Show("Item " + item_name + " successfuly remove!");
         pos.AddItemsData();
     }
     catch (Exception ex) {
         MessageBox.Show("Please choose a row");
     }
     pos.EmptyProductInfo();
 }
        public void AppendCredit()
        {
            //Update unit left in DB
            Update_UnitLeft update_unitLeft = new Update_UnitLeft(
                ItemsModel,
                StockModel
                );

            update_unitLeft.UpdateChecker();
            POS_DB pos_db = new POS_DB();

            for (int count = 0; count < ItemsModel.getItemName().Count; count++)
            {
                pos_db.AddToCredit(
                    CB_CustomerList.Text.Split('/')[1],
                    ItemsModel.getItemName()[count].ToString(),
                    ItemsModel.getCode()[count].ToString(),
                    ItemsModel.getPrice()[count].ToString(),
                    DateTime.Now.ToString(),
                    ItemsModel.getUnit()[count].ToString(),
                    "Unpaid",
                    dh.getUsername() + "/" + dh.getUserFullName(),
                    RTB_Description.Text);
            }
            MessageBox.Show("Successfuly added " + ItemsModel.getItemName().Count + " items to" + CB_CustomerList.Text.Split('/')[0] + " as credit!");
            ItemsModel.ClearCart();
            pos.AddItemsData();
        }
Example #3
0
        public void UpdateChecker()
        {
            /*
             * --Update unit left in DB--
             * Reusable updating unit left
             * in DB from 2 models (POS and Stock)
             */
            POS_DB pos_db = new POS_DB();

            for (int count = 0; count < ItemsModel.getItemName().Count; count++)
            {
                pos_db.UpdateDataUnitLeft(
                    ItemsModel.getCode()[count].ToString(),
                    StockModel.getUnitLeft()[
                        StockModel.getCode().IndexOf(
                            ItemsModel.getCode()[count].ToString()
                            )
                    ].ToString()
                    );
            }
        }