Exemple #1
0
        /// <summary>
        /// Handles Delete of an item
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void toolBtnDelete_Click(object sender, EventArgs e)
        {
            DataRow drv = gridView1.GetFocusedDataRow();

            if (drv != null)
            {
                Items            itm    = new Items();
                ProductsCategory proCat = new ProductsCategory();
                int itemId = Convert.ToInt32(drv["ID"]);
                if (!itm.HasTransactions(itemId))
                {
                    if (XtraMessageBox.Show("Are You Sure, You want to delete this Transaction? You will not be able to restore this data.", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        proCat.GetCategoryByItem(itemId);
                        foreach (DataRowView drcat in proCat.DefaultView)
                        {
                            ProductsCategory cat = new ProductsCategory();
                            cat.LoadByPrimaryKey(Convert.ToInt32(drcat["ID"]));
                            cat.MarkAsDeleted();
                            cat.Save();
                        }
                        itm.LoadByPrimaryKey(itemId);
                        itm.MarkAsDeleted();
                        itm.Save();
                        XtraMessageBox.Show("Item Deleted!", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    XtraMessageBox.Show("Unable to Delete, This Item has been Received or Issued.", "Unable to Delete", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }
            }
        }
Exemple #2
0
        private void removeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (lstCat.SelectedItems.Count > 0)
            {
                if (lstCat.SelectedItems[0] != null)
                {
                    ProductsCategory prodCate = new ProductsCategory();
                    int id = Convert.ToInt32(lstCat.SelectedItems[0].Tag);

                    if (prodCate.CategoryExists(_itemId, id))
                    {
                        prodCate.GetProductCategory(_itemId, id);
                        prodCate.MarkAsDeleted();
                        prodCate.Save();
                    }
                    lstCat.Items.Remove(lstCat.SelectedItems[0]);
                }
            }
        }