public int Insert(ItemOnhandModel model) { string sql = @"insert into mtl_onhand_quantities_detail (inventory_item_id, organization_id, date_received, last_update_date, last_updated_by, creation_date, created_by, last_update_login, primary_transaction_quantity, catalog_item_id, subinventory_code, revision, locator_id, create_transaction_id, update_transaction_id, lot_number, orig_date_received, cost_group_id, project_id, task_id, organization_type, owning_organization_id, owning_tp_type, planning_organization_id, planning_tp_type, transaction_uom_code, transaction_quantity, reserve_uom_code, reserve_quantity, status_id, BOM_NO, transaction_unit_cost, project_number, project_cost_code) values (@inventory_item_id,@organization_id, @date_received,@last_update_date,@last_updated_by, @creation_date,@created_by,@last_update_login, @primary_transaction_quantity,@catalog_item_id,@subinventory_code, @revision,@locator_id,@create_transaction_id, @update_transaction_id,@lot_number,@orig_date_received, @cost_group_id,@project_id,@task_id, @organization_type,@owning_organization_id,@owning_tp_type, @planning_organization_id,@planning_tp_type,@transaction_uom_code, @transaction_quantity,@reserve_uom_code,@reserve_quantity, @status_id, @BOM_NO, @transaction_unit_cost, @project_number, @project_cost_code)"; return(db.Insert(sql, Take(model))); }
private void Save_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(_view.head.IssueNumber)) { MessageBox.Show("Please Generate Issue Number before save.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } MetroGrid grid = sender as MetroGrid; //bool valid = true; foreach (DataGridViewRow item in grid.Rows) { try { //if (string.IsNullOrEmpty(item.Cells[0].Value.ToString())) //{ double qty = Convert.ToDouble(item.Cells[0].Value); if (qty != 0) { int id = (int)item.Cells["onhandQuantitiesIdDataGridViewTextBoxColumn"].Value; ItemOnhandModel line = _view.onhandsSelected.Where(x => x.OnhandQuantitiesId == id).FirstOrDefault(); GenerateTransaction(line, qty); } //} } catch { } } MessageBox.Show("Issue Completed.", "Result", MessageBoxButtons.OK, MessageBoxIcon.Information); _view.CloseForm(); }
public int InsertOnhand(ItemOnhandModel model) { model.CreationDate = DateTime.Now; model.LastUpdateDate = DateTime.Now; return(factory.ItemOnhandDao.Insert(model)); }
public void Delete(ItemOnhandModel model) { string sql = @"DELETE FROM mtl_onhand_quantities_detail WHERE onhand_quantities_id = @onhand_quantities_id"; object[] parms = { "@onhand_quantities_id", model.OnhandQuantitiesId }; db.Update(sql, parms); }
private void Insert_Cache(object sender, EventArgs e) { MetroGrid grid = sender as MetroGrid; List <ItemOnhandModel> lines = new List <ItemOnhandModel>(); //grid.SelectedRows.DataBoundItem; List <ItemOnhandModel> onhands = _view.onhands.ToList(); if (_view.onhandsCache != null) { lines = _view.onhandsCache.ToList(); } foreach (DataGridViewRow item in grid.Rows) { try { if ((bool)item.Cells[0].Value) { int id = (int)item.Cells[1].Value; //ItemOnhandModel line = _view.onhands.Where(x => x.OnhandQuantitiesId == id).FirstOrDefault(); ItemOnhandModel line = (ItemOnhandModel)item.DataBoundItem; line.IssueProjectNum = string.IsNullOrEmpty(_view.forProjectNo) ? line.ProjectNum : _view.forProjectNo; line.IssueCostCode = string.IsNullOrEmpty(_view.forCostCode) ? line.ProjectCostCode : _view.forCostCode; if (!string.IsNullOrEmpty(_view.forProjectNo) && string.IsNullOrEmpty(_view.forCostCode)) { MessageBox.Show("Please select cost code.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } lines.Add(line); onhands.RemoveAll(x => x.OnhandQuantitiesId == id); } } catch { } } if (lines.Count > 0) { _view.onhandsCache = lines; _view.bindingCache.DataSource = _view.onhandsCache; //_view.BindingCache(_view.onhandsCache.ToList()); _view.onhands = onhands; _view.bindingHead.DataSource = _view.onhands; //_view.BindingData(_view.onhands.ToList()); } else { MessageBox.Show("Please select rows.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
private bool ValidateLines(IEnumerable <POReceiptLineModel> lines) { bool result = true; foreach (var recLine in lines) { if (recLine.QuantityShipped == 0 && _view.headSeleted.ReceiptMethod == "RECEIVE") { MessageBox.Show("PO No. " + recLine.PONum + " Line : " + recLine.POLineNum + " receive qty. = 0", "Validate Line Error", MessageBoxButtons.OK, MessageBoxIcon.Error); result = false; } if (string.IsNullOrEmpty(recLine.ToSubinventory)) { MessageBox.Show("Subinventory is null.", "Validate Line Error", MessageBoxButtons.OK, MessageBoxIcon.Error); result = false; } if (string.IsNullOrEmpty(recLine.ProjectNum)) { MessageBox.Show("Project is null.", "Validate Line Error", MessageBoxButtons.OK, MessageBoxIcon.Error); result = false; } if (_view.headSeleted.ReceiptMethod == "RETURN") { ItemOnhandModel onhand = _repoOnhand.GetDupplicated(recLine.ItemId , recLine.ToSubinventory , recLine.LotNumber , string.IsNullOrEmpty(recLine.Attribute1) ? "999" : recLine.Attribute1 /*Bom Number*/ ); if (onhand != null) { if (Math.Abs(recLine.QuantityShipped) > onhand.PrimaryTransactionQuantity) { MessageBox.Show("Return quantity is not available.", "Validate Line Error", MessageBoxButtons.OK, MessageBoxIcon.Error); result = false; } } } } return(result); }
private bool GenerateTransaction(ItemOnhandModel line, double qty) { MaterialIssueModel Head = _view.head; ItemTransactionModel trans = new ItemTransactionModel(); trans.InventoryItemId = line.InventoryItemId; trans.SubinventoryCode = line.SubinventoryCode; trans.TransactionSourceName = "MATERIAL ISSUE"; trans.TransactionQuantity = qty * -1; trans.TransactionUom = string.IsNullOrEmpty(line.TransactionUomCode) ? "PCS" : line.TransactionUomCode; trans.PrimaryQuantity = qty * -1; trans.TransactionDate = Head.IssueDate; trans.TransactionReference = Head.IssueNumber; //trans.TransactionSourceName trans.TransactionSourceId = line.OnhandQuantitiesId; //Only Materail Issue using ONHAND_QUANTITIES_ID trans.CostedFlag = "Y"; trans.ActualCost = line.TransactionUnitCost; trans.TransactionCost = line.TransactionUnitCost; trans.Attribute1 = string.IsNullOrEmpty(line.IssueProjectNum) ? line.ProjectNum : line.IssueProjectNum; trans.Attribute2 = string.IsNullOrEmpty(line.IssueCostCode) ? line.ProjectCostCode : line.IssueCostCode; trans.Attribute3 = line.LotNumber; trans.Attribute4 = line.BomNo; int id = _repoTrans.InsertTrans(trans); ItemOnhandModel onhand = line; //if (onhand != null) //{ double trxQty = onhand.PrimaryTransactionQuantity - qty; onhand.PrimaryTransactionQuantity = trxQty; onhand.TransactionQuantity = trxQty; onhand.UpdateTransactionId = id; onhand.TransactionUnitCost = trans.ActualCost; _repoOnhand.UpdateOnhand(onhand); //} return(true); }
private object[] Take(ItemOnhandModel model) { return(new object[] { "@onhand_quantities_id", model.OnhandQuantitiesId, "@inventory_item_id", model.InventoryItemId, "@organization_id", model.OrganizationId, "@date_received", model.DateReceived, "@last_update_date", model.LastUpdateDate, "@last_updated_by", model.LastUpdatedBy, "@creation_date", model.CreationDate, "@created_by", model.CreatedBy, "@last_update_login", model.LastUpdateLogin, "@primary_transaction_quantity", model.PrimaryTransactionQuantity, "@catalog_item_id", model.CatalogItemId, "@subinventory_code", model.SubinventoryCode, "@revision", model.Revision, "@locator_id", model.LocatorId, "@create_transaction_id", model.CreateTransactionId, "@update_transaction_id", model.UpdateTransactionId, "@lot_number", model.LotNumber, "@orig_date_received", model.OrigDateReceived, "@cost_group_id", model.CostGroupId, "@project_id", model.ProjectId, "@task_id", model.TaskId, "@organization_type", model.OrganizationType, "@owning_organization_id", model.OwningOrganizationId, "@owning_tp_type", model.OwningTpType, "@planning_organization_id", model.PlanningOrganizationId, "@planning_tp_type", model.PlanningTpType, "@transaction_uom_code", model.TransactionUomCode, "@transaction_quantity", model.TransactionQuantity, "@reserve_uom_code", model.ReserveUomCode, "@reserve_quantity", model.ReserveQuantity, "@status_id", model.StatusId, "@BOM_NO", model.BomNo, "@transaction_unit_cost", model.TransactionUnitCost, "@project_number", model.ProjectNum, "@project_cost_code", model.ProjectCostCode }); }
public void Update(ItemOnhandModel model) { string sql = @"UPDATE mtl_onhand_quantities_detail SET inventory_item_id = @inventory_item_id, organization_id = @organization_id, date_received = @date_received, last_update_date = @last_update_date, last_updated_by = @last_updated_by, last_update_login = @last_update_login, primary_transaction_quantity = @primary_transaction_quantity, catalog_item_id = @catalog_item_id, subinventory_code = @subinventory_code, revision = @revision, locator_id = @locator_id, create_transaction_id = @create_transaction_id, update_transaction_id = @update_transaction_id, lot_number = @lot_number, orig_date_received = @orig_date_received, cost_group_id = @cost_group_id, project_id = @project_id, task_id = @task_id, organization_type = @organization_type, owning_organization_id = @owning_organization_id, owning_tp_type = @owning_tp_type, planning_organization_id = @planning_organization_id, planning_tp_type = @planning_tp_type, transaction_uom_code = @transaction_uom_code, transaction_quantity = @transaction_quantity, reserve_uom_code = @reserve_uom_code, reserve_quantity = @reserve_quantity, status_id = @status_id, BOM_NO = @BOM_NO, transaction_unit_cost = @transaction_unit_cost, project_number = @project_number, project_cost_code = @project_cost_code where onhand_quantities_id = @onhand_quantities_id"; db.Update(sql, Take(model)); }
private bool GenerateTransaction(IEnumerable <POReceiptLineModel> lines) { bool result = true; try { POReceiptHeaderModel recHead = _view.headSeleted; foreach (var recLine in lines) { ItemTransactionModel trans = new ItemTransactionModel(); trans.InventoryItemId = recLine.ItemId; trans.SubinventoryCode = recLine.ToSubinventory; trans.TransactionSourceName = "PO RECEIVING"; trans.TransactionQuantity = recLine.QuantityShipped; trans.TransactionUom = string.IsNullOrEmpty(recLine.UnitOfMeasure) ? "PCS" : recLine.UnitOfMeasure; trans.PrimaryQuantity = recLine.QuantityShipped; trans.TransactionDate = recHead.ReceiptDate; trans.TransactionReference = recHead.ReceiptNum; trans.CostedFlag = "Y"; trans.ActualCost = recLine.ShipmentUnitPrice; trans.TransactionCost = recLine.ShipmentUnitPrice; trans.Attribute1 = recLine.ProjectNum; trans.Attribute2 = recLine.CostCode; trans.Attribute3 = recLine.LotNumber; trans.Attribute4 = recLine.Attribute1; //BOM No. trans.TrxSourceLineId = recLine.ReceiptLineId; trans.TransferSubinventory = recLine.ToSubinventory; //Update po_line_id to task_id For PO line is Job Process. if (recLine.QcRequireInspcFlag) { trans.TaskId = recLine.PoLineId; } int id = _repoTrans.InsertTrans(trans); ItemOnhandModel onhand = _repoOnhand.GetDupplicated(recLine.ItemId , recLine.ToSubinventory , recLine.LotNumber , string.IsNullOrEmpty(recLine.Attribute1) ? "999" : recLine.Attribute1 //If BOM No. is null default '999' ); if (onhand != null) { double trxQty = onhand.PrimaryTransactionQuantity + recLine.QuantityShipped; onhand.PrimaryTransactionQuantity = trxQty; onhand.TransactionQuantity = trxQty; onhand.UpdateTransactionId = id; onhand.TransactionUnitCost = recLine.ShipmentUnitPrice; _repoOnhand.UpdateOnhand(onhand); } else { onhand = new ItemOnhandModel(); onhand.InventoryItemId = recLine.ItemId; onhand.DateReceived = _view.headSeleted.RequestDate; onhand.PrimaryTransactionQuantity = recLine.QuantityShipped; onhand.TransactionQuantity = recLine.QuantityShipped; onhand.SubinventoryCode = recLine.ToSubinventory; onhand.LotNumber = recLine.LotNumber; onhand.TransactionUomCode = recLine.UnitOfMeasure; onhand.CreateTransactionId = id; onhand.UpdateTransactionId = id; onhand.BomNo = string.IsNullOrEmpty(recLine.Attribute1) ? "999" : recLine.Attribute1; //If BOM No. is null default '999' onhand.TransactionUnitCost = recLine.ShipmentUnitPrice; onhand.ProjectId = recLine.ProjectId; onhand.ProjectNum = recLine.ProjectNum; onhand.ProjectCostCode = recLine.CostCode; //Update po_line_id to task_id For PO line is Job Process. if (recLine.QcRequireInspcFlag) { onhand.TaskId = recLine.PoLineId; } int onhandId = _repoOnhand.InsertOnhand(onhand); } } result = true; } catch (Exception ex) { MessageBox.Show("Received process error : ." + Environment.NewLine + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); result = false; } return(result); }
private void GenerateTransaction(ItemTransactionModel line, double qty, string returnNumber, DateTime transactionDate) { //MaterialIssueModel Head = _view.head; ItemTransactionModel trans = new ItemTransactionModel(); trans.InventoryItemId = line.InventoryItemId; trans.SubinventoryCode = line.TransferSubinventory; //Source Subinventory trans.TransferSubinventory = line.TransferSubinventory; trans.TransactionSourceName = "MATERIAL RETURN"; trans.TransactionQuantity = Math.Abs(qty); trans.TransactionUom = line.TransactionUom; trans.PrimaryQuantity = Math.Abs(qty); trans.TransactionDate = transactionDate; trans.TransactionReference = returnNumber; //trans.TransactionSourceName trans.TransactionSourceId = line.TransactionId; //Only Materail Return using transaction_id trans.CostedFlag = "Y"; trans.ActualCost = line.ActualCost; trans.TransactionCost = line.TransactionCost; trans.Attribute1 = line.Attribute1; trans.Attribute2 = line.Attribute2; trans.Attribute3 = line.Attribute3; trans.Attribute4 = line.Attribute4; line.QuantityAdjusted = line.QuantityAdjusted + qty; line.TransactionQuantity = line.TransactionQuantity * -1; line.LastUpdateDate = DateTime.Now; line.LastUpdatedBy = _view.EpiSession.User.Id; _repoTrans.UpdateTrans(line); int id = _repoTrans.InsertTrans(trans); ItemOnhandModel onhand = _repoOnhand.GetDupplicated(line.InventoryItemId , line.TransferSubinventory , line.Attribute3 , string.IsNullOrEmpty(line.Attribute4) ? "999" : line.Attribute4 /*Bom Number*/ ); if (onhand != null) { double trxQty = onhand.PrimaryTransactionQuantity + qty; onhand.PrimaryTransactionQuantity = trxQty; onhand.TransactionQuantity = trxQty; onhand.UpdateTransactionId = id; onhand.TransactionUnitCost = trans.ActualCost; _repoOnhand.UpdateOnhand(onhand); } else { onhand = new ItemOnhandModel(); onhand.InventoryItemId = line.InventoryItemId; onhand.DateReceived = DateTime.Now; onhand.PrimaryTransactionQuantity = qty; onhand.TransactionQuantity = qty; onhand.SubinventoryCode = line.TransferSubinventory; onhand.LotNumber = line.Attribute3; onhand.TransactionUomCode = line.TransactionUom; onhand.CreateTransactionId = id; onhand.UpdateTransactionId = id; onhand.BomNo = string.IsNullOrEmpty(line.Attribute4) ? "999" : line.Attribute4; onhand.TransactionUnitCost = trans.ActualCost; //onhand.ProjectId = ; onhand.ProjectNum = line.Attribute1; onhand.ProjectCostCode = line.Attribute2; int onhandId = _repoOnhand.InsertOnhand(onhand); } }
public void DeleteOnhand(ItemOnhandModel model) { factory.ItemOnhandDao.Delete(model); }
public void UpdateOnhand(ItemOnhandModel model) { model.LastUpdateDate = DateTime.Now; factory.ItemOnhandDao.Update(model); }