public static LTS.StockRemoved GetStockRemovedItemByID(int?StockRemovedID) { LTS.StockRemoved stockRemoved = new LTS.StockRemoved(); try { using (LTS.LTSBase access = new LTS.LTSDC()) { stockRemoved = access.StockRemoved.Where(o => o.StockRemovedID == StockRemovedID).FirstOrDefault(); } } catch (Exception ex) { } return(stockRemoved); }
public static int AddStockRemoved(LTS.StockRemoved stockRemoved) { int?StockRemovedID = -1; try { using (LTS.LTSBase access = new LTS.LTSDC()) { access.InsertStockRemoved(stockRemoved.DateRemoved, stockRemoved.EmpId, stockRemoved.VIN, ref StockRemovedID); } } catch (Exception ex) { } return(StockRemovedID.Value); }
public static bool UpdateStockRemoved(LTS.StockRemoved stockRemoved) { bool completed = false; try { using (LTS.LTSBase access = new LTS.LTSDC()) { access.UpdateStockRemoved(stockRemoved.DateRemoved, stockRemoved.EmpId, stockRemoved.VIN, stockRemoved.StockRemovedID); completed = true; } } catch (Exception ex) { completed = false; } return(completed); }
private void button2_Click(object sender, EventArgs e) { if (dataGridView1.SelectedRows == null) { } else { if (MessageBox.Show("Are You sure you want to remove this stock Item?" + Environment.NewLine + "The system records which user removes stock.", "", MessageBoxButtons.YesNo) == DialogResult.Yes) { string VIN; using (DataGridViewRow item = this.dataGridView1.SelectedRows[0]) { int i = item.Index; LTS.StockRemoved removing = new LTS.StockRemoved(); removing.VIN = dataGridView1.Rows[i].Cells[0].Value.ToString(); VIN = dataGridView1.Rows[i].Cells[0].Value.ToString(); removing.EmpId = DAT.DataAccess.GetEmployee().Where(o => o.Username == lblloggedInAs.Text).FirstOrDefault().EmpID; removing.DateRemoved = DateTime.Now; DAT.DataAccess.AddStockRemoved(removing); dataGridView1.Rows.RemoveAt(i); bool removed = DAT.DataAccess.RemoveStock(DAT.DataAccess.GetStock().Where(o => o.VIN == VIN).FirstOrDefault().StockID); if (removed) { if (DialogResult.OK == MessageBox.Show("Stock item removed successfully!")) { ((Form1)this.Parent.Parent).ChangeView <Stock1>(); } } else { if (DialogResult.OK == MessageBox.Show("Sorry something went wrong, the stock item was not removed successfully!")) { ((Form1)this.Parent.Parent).ChangeView <Stock1>(); } } } } else { } } }