Exemple #1
0
        private void dataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 7)
            {
                DialogResult dialogResult = MessageBox.Show("Are you sure?", "", MessageBoxButtons.YesNo);

                if (dialogResult == DialogResult.Yes)
                {
                    int    partID         = int.Parse(dataGridView.CurrentRow.Cells["PartID"].Value.ToString());
                    double minAmount      = db.Parts.SingleOrDefault(m => m.ID == partID).MinimumAmount.Value;
                    double amountSelected = double.Parse(dataGridView.CurrentRow.Cells["Amount"].Value.ToString());
                    double totalAmount    = double.Parse(db.OrderItems.Where(m => m.PartID == partID).Sum(m => m.Amount).ToString());
                    if (totalAmount - amountSelected < minAmount)
                    {
                        MessageBox.Show("This record can't remove");
                    }
                    else
                    {
                        int orderItemID = int.Parse(dataGridView.CurrentRow.Cells["OrderItemID"].Value.ToString());
                        db.OrderItems.Remove(db.OrderItems.SingleOrDefault(m => m.ID == orderItemID));
                        db.SaveChanges();
                        FrmInventoryManagement_Load(sender, e);
                        MessageBox.Show("Done");
                    }
                }
            }
            if (e.ColumnIndex == 6)
            {
                DataGridViewRow row = dataGridView.CurrentRow;
                if (row.Cells["TransactionType"].Value.ToString().Trim() == "Purchase Order")
                {
                    FrmPurchaseOrder frmPurchaseOrder = new FrmPurchaseOrder();
                    frmPurchaseOrder.Tag    = row;
                    frmPurchaseOrder.isEdit = true;
                    frmPurchaseOrder.ShowDialog();
                    FrmInventoryManagement_Load(sender, e);
                }
                else
                {
                    FrmWarehouseManagement frmWarehouse = new FrmWarehouseManagement();
                    frmWarehouse.Tag    = row;
                    frmWarehouse.isEdit = true;
                    frmWarehouse.ShowDialog();
                    FrmInventoryManagement_Load(sender, e);
                }
            }
        }
Exemple #2
0
        private void warehouseManagementToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FrmWarehouseManagement frmWarehouse = new FrmWarehouseManagement();

            frmWarehouse.ShowDialog();
        }