public async Task <ActionResult <InventoryTransferLine> > Delete([FromBody] InventoryTransferLine _ContratoDetalle) { try { List <InventoryTransferLine> _Contrato_DetalleLIST = JsonConvert.DeserializeObject <List <InventoryTransferLine> >(HttpContext.Session.GetString("listadoproductos")); if (_Contrato_DetalleLIST != null) { _Contrato_DetalleLIST = _Contrato_DetalleLIST .Where(q => q.Id != _ContratoDetalle.Id) //.Where(q => q.ContratoId != _ContratoDetalle.ContratoId) .Where(q => q.ProductId != _ContratoDetalle.ProductId) .ToList(); HttpContext.Session.SetString("listadoproductos", JsonConvert.SerializeObject(_Contrato_DetalleLIST)); } } catch (Exception ex) { _logger.LogError($"Ocurrio un error: { ex.ToString() }"); return(BadRequest($"Ocurrio un error: {ex.Message}")); } return(await Task.Run(() => Ok(_ContratoDetalle))); //return new ObjectResult(new DataSourceResult { Data = new[] { _ContratoDetalle }, Total = 1 }); }
public async Task <ActionResult <InventoryTransfer> > Update([FromBody] InventoryTransfer _InventoryTransfer) { InventoryTransfer _InventoryTransferq = _InventoryTransfer; int a = _InventoryTransfer.InventoryTransferLines.Count(); try { for (int i = 0; i < a; i++) { InventoryTransferLine InventoryTransferLine = new InventoryTransferLine(); InventoryTransferLine = await(from c in _context.InventoryTransferLine .Where(q => q.Id == _InventoryTransfer.InventoryTransferLines[i].Id) select c).FirstOrDefaultAsync(); _context.Entry(InventoryTransferLine).CurrentValues.SetValues(_InventoryTransfer.InventoryTransferLines[i]); } _InventoryTransferq = await(from c in _context.InventoryTransfer .Where(q => q.Id == _InventoryTransfer.Id) select c ).FirstOrDefaultAsync(); _context.Entry(_InventoryTransferq).CurrentValues.SetValues((_InventoryTransfer)); //_context.InventoryTransfer.Update(_InventoryTransferq); await _context.SaveChangesAsync(); } catch (Exception ex) { _logger.LogError($"Ocurrio un error: { ex.ToString() }"); return(BadRequest($"Ocurrio un error:{ex.Message}")); } return(await Task.Run(() => Ok(_InventoryTransferq))); }
public async Task <IActionResult> GetInventoryTransferLineById(Int64 InventoryTransferLineId) { InventoryTransferLine Items = new InventoryTransferLine(); try { Items = await _context.InventoryTransferLine.Where(q => q.Id == InventoryTransferLineId).FirstOrDefaultAsync(); } catch (Exception ex) { _logger.LogError($"Ocurrio un error: { ex.ToString() }"); return(await Task.Run(() => BadRequest($"Ocurrio un error:{ex.Message}"))); } return(await Task.Run(() => Ok(Items))); }
public async Task <ActionResult <InventoryTransferLine> > Insert([FromBody] InventoryTransferLine _InventoryTransferLine) { InventoryTransferLine _InventoryTransferLineq = new InventoryTransferLine(); try { _InventoryTransferLineq = _InventoryTransferLine; _context.InventoryTransferLine.Add(_InventoryTransferLineq); await _context.SaveChangesAsync(); } catch (Exception ex) { _logger.LogError($"Ocurrio un error: { ex.ToString() }"); return(await Task.Run(() => BadRequest($"Ocurrio un error:{ex.Message}"))); } return(await Task.Run(() => Ok(_InventoryTransferLineq))); }
protected override OpResult _Store(InventoryTransferLine _obj) { if (_obj == null) { return(OpResult.NotifyStoreAction(OpResult.ResultStatus.ObjectIsNull, _obj, "InventoryTransferLine object cannot be created as it is null")); } if (Exists(_obj)) { ExecuteNonQuery(GetQuery_UpdateQuery(_obj)); return(OpResult.NotifyStoreAction(OpResult.ResultStatus.Updated, _obj)); } ExecuteNonQuery(GetQuery_InsertQuery(_obj)); if (_obj.InventoryTransferLineID == null) { _obj.InventoryTransferLineID = DbMgr.GetLastInsertID(); } _obj.FromDb = true; return(OpResult.NotifyStoreAction(OpResult.ResultStatus.Created, _obj)); }
public async Task <IActionResult> Delete([FromBody] InventoryTransferLine _InventoryTransferLine) { InventoryTransferLine _InventoryTransferLineq = new InventoryTransferLine(); try { _InventoryTransferLineq = _context.InventoryTransferLine .Where(x => x.Id == (Int64)_InventoryTransferLine.Id) .FirstOrDefault(); _context.InventoryTransferLine.Remove(_InventoryTransferLineq); await _context.SaveChangesAsync(); } catch (Exception ex) { _logger.LogError($"Ocurrio un error: { ex.ToString() }"); return(await Task.Run(() => BadRequest($"Ocurrio un error:{ex.Message}"))); } return(await Task.Run(() => Ok(_InventoryTransferLineq))); }
public async Task <ActionResult <InventoryTransferLine> > Update([FromBody] InventoryTransferLine _InventoryTransferLine) { InventoryTransferLine _InventoryTransferLineq = _InventoryTransferLine; try { _InventoryTransferLineq = await(from c in _context.InventoryTransferLine .Where(q => q.Id == _InventoryTransferLine.Id) select c ).FirstOrDefaultAsync(); _context.Entry(_InventoryTransferLineq).CurrentValues.SetValues((_InventoryTransferLine)); //_context.InventoryTransferLine.Update(_InventoryTransferLineq); await _context.SaveChangesAsync(); } catch (Exception ex) { _logger.LogError($"Ocurrio un error: { ex.ToString() }"); return(await Task.Run(() => BadRequest($"Ocurrio un error:{ex.Message}"))); } return(await Task.Run(() => Ok(_InventoryTransferLineq))); }
public async Task <DataSourceResult> GetInventoryTransferLine([DataSourceRequest] DataSourceRequest request, InventoryTransferLine _ContratoDetallep) { List <InventoryTransferLine> _ContratoDetalle = new List <InventoryTransferLine>(); try { string baseadress = config.Value.urlbase; HttpClient _client = new HttpClient(); if (HttpContext.Session.Get("listadoproductos") == null || HttpContext.Session.GetString("listadoproductos") == "") { if (_ContratoDetallep.InventoryTransferId > 0) { string serialzado = JsonConvert.SerializeObject(_ContratoDetallep).ToString(); HttpContext.Session.SetString("listadoproductos", serialzado); } } else { _ContratoDetallep.UsuarioCreacion = HttpContext.Session.GetString("user"); _ContratoDetallep.UsuarioModificacion = HttpContext.Session.GetString("user"); _ContratoDetallep.FechaCreacion = DateTime.Now; _ContratoDetallep.FechaModificacion = DateTime.Now; _ContratoDetalle = JsonConvert.DeserializeObject <List <InventoryTransferLine> >(HttpContext.Session.GetString("listadoproductos")); } if (_ContratoDetallep.InventoryTransferId > 0) { _client.DefaultRequestHeaders.Add("Authorization", "Bearer " + HttpContext.Session.GetString("token")); var result = await _client.GetAsync(baseadress + "api/InventoryTransferLine/GetInventoryTransferLineByInventoryTransferId/" + _ContratoDetallep.InventoryTransferId); string valorrespuesta = ""; if (result.IsSuccessStatusCode) { valorrespuesta = await(result.Content.ReadAsStringAsync()); _ContratoDetalle = JsonConvert.DeserializeObject <List <InventoryTransferLine> >(valorrespuesta); } } else { List <InventoryTransferLine> _existelinea = new List <InventoryTransferLine>(); if (HttpContext.Session.GetString("listadoproductos") != "" && HttpContext.Session.GetString("listadoproductos") != null) { _ContratoDetalle = JsonConvert.DeserializeObject <List <InventoryTransferLine> >(HttpContext.Session.GetString("listadoproductos")); _existelinea = _ContratoDetalle.Where(q => q.Id == _ContratoDetallep.InventoryTransferId).ToList(); } var id = _ContratoDetallep.Id; if (_ContratoDetalle.Count > 0) { id--; foreach (var item in _ContratoDetalle) { if (item.ProductId == _ContratoDetallep.ProductId) { item.QtyStock = item.QtyStock + _ContratoDetallep.QtyStock; HttpContext.Session.SetString("listadoproductos", JsonConvert.SerializeObject(_ContratoDetalle).ToString()); break; } else if (item.Id == id && _existelinea.Count == 0) { _ContratoDetalle.Add(_ContratoDetallep); HttpContext.Session.SetString("listadoproductos", JsonConvert.SerializeObject(_ContratoDetalle).ToString()); break; } } } else if (_ContratoDetallep.Id > 0 && _existelinea.Count == 0) { _ContratoDetalle.Add(_ContratoDetallep); HttpContext.Session.SetString("listadoproductos", JsonConvert.SerializeObject(_ContratoDetalle).ToString()); } else { var obj = _ContratoDetalle.Where(x => x.Id == _ContratoDetallep.Id).FirstOrDefault(); if (obj != null) { obj.ProductId = _ContratoDetallep.ProductId; obj.QtyStock = _ContratoDetallep.QtyStock; //obj.DiscountAmount = _ContratoDetallep.DiscountAmount; //obj.DiscountPercentage = _ContratoDetallep.DiscountPercentage; } HttpContext.Session.SetString("listadoproductos", JsonConvert.SerializeObject(_ContratoDetalle).ToString()); } } } catch (Exception ex) { _logger.LogError($"Ocurrio un error: { ex.ToString() }"); throw ex; } return(_ContratoDetalle.ToDataSourceResult(request)); }
private void PurchaseOrderReceiptAction_Execute(object sender, SimpleActionExecuteEventArgs e) { try { GlobalFunction _globFunc = new GlobalFunction(); IObjectSpace _objectSpace = View is ListView?Application.CreateObjectSpace() : View.ObjectSpace; ArrayList _objectsToProcess = new ArrayList(e.SelectedObjects); DateTime now = DateTime.Now; Session _currSession = null; string _currObjectId = null; string _locDocCode = null; ProjectHeader _locProjectHeader = null; if (this.ObjectSpace != null) { _currSession = ((XPObjectSpace)this.ObjectSpace).Session; } if (_objectsToProcess != null) { foreach (Object obj in _objectsToProcess) { PurchaseOrder _locPurchaseOrderOS = (PurchaseOrder)_objectSpace.GetObject(obj); if (_locPurchaseOrderOS != null) { if (_locPurchaseOrderOS.Code != null) { _currObjectId = _locPurchaseOrderOS.Code; PurchaseOrder _locPurchaseOrderXPO = _currSession.FindObject <PurchaseOrder> (new GroupOperator(GroupOperatorType.And, new BinaryOperator("Code", _currObjectId), new BinaryOperator("Status", Status.Progress))); if (_locPurchaseOrderXPO != null) { if (_locPurchaseOrderXPO.ProjectHeader != null) { _locProjectHeader = _locPurchaseOrderXPO.ProjectHeader; } DocumentType _locDocumentTypeXPO = _currSession.FindObject <DocumentType> (new GroupOperator(GroupOperatorType.And, new BinaryOperator("DirectionType", DirectionType.External), new BinaryOperator("InventoryMovingType", InventoryMovingType.Receive), new BinaryOperator("ObjectList", ObjectList.InventoryTransfer), new BinaryOperator("DocumentRule", DocumentRule.Vendor), new BinaryOperator("Active", true), new BinaryOperator("Default", true))); if (_locDocumentTypeXPO != null) { _locDocCode = _globFunc.GetDocumentNumberingUnlockOptimisticRecord(_currSession.DataLayer, _locDocumentTypeXPO); if (_locDocCode != null) { InventoryTransfer _saveDataIT = new InventoryTransfer(_currSession) { DirectionType = _locDocumentTypeXPO.DirectionType, InventoryMovingType = _locDocumentTypeXPO.InventoryMovingType, ObjectList = _locDocumentTypeXPO.ObjectList, DocumentType = _locDocumentTypeXPO, DocNo = _locDocCode, EstimatedDate = _locPurchaseOrderXPO.EstimatedDate, PurchaseOrder = _locPurchaseOrderXPO, ProjectHeader = _locProjectHeader }; _saveDataIT.Save(); _saveDataIT.Session.CommitTransaction(); InventoryTransfer _locInventoryTransfer = _currSession.FindObject <InventoryTransfer> (new GroupOperator(GroupOperatorType.And, new BinaryOperator("DocNo", _locDocCode), new BinaryOperator("PurchaseOrder", _locPurchaseOrderXPO), new BinaryOperator("ProjectHeader", _locProjectHeader))); if (_locInventoryTransfer != null) { XPCollection <PurchaseOrderLine> _locPurchaseOrderLines = new XPCollection <PurchaseOrderLine> (_currSession, new GroupOperator(GroupOperatorType.And, new BinaryOperator("PurchaseOrder", _locPurchaseOrderXPO), new BinaryOperator("Status", Status.Progress))); if (_locPurchaseOrderLines != null && _locPurchaseOrderLines.Count > 0) { foreach (PurchaseOrderLine _locPurchaseOrderLine in _locPurchaseOrderLines) { InventoryTransferLine _saveDataInventoryTransferLine = new InventoryTransferLine(_currSession) { Item = _locPurchaseOrderLine.Item, MxDQty = _locPurchaseOrderLine.DQty, MxDUOM = _locPurchaseOrderLine.DUOM, MxQty = _locPurchaseOrderLine.Qty, MxUOM = _locPurchaseOrderLine.UOM, MxTQty = _locPurchaseOrderLine.TQty, DQty = _locPurchaseOrderLine.DQty, DUOM = _locPurchaseOrderLine.DUOM, Qty = _locPurchaseOrderLine.Qty, UOM = _locPurchaseOrderLine.UOM, TQty = _locPurchaseOrderLine.TQty, EstimatedDate = _locInventoryTransfer.EstimatedDate, InventoryTransfer = _locInventoryTransfer }; _saveDataInventoryTransferLine.Save(); _saveDataInventoryTransferLine.Session.CommitTransaction(); //Change Status POL From Progress To Posted _locPurchaseOrderLine.Status = Status.Posted; _locPurchaseOrderLine.StatusDate = now; _locPurchaseOrderLine.Save(); _locPurchaseOrderLine.Session.CommitTransaction(); } } } } } //Change Status PO From Progress To Posted _locPurchaseOrderXPO.Status = Status.Posted; _locPurchaseOrderXPO.StatusDate = now; _locPurchaseOrderXPO.Save(); _locPurchaseOrderXPO.Session.CommitTransaction(); SuccessMessageShow(_locPurchaseOrderXPO, "Inventory Transfer"); } else { ErrorMessageShow("Data Purchase Order Not Available"); } } else { ErrorMessageShow("Data Purchase Order Not Available"); } } } } if (View is DetailView && ((DetailView)View).ViewEditMode == ViewEditMode.View) { _objectSpace.CommitChanges(); _objectSpace.Refresh(); } if (View is ListView) { _objectSpace.CommitChanges(); View.ObjectSpace.Refresh(); } } catch (Exception ex) { Tracing.Tracer.LogError(" BusinessObject = PurchaseOrder " + ex.ToString()); } }
private DbUpdateStatement GetQuery_UpdateQuery(InventoryTransferLine _obj) { return(DbMgr.CreateUpdateClause("InventoryTransferLines", GetFields(_obj), "InventoryTransferLineID", _obj.InventoryTransferLineID)); }
private DbInsertStatement GetQuery_InsertQuery(InventoryTransferLine _obj) { Dictionary <string, DbFieldEntry> fields = GetFields(_obj); return(DbMgr.CreateInsertClause("InventoryTransferLines", fields)); }