public IHttpActionResult PutSalesOrderDetail(int id, SalesOrderDetail salesOrderDetail) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != salesOrderDetail.SalesOrderID) { return BadRequest(); } db.Entry(salesOrderDetail).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!SalesOrderDetailExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostSalesOrderDetail(SalesOrderDetail salesOrderDetail) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.SalesOrderDetails.Add(salesOrderDetail); try { db.SaveChanges(); } catch (DbUpdateException) { if (SalesOrderDetailExists(salesOrderDetail.SalesOrderID)) { return Conflict(); } else { throw; } } return CreatedAtRoute("DefaultApi", new { id = salesOrderDetail.SalesOrderID }, salesOrderDetail); }
public static SalesOrderDetailList Searchzz(string pcompany, out double mappingTiem, out double sqlCallTie) { Database wDataBase = null; DbCommand wCmd = null; SalesOrderDetailList list; SalesOrderDetail sales; Stopwatch watch = new Stopwatch(); try { wDataBase = DatabaseFactory.CreateDatabase(pcompany); wCmd = wDataBase.GetStoredProcCommand("SalesOrderDetail_s"); watch.Start(); IDataReader reader = wDataBase.ExecuteReader(wCmd); watch.Stop(); sqlCallTie = watch.Elapsed.TotalMilliseconds; watch.Reset(); watch.Start(); list = new SalesOrderDetailList(); while (reader.Read()) { sales = new SalesOrderDetail(); sales.CarrierTrackingNumber = reader["CarrierTrackingNumber"].ToString(); sales.LineTotal = Convert.ToInt32(reader["LineTotal"]); sales.ModifiedDate = Convert.ToDateTime(reader["ModifiedDate"]); sales.ProductID = Convert.ToInt32(reader.GetOrdinal("ProductID")); sales.OrderQty = Convert.ToInt32(reader["OrderQty"]); sales.rowguid = (Guid)reader["rowguid"]; sales.SalesOrderDetailID = Convert.ToInt32(reader["SalesOrderDetailID"]); sales.SalesOrderID = Convert.ToInt32(reader["SalesOrderID"]); sales.SpecialOfferID = Convert.ToInt32(reader["SpecialOfferID"]); sales.UnitPrice = Convert.ToDouble(reader["UnitPrice"]); sales.UnitPriceDiscount = Convert.ToDouble(reader["UnitPriceDiscount"]); list.Add(sales); } reader.Close(); reader.Dispose(); watch.Stop(); mappingTiem = watch.Elapsed.TotalMilliseconds; return list; } catch (Exception ex) { throw Fwk.Exceptions.ExceptionHelper.ProcessException(ex); } }
// PUT api/awbuildversion/5 public void Put(SalesOrderDetail value) { var GetActionType = Request.Headers.Where(x => x.Key.Equals("ActionType")).FirstOrDefault(); if (GetActionType.Key != null) { if (GetActionType.Value.ToList()[0].Equals("DELETE")) adventureWorks_BC.SalesOrderDetailDelete(value); if (GetActionType.Value.ToList()[0].Equals("UPDATE")) adventureWorks_BC.SalesOrderDetailUpdate(value); } }
public async Task<IHttpActionResult> PostOrder(int productId, string userName) { Customer customer = await repository.Customers.FirstOrDefaultAsync(x => x.EmailAddress == userName); if (!customer.SalesOrderHeaders.Any() || customer.SalesOrderHeaders.All(x => x.Status == 0)) { var salesOrderHeader = new SalesOrderHeader { Address = customer.CustomerAddresses.First().Address, OrderDate = DateTime.Now, DueDate = DateTime.MaxValue, Status = 1, Customer = customer, ShipMethod = string.Empty, rowguid = Guid.NewGuid(), ModifiedDate = DateTime.Now, SalesOrderDetails = new List<SalesOrderDetail>(), CustomerID = customer.CustomerID, }; customer.SalesOrderHeaders.Add(salesOrderHeader); } SalesOrderHeader currentOrder = customer.SalesOrderHeaders.Last(x => x.Status == 1); if (currentOrder.SalesOrderDetails.All(x => x.Product.ProductID != productId)) { var product = repository.Products.First(x => x.ProductID == productId); var salesOrderDetail = new SalesOrderDetail { Product = product, SalesOrderHeader = currentOrder, ModifiedDate = DateTime.Now, rowguid = Guid.NewGuid(), LineTotal = 0, UnitPrice = product.ListPrice, ProductID = productId, UnitPriceDiscount = 0, OrderQty = ((short)1) }; currentOrder.SalesOrderDetails.Add(salesOrderDetail); product.SalesOrderDetails.Add(salesOrderDetail); await repository.SaveChangesAsync(); } return CreatedAtRoute("DefaultApi", new {id = productId}, productId); }
public int UpdationOrder(SalesOrderForm orderData) { try { using (SDNSalesDBEntities entities = new SDNSalesDBEntities()) { SalesOrder obj = entities.SalesOrders.Where(e => e.SO_No == orderData.Order.OrderNo ).SingleOrDefault(); if (obj != null) { //obj.ID = orderData.Order.ID; obj.Cus_Id = orderData.Order.CustomerID; // obj.SO_Conv_to_SO = orderData.Order.SO_Conv_to_SO; // obj.SO_Conv_to_SI = orderData.Order.SO_Conv_to_SI; obj.SO_Date = orderData.Order.OrderDate; obj.SO_GST_Amt = Convert.ToDecimal(orderData.Order.TotalTax); obj.SO_No = orderData.Order.OrderNo; obj.SO_TandC = orderData.Order.TermsAndConditions; obj.SO_Tot_aft_Tax = Convert.ToDecimal(orderData.Order.TotalAfterTax); obj.SO_Tot_bef_Tax = Convert.ToDecimal(orderData.Order.TotalBeforeTax); //obj.SO_Valid_for = orderData.Order.ValidForDays; obj.SO_Del_Date = orderData.Order.DeliveryDate; obj.Cus_PO_No = orderData.Order.Cus_Po_No; obj.Exc_Inc_GST = orderData.Order.ExcIncGST; obj.ModifiedDate = DateTime.Now; entities.SaveChanges(); } var objSales = entities.SalesOrderDetails.Where (e => e.SO_ID == obj.ID).ToList(); if (objSales != null) { foreach (var item in objSales) { int PSId = Convert.ToInt32(item.SO_No); if (PSId != 0) { ProductsAndService ps = entities.ProductsAndServices.SingleOrDefault(e => e.ID == PSId); if (ps != null) { ps.PandS_Qty_for_SO = ps.PandS_Qty_for_SO - item.SO_Qty; entities.SaveChanges(); } } entities.SalesOrderDetails.Remove(item); entities.SaveChanges(); } } SalesOrderDetail SODetails; if (orderData.OrderDetails != null) { foreach (SalesOrderDetailEntity SODetailEntity in orderData.OrderDetails) { SODetails = new SalesOrderDetail(); SODetails.SO_ID = obj.ID; SODetails.SO_No = SODetailEntity.SONo; SODetails.PandS_Code = SODetailEntity.PandSCode; SODetails.PandS_Name = SODetailEntity.PandSName; SODetails.SO_Amount = SODetailEntity.SOAmount; SODetails.SO_Discount = SODetailEntity.SODiscount; SODetails.SO_No = SODetailEntity.SONo; SODetails.SO_Price = Convert.ToDecimal(SODetailEntity.SOPrice); SODetails.SO_Qty = SODetailEntity.SOQty; SODetails.GST_Code = SODetailEntity.GSTCode; SODetails.GST_Rate = SODetailEntity.GSTRate; entities.SalesOrderDetails.Add(SODetails); entities.SaveChanges(); int PSId = Convert.ToInt32(SODetailEntity.SONo); if (PSId != 0) { ProductsAndService ps = entities.ProductsAndServices.SingleOrDefault(e => e.ID == PSId); if (ps != null) { ps.PandS_Qty_for_SO = ps.PandS_Qty_for_SO + SODetailEntity.SOQty; entities.SaveChanges(); } } } } return(obj.ID); } } catch (Exception ex) { throw ex; } }
public bool Validate(SalesOrderDetail _SalesOrderDetail, out List <string> lstMessages) { return(SalesOrderDetailDaoRepository.Validate(_SalesOrderDetail, out lstMessages)); }
public int Update(SalesOrderDetail _SalesOrderDetail) { return(SalesOrderDetailDaoRepository.Update(_SalesOrderDetail)); }
private void detach_SalesOrderDetail(SalesOrderDetail entity) { this.SendPropertyChanging(); entity.Product = null; }
public SalesOrderDetail UpdateObject(SalesOrderDetail salesOrderDetail, ISalesOrderService _salesOrderService, IItemService _itemService) { return(_validator.ValidUpdateObject(salesOrderDetail, this, _salesOrderService, _itemService) ? _repository.UpdateObject(salesOrderDetail) : salesOrderDetail); }
public void UpdateSalesOrderDetail(SalesOrderDetail soDetail) { SalesOrderDetail orig = this.GetOriginal <SalesOrderDetail>(); this.DB.SalesOrderDetails.Attach(soDetail, orig); }
public static SalesOrderDetail CreateSalesOrderDetail(int salesOrderID, int salesOrderDetailID, short orderQty, int productID, decimal unitPrice, decimal unitPriceDiscount, decimal lineTotal, global::System.Guid rowguid, global::System.DateTime modifiedDate) { SalesOrderDetail salesOrderDetail = new SalesOrderDetail(); salesOrderDetail.SalesOrderID = salesOrderID; salesOrderDetail.SalesOrderDetailID = salesOrderDetailID; salesOrderDetail.OrderQty = orderQty; salesOrderDetail.ProductID = productID; salesOrderDetail.UnitPrice = unitPrice; salesOrderDetail.UnitPriceDiscount = unitPriceDiscount; salesOrderDetail.LineTotal = lineTotal; salesOrderDetail.rowguid = rowguid; salesOrderDetail.ModifiedDate = modifiedDate; return salesOrderDetail; }
partial void UpdateSalesOrderDetail(SalesOrderDetail instance);
/// <summary> /// This method is used to convert the Sales order to order /// </summary> /// <param name="orderData"></param> /// <returns></returns> public int ConvertToSalesOrder(SalesOrderForm orderData) { int autoId = 0; //Add sales order SalesOrder obj = new SalesOrder(); //obj.ID = orderData.Order.ID; obj.Cus_Id = orderData.Order.CustomerID; obj.SO_Date = orderData.Order.OrderDate; obj.SO_Del_Date = DateTime.Now; obj.SO_GST_Amt = Convert.ToDecimal(orderData.Order.TotalTax); obj.SO_No = "SO-" + GetLastOrderNo(); obj.SO_TandC = orderData.Order.TermsAndConditions; obj.SO_Tot_aft_Tax = Convert.ToDecimal(orderData.Order.TotalAfterTax); obj.SO_Tot_bef_Tax = Convert.ToDecimal(orderData.Order.TotalBeforeTax); obj.Exc_Inc_GST = orderData.Order.ExcIncGST; obj.IsDeleted = false; try { using (SDNSalesDBEntities entities = new SDNSalesDBEntities()) { if (entities.SalesOrders.AsNoTracking().FirstOrDefault(x => x.ID == orderData.Order.ID) == null) { //obj.CreatedBy = orderData.SOModel.CreatedBy; obj.CreatedDate = DateTime.Now; entities.SalesOrders.Add(obj); entities.SaveChanges(); autoId = obj.ID; } else { // obj.ModifiedBy = orderData.SOModel.ModifiedBy; obj.ModifiedDate = DateTime.Now; entities.Entry(obj).State = EntityState.Modified; autoId = entities.SaveChanges(); } if (autoId > 0) { SalesOrderDetail SODetails; if (orderData.OrderDetails != null) { foreach (SalesOrderDetailEntity SODetailEntity in orderData.OrderDetails) { SODetails = new SalesOrderDetail(); SODetails.SO_ID = autoId; SODetails.SO_No = SODetailEntity.SONo; SODetails.PandS_Code = SODetailEntity.PandSCode; SODetails.PandS_Name = SODetailEntity.PandSName; SODetails.SO_Amount = SODetailEntity.SOAmount; SODetails.SO_Discount = SODetailEntity.SODiscount; SODetails.SO_No = SODetailEntity.SONo; SODetails.SO_Price = Convert.ToDecimal(SODetailEntity.SOPrice); SODetails.SO_Qty = SODetailEntity.SOQty; SODetails.GST_Code = SODetailEntity.GSTCode; SODetails.GST_Rate = SODetailEntity.GSTRate; if (entities.SalesOrderDetails.AsNoTracking().FirstOrDefault(x => x.ID == SODetailEntity.ID) == null) { entities.SalesOrderDetails.Add(SODetails); entities.SaveChanges(); } else { entities.Entry(SODetails).State = EntityState.Modified; entities.SaveChanges(); } } } SalesOrder objQ = entities.SalesOrders.Where(e => e.SO_No == orderData.Order.OrderNo ).SingleOrDefault(); if (objQ != null) { //objQ.SO_Conv_to_SO = true; objQ.ModifiedDate = DateTime.Now; entities.SaveChanges(); } } } return(autoId); } catch (Exception ex) { throw ex; } }
private void attach_SalesOrderDetail(SalesOrderDetail entity) { this.SendPropertyChanging(); entity.SalesOrderHeader = this; }
// POST api/awbuildversion public void Post(SalesOrderDetail value) { adventureWorks_BC.SalesOrderDetailAdd(value); }
public virtual SalesOrderDetail_CreateOutput Detail_Create(SalesOrderDetail_CreateInput _data) { SalesOrderDetail_CreateOutput res = new SalesOrderDetail_CreateOutput(); using (AdventureWorksEntities ctx = new AdventureWorksEntities()) { EntityState state = EntityState.Added; SalesOrderDetail obj = new SalesOrderDetail(); var entry = ctx.Entry(obj); entry.State = state; entry.CurrentValues.SetValues(_data); obj.SalesOrderObject = ctx.SalesOrder.Find(_data.SalesOrderId); if (obj.SalesOrderObject == null) ErrorList.Current.AddError("Invalid value {0} for parameter SalesOrderId. Cannot find the corresponding SalesOrder object.", _data.SalesOrderId); // CUSTOM_CODE_START: use the SpecialOfferId input parameter of Detail_Create operation below // TODO: ??? = _data.SpecialOfferId; // CUSTOM_CODE_END // CUSTOM_CODE_START: use the ProductId input parameter of Detail_Create operation below // TODO: ??? = _data.ProductId; // CUSTOM_CODE_END // CUSTOM_CODE_START: add custom code for Detail_Create operation below // CUSTOM_CODE_END ErrorList.Current.AbortIfHasErrors(HttpStatusCode.BadRequest); ctx.SaveChanges(); ServiceUtil.CopyProperties(obj, res); } return res; }
private void detach_SalesOrderDetails(SalesOrderDetail entity) { this.SendPropertyChanging(); entity.SalesOrderHeader = null; }
public static SalesOrderDetailList Search(string pcompany, out double mappingTiem, out double sqlCallTie, out Hashtable pRetrieveStatistics) { SqlConnection conn = new SqlConnection(GetCnnstring_App(pcompany)); conn.StatisticsEnabled = true; SqlCommand cmd = new SqlCommand("SalesOrderDetail_s", conn); cmd.CommandType = CommandType.StoredProcedure; //cmd.Connection = conn; //cmd.CommandText = "SalesOrderDetail_s"; SalesOrderDetailList list; SalesOrderDetail sales; Stopwatch watch = new Stopwatch(); try { conn.Open(); watch.Start(); IDataReader reader = cmd.ExecuteReader(); watch.Stop(); sqlCallTie = watch.Elapsed.TotalMilliseconds; watch.Reset(); watch.Start(); #region DATA Mapping list = new SalesOrderDetailList(); while (reader.Read()) { sales = new SalesOrderDetail(); sales.CarrierTrackingNumber = reader["CarrierTrackingNumber"].ToString(); sales.LineTotal = Convert.ToInt32(reader["LineTotal"]); sales.ModifiedDate = Convert.ToDateTime(reader["ModifiedDate"]); sales.ProductID = Convert.ToInt32(reader.GetOrdinal("ProductID")); sales.OrderQty = Convert.ToInt32(reader["OrderQty"]); sales.rowguid = (Guid)reader["rowguid"]; sales.SalesOrderDetailID = Convert.ToInt32(reader["SalesOrderDetailID"]); sales.SalesOrderID = Convert.ToInt32(reader["SalesOrderID"]); sales.SpecialOfferID = Convert.ToInt32(reader["SpecialOfferID"]); sales.UnitPrice = Convert.ToDouble(reader["UnitPrice"]); sales.UnitPriceDiscount = Convert.ToDouble(reader["UnitPriceDiscount"]); list.Add(sales); } reader.Close(); reader.Dispose(); #endregion watch.Stop(); mappingTiem = watch.Elapsed.TotalMilliseconds; //Recojo las estadísticas pRetrieveStatistics = (Hashtable)conn.RetrieveStatistics(); return list; } catch (Exception ex) { throw Fwk.Exceptions.ExceptionHelper.ProcessException(ex); } }
/// <summary> /// This method is used to convert the Sales quotation to order /// </summary> /// <param name="quotationData"></param> /// <returns></returns> public int ConvertToSalesOrder(SalesQuotationForm quotationData) { int autoId = 0; //Add purchase quotation SalesOrder obj = new SalesOrder(); //obj.ID = quotationData.Quotation.ID; obj.Cus_Id = quotationData.Quotation.CustomerID; obj.SO_Date = quotationData.Quotation.QuotationDate; obj.SO_Del_Date = DateTime.Now; obj.SO_GST_Amt = Convert.ToDecimal(quotationData.Quotation.TotalTax); obj.SO_No = "SO-" + (GetLastOrderNo() + 1); obj.SO_TandC = quotationData.Quotation.TermsAndConditions; obj.SO_Tot_aft_Tax = Convert.ToDecimal(quotationData.Quotation.TotalAfterTax); obj.SO_Tot_bef_Tax = Convert.ToDecimal(quotationData.Quotation.TotalBeforeTax); obj.Salesman = quotationData.Quotation.SalesmanID; obj.Exc_Inc_GST = quotationData.Quotation.ExcIncGST; obj.IsDeleted = false; try { using (SASEntitiesEDM entities = new SASEntitiesEDM()) { if (entities.SalesOrders.AsNoTracking().FirstOrDefault(x => x.ID == quotationData.Quotation.ID) == null) { //obj.CreatedBy = quotationData.SQModel.CreatedBy; obj.CreatedDate = DateTime.Now; entities.SalesOrders.Add(obj); entities.SaveChanges(); autoId = obj.ID; } else { // obj.ModifiedBy = quotationData.SQModel.ModifiedBy; obj.ModifiedDate = DateTime.Now; entities.Entry(obj).State = EntityState.Modified; autoId = entities.SaveChanges(); } if (autoId > 0) { SalesOrderDetail SQDetails; if (quotationData.QuotationDetails != null) { foreach (SalesQuotationDetailEntity SQDetailEntity in quotationData.QuotationDetails) { SQDetails = new SalesOrderDetail(); SQDetails.SO_ID = autoId; SQDetails.SO_No = SQDetailEntity.SQNo; SQDetails.PandS_Code = SQDetailEntity.PandSCode; SQDetails.PandS_Name = SQDetailEntity.PandSName; SQDetails.SO_Amount = SQDetailEntity.SQAmount; SQDetails.SO_Discount = SQDetailEntity.SQDiscount; SQDetails.SO_No = SQDetailEntity.SQNo; SQDetails.SO_Price = Convert.ToDecimal(SQDetailEntity.SQPrice); SQDetails.SO_Qty = SQDetailEntity.SQQty; SQDetails.GST_Code = SQDetailEntity.GSTCode; SQDetails.GST_Rate = SQDetailEntity.GSTRate; if (entities.SalesOrderDetails.AsNoTracking().FirstOrDefault(x => x.ID == SQDetailEntity.ID) == null) { entities.SalesOrderDetails.Add(SQDetails); entities.SaveChanges(); } else { entities.Entry(SQDetails).State = EntityState.Modified; entities.SaveChanges(); } } } SalesQuotation objQ = entities.SalesQuotations.Where(e => e.SQ_No == quotationData.Quotation.QuotationNo ).SingleOrDefault(); if (objQ != null) { objQ.SQ_Conv_to_SO = true; objQ.Conv_to_No = obj.SO_No; objQ.ModifiedDate = DateTime.Now; entities.SaveChanges(); } } } return(autoId); } catch (Exception ex) { throw ex; } }
public ActionResult AddItem(int order, int product) { var entity = SalesOrder.TryFind (order); var p = Product.TryFind (product); int pl = entity.Customer.PriceList.Id; var cost = (from x in ProductPrice.Queryable where x.Product.Id == product && x.List.Id == 0 select x).SingleOrDefault (); var price = (from x in ProductPrice.Queryable where x.Product.Id == product && x.List.Id == pl select x).SingleOrDefault (); if (entity.IsCompleted || entity.IsCancelled) { Response.StatusCode = 400; return Content (Resources.ItemAlreadyCompletedOrCancelled); } if (cost == null) { cost = new ProductPrice { Value = decimal.Zero }; } if (price == null) { price = new ProductPrice { Value = decimal.MaxValue }; } var item = new SalesOrderDetail { SalesOrder = entity, Product = p, Warehouse = entity.PointOfSale.Warehouse, ProductCode = p.Code, ProductName = p.Name, TaxRate = p.TaxRate, IsTaxIncluded = p.IsTaxIncluded, Quantity = p.MinimumOrderQuantity, Cost = cost.Value, Price = price.Value, Currency = entity.Currency, ExchangeRate = entity.ExchangeRate }; if (p.Currency != entity.Currency) { item.Cost = cost.Value * CashHelpers.GetTodayExchangeRate (p.Currency, entity.Currency); item.Price = price.Value * CashHelpers.GetTodayExchangeRate (p.Currency, entity.Currency); } using (var scope = new TransactionScope ()) { item.CreateAndFlush (); } return Json (new { id = item.Id }); }
/// <summary> /// Creates any entity records that this sample requires. /// </summary> public void CreateRequiredRecords() { #region Create or Retrieve the necessary system users // Retrieve the ldapPath String ldapPath = String.Empty; // Retrieve the sales team - 1 sales manager and 2 sales representatives. _salesManagerId = SystemUserProvider.RetrieveSalesManager(_serviceProxy, ref ldapPath); _salesRepresentativeId = SystemUserProvider.RetrieveSalespersons(_serviceProxy, ref ldapPath)[0]; #endregion #region Create records to support SalesOrder records // Create a unit group UoMSchedule newUnitGroup = new UoMSchedule { Name = "Example Unit Group", BaseUoMName = "Example Primary Unit" }; _unitGroupId = _serviceProxy.Create(newUnitGroup); // Retrieve the default unit id that was automatically created // when we created the Unit Group QueryExpression unitQuery = new QueryExpression { EntityName = UoM.EntityLogicalName, ColumnSet = new ColumnSet("uomid", "name"), Criteria = new FilterExpression { Conditions = { new ConditionExpression { AttributeName = "uomscheduleid", Operator = ConditionOperator.Equal, Values = { _unitGroupId } } } }, PageInfo = new PagingInfo { PageNumber = 1, Count = 1 } }; // Retrieve the unit. UoM unit = (UoM)_serviceProxy.RetrieveMultiple(unitQuery).Entities[0]; _defaultUnitId = unit.UoMId.Value; // Create a few products Product newProduct = new Product { ProductNumber = "1", Name = "Example Product", ProductStructure = new OptionSetValue(1), QuantityDecimal = 2, DefaultUoMScheduleId = new EntityReference(UoMSchedule.EntityLogicalName, _unitGroupId), DefaultUoMId = new EntityReference(UoM.EntityLogicalName, _defaultUnitId) }; _productId = _serviceProxy.Create(newProduct); newProduct.Id = _productId; Console.WriteLine("Created {0}", newProduct.Name); // Create a price list PriceLevel newPriceList = new PriceLevel { Name = "Example Price List" }; _priceListId = _serviceProxy.Create(newPriceList); // Create a price list item for the first product and apply volume discount ProductPriceLevel newPriceListItem = new ProductPriceLevel { PriceLevelId = new EntityReference(PriceLevel.EntityLogicalName, _priceListId), ProductId = new EntityReference(Product.EntityLogicalName, _productId), UoMId = new EntityReference(UoM.EntityLogicalName, _defaultUnitId), Amount = new Money(20), }; _priceListItemId = _serviceProxy.Create(newPriceListItem); // Publish the product SetStateRequest publishRequest = new SetStateRequest { EntityMoniker = new EntityReference(Product.EntityLogicalName, _productId), State = new OptionSetValue((int)ProductState.Active), Status = new OptionSetValue(1) }; _serviceProxy.Execute(publishRequest); Console.WriteLine("Published {0}", newProduct.Name); // Create an account record for the sales order's potential customerid Account newAccount = new Account { Name = "Litware, Inc.", Address1_PostalCode = "60661" }; _accountId = _serviceProxy.Create(newAccount); newAccount.Id = _accountId; #endregion Create records to support SalesOrder #region Create SalesOrder record // Create the sales order. SalesOrder order = new SalesOrder() { Name = "Faux Order", DateFulfilled = new DateTime(2010, 8, 1), PriceLevelId = new EntityReference(PriceLevel.EntityLogicalName, _priceListId), CustomerId = new EntityReference(Account.EntityLogicalName, _accountId), FreightAmount = new Money(20.0M) }; _orderId = _serviceProxy.Create(order); order.Id = _orderId; // Add the product to the order with the price overriden with a // negative value. SalesOrderDetail orderDetail = new SalesOrderDetail() { ProductId = newProduct.ToEntityReference(), Quantity = 4, SalesOrderId = order.ToEntityReference(), IsPriceOverridden = true, PricePerUnit = new Money(1000.0M), UoMId = new EntityReference(UoM.EntityLogicalName, _defaultUnitId) }; _orderDetailId = _serviceProxy.Create(orderDetail); #endregion Create SalesOrder record }
public SalesOrderDetail Create(SalesOrderDetail sod) { sod.ObjectState = ObjectState.Added; _unitOfWork.Repository <SalesOrderDetail>().Insert(sod); return(sod); }
public void Delete(SalesOrderDetail sod) { _unitOfWork.Repository <SalesOrderDetail>().Delete(sod); }
private static void GetDistinctSalesOrderDetails(Db db, DbAggregateQueryBuilder queryBuilder, SalesOrderDetail model) { SalesOrderDetail d; queryBuilder.From(db.SalesOrderDetail, out d) .AutoSelect() .OrderBy(d.SalesOrderDetailID); }
public void Update(SalesOrderDetail sod) { sod.ObjectState = ObjectState.Modified; _unitOfWork.Repository <SalesOrderDetail>().Update(sod); }
public SalesOrderDetail SoftDeleteObject(SalesOrderDetail salesOrderDetail) { return(_validator.ValidDeleteObject(salesOrderDetail) ? _repository.SoftDeleteObject(salesOrderDetail) : salesOrderDetail); }
public SalesOrderDetail Add(SalesOrderDetail sod) { _unitOfWork.Repository <SalesOrderDetail>().Insert(sod); return(sod); }
public int Insert(SalesOrderDetail _SalesOrderDetail) { return(SalesOrderDetailDaoRepository.Insert(_SalesOrderDetail)); }
/// <summary> /// Delete Sales Order Detail /// </summary> /// <param name="salesOrderDetailId"></param> /// <returns></returns> public async Task DeleteSalesOrderDetail(int salesOrderDetailId) { SalesOrderDetail salesOrderDetail = await dbConnection.SalesOrderDetails.Where(x => x.SalesOrderDetailId == salesOrderDetailId).FirstOrDefaultAsync(); dbConnection.SalesOrderDetails.Remove(salesOrderDetail); }
public int Delete(SalesOrderDetail _SalesOrderDetail) { return(SalesOrderDetailDaoRepository.Delete(_SalesOrderDetail)); }
/// <summary> /// Update Sales Order Detail /// </summary> /// <param name="salesOrderDetailDataTransformation"></param> /// <returns></returns> public async Task <ResponseModel <SalesOrderDetailDataTransformation> > UpdateSalesOrderDetail(SalesOrderDetailDataTransformation salesOrderDetailDataTransformation) { ResponseModel <SalesOrderDetailDataTransformation> returnResponse = new ResponseModel <SalesOrderDetailDataTransformation>(); SalesOrderDetail salesOrderDetail = new SalesOrderDetail(); try { int accountId = salesOrderDetailDataTransformation.AccountId; int salesOrderId = salesOrderDetailDataTransformation.SalesOrderId; int salesOrderDetailId = salesOrderDetailDataTransformation.SalesOrderDetailId; // // Validate Shipped Quantity // if (salesOrderDetailDataTransformation.CurrentShippedQuantity == 0) { returnResponse.ReturnMessage.Add("Invalid Shipped Quantity"); returnResponse.ReturnStatus = false; return(returnResponse); } // // Begin a Serializable Transaction // _inventoryManagementDataService.OpenConnection(_connectionStrings.PrimaryDatabaseConnectionString); _inventoryManagementDataService.BeginTransaction((int)IsolationLevel.Serializable); // // Get Sales Order Header // SalesOrder salesOrder = await _inventoryManagementDataService.GetSalesOrderHeader(accountId, salesOrderId); if (salesOrder == null) { _inventoryManagementDataService.RollbackTransaction(); returnResponse.ReturnMessage.Add("Sales Order not found"); returnResponse.ReturnStatus = false; return(returnResponse); } // // Get Sales Order Detail // salesOrderDetail = await _inventoryManagementDataService.GetSalesOrderDetailForUpdate(salesOrderDetailId); if (salesOrderDetail == null) { _inventoryManagementDataService.RollbackTransaction(); returnResponse.ReturnMessage.Add("Sales Order Detail not found"); returnResponse.ReturnStatus = false; return(returnResponse); } // // Update Sales Order Shipped Quantity // salesOrderDetail.ShippedQuantity = salesOrderDetail.ShippedQuantity + salesOrderDetailDataTransformation.CurrentShippedQuantity; await _inventoryManagementDataService.UpdateSalesOrderDetail(salesOrderDetail); // // Get Product Record with an exclusive update lock // Product product = await _inventoryManagementDataService.GetProductInformationForUpdate(salesOrderDetail.ProductId); if (product == null) { _inventoryManagementDataService.RollbackTransaction(); returnResponse.ReturnMessage.Add("Product not found"); returnResponse.ReturnStatus = false; return(returnResponse); } // // Reduce Product OnHand Quantity by the quantity shipped // product.OnHandQuantity = product.OnHandQuantity - salesOrderDetailDataTransformation.CurrentShippedQuantity; await _inventoryManagementDataService.UpdateProduct(product); // // Create Inventory Transaction Record // InventoryTransaction inventoryTransaction = new InventoryTransaction(); inventoryTransaction.EntityId = salesOrderDetail.SalesOrderDetailId; inventoryTransaction.MasterEntityId = salesOrderDetail.MasterSalesOrderDetailId; inventoryTransaction.ProductId = salesOrderDetail.ProductId; inventoryTransaction.UnitCost = product.AverageCost; inventoryTransaction.Quantity = salesOrderDetailDataTransformation.CurrentShippedQuantity; inventoryTransaction.TransactionDate = DateTime.UtcNow; await _inventoryManagementDataService.CreateInventoryTransaction(inventoryTransaction); // // Create Transaction Queue record and create inventory transaction payload // TransactionQueueOutbound transactionQueue = new TransactionQueueOutbound(); transactionQueue.Payload = GenerateInventoryTransactionPayload(inventoryTransaction); transactionQueue.TransactionCode = TransactionQueueTypes.InventoryShipped; transactionQueue.ExchangeName = MessageQueueExchanges.InventoryManagement; await _inventoryManagementDataService.CreateOutboundTransactionQueue(transactionQueue); //await _inventoryManagementDataService.UpdateDatabase(); // // Commit Transaction // _inventoryManagementDataService.CommitTransaction(); returnResponse.ReturnStatus = true; } catch (Exception ex) { _inventoryManagementDataService.RollbackTransaction(); returnResponse.ReturnStatus = false; returnResponse.ReturnMessage.Add(ex.Message); } finally { _inventoryManagementDataService.CloseConnection(); } returnResponse.Entity = salesOrderDetailDataTransformation; return(returnResponse); }
/// <summary> /// This method is used to add or edit sales order /// </summary> /// <param name="orderData"></param> /// <returns></returns> public int AddUpdateOrder(SalesOrderForm orderData) { int autoId = 0; //Add sales order SalesOrder obj = new SalesOrder(); obj.ID = orderData.Order.ID; obj.Cus_Id = orderData.Order.CustomerID; //obj.SO_Conv_to_SO = orderData.Order.SO_Conv_to_SO; obj.SO_Conv_to_SI = orderData.Order.SO_Conv_to_SI; obj.SO_Date = orderData.Order.OrderDate; obj.SO_GST_Amt = Convert.ToDecimal(orderData.Order.TotalTax); obj.SO_No = orderData.Order.OrderNo; obj.SO_TandC = orderData.Order.TermsAndConditions; obj.SO_Tot_aft_Tax = Convert.ToDecimal(orderData.Order.TotalAfterTax); obj.SO_Tot_bef_Tax = Convert.ToDecimal(orderData.Order.TotalBeforeTax); //obj.SO_Valid_for = orderData.Order.ValidForDays; obj.SO_Del_Date = orderData.Order.DeliveryDate; obj.Cus_PO_No = orderData.Order.Cus_Po_No; obj.Exc_Inc_GST = orderData.Order.ExcIncGST; obj.IsDeleted = false; try { using (SDNSalesDBEntities entities = new SDNSalesDBEntities()) { if (entities.SalesOrders.AsNoTracking().FirstOrDefault(x => x.ID == orderData.Order.ID) == null) { //obj.CreatedBy = orderData.SOModel.CreatedBy; obj.CreatedDate = DateTime.Now; entities.SalesOrders.Add(obj); entities.SaveChanges(); autoId = obj.ID; } else { // obj.ModifiedBy = orderData.SOModel.ModifiedBy; obj.ModifiedDate = DateTime.Now; entities.Entry(obj).State = EntityState.Modified; autoId = entities.SaveChanges(); } if (autoId > 0) { SalesOrderDetail SODetails; if (orderData.OrderDetails != null) { foreach (SalesOrderDetailEntity SODetailEntity in orderData.OrderDetails) { SODetails = new SalesOrderDetail(); SODetails.SO_ID = autoId; SODetails.SO_No = SODetailEntity.SONo; SODetails.PandS_Code = SODetailEntity.PandSCode; SODetails.PandS_Name = SODetailEntity.PandSName; SODetails.SO_Amount = SODetailEntity.SOAmount; SODetails.SO_Discount = SODetailEntity.SODiscount; SODetails.SO_No = SODetailEntity.SONo; SODetails.SO_Price = Convert.ToDecimal(SODetailEntity.SOPrice); SODetails.SO_Qty = SODetailEntity.SOQty; SODetails.GST_Code = SODetailEntity.GSTCode; SODetails.GST_Rate = SODetailEntity.GSTRate; if (entities.SalesOrderDetails.AsNoTracking().FirstOrDefault(x => x.ID == SODetailEntity.ID) == null) { entities.SalesOrderDetails.Add(SODetails); entities.SaveChanges(); } else { entities.Entry(SODetails).State = EntityState.Modified; entities.SaveChanges(); } int PSId = Convert.ToInt32(SODetailEntity.SONo); if (PSId != 0) { ProductsAndService ps = entities.ProductsAndServices.SingleOrDefault(e => e.ID == PSId); if (ps != null) { ps.PandS_Qty_for_SO = ps.PandS_Qty_for_SO + SODetailEntity.SOQty; entities.SaveChanges(); } } } } } } return(autoId); } catch (Exception ex) { throw ex; } }
public SalesOrderDetailModel MapToModel(SalesOrderDetail item) { var newItem = Mapper.Map <SalesOrderDetail, SalesOrderDetailModel>(item); return(newItem); }
private void attach_SalesOrderDetails(SalesOrderDetail entity) { this.SendPropertyChanging(); entity.Product = this; }
public SalesOrderDetail VDeleteObject(SalesOrderDetail salesOrderDetail) { VHasNotBeenConfirmed(salesOrderDetail); return(salesOrderDetail); }
partial void InsertSalesOrderDetail(SalesOrderDetail instance);
public bool ValidCreateObject(SalesOrderDetail salesOrderDetail, ISalesOrderDetailService _salesOrderDetailService, ISalesOrderService _salesOrderService, IItemService _itemService) { VCreateObject(salesOrderDetail, _salesOrderDetailService, _salesOrderService, _itemService); return(isValid(salesOrderDetail)); }
partial void DeleteSalesOrderDetail(SalesOrderDetail instance);
public bool ValidUpdateObject(SalesOrderDetail salesOrderDetail, ISalesOrderDetailService _salesOrderDetailService, ISalesOrderService _salesOrderService, IItemService _itemService) { salesOrderDetail.Errors.Clear(); VUpdateObject(salesOrderDetail, _salesOrderDetailService, _salesOrderService, _itemService); return(isValid(salesOrderDetail)); }
public void InsertSalesOrderDetail(SalesOrderDetail soDetail) { soDetail.ModifiedDate = DateTime.Now; soDetail.rowguid = Guid.NewGuid(); this.DB.SalesOrderDetails.InsertOnSubmit(soDetail); }
public bool ValidDeleteObject(SalesOrderDetail salesOrderDetail) { salesOrderDetail.Errors.Clear(); VDeleteObject(salesOrderDetail); return(isValid(salesOrderDetail)); }
public void DeleteSalesOrderDetail(SalesOrderDetail soDetail) { this.DB.SalesOrderDetails.Attach(soDetail); this.DB.SalesOrderDetails.DeleteOnSubmit(soDetail); }
public bool ValidConfirmObject(SalesOrderDetail salesOrderDetail) { salesOrderDetail.Errors.Clear(); VConfirmObject(salesOrderDetail); return(isValid(salesOrderDetail)); }
/// <summary> /// This method first connects to the Organization service. Afterwards, an /// opportunity is created to demonstrate a negative estimated value. This is /// followed by the creation of a quote with a negative product quantity. /// Finally, a sales order with a negative product price is shown. /// </summary> /// <param name="serverConfig">Contains server connection information.</param> /// <param name="promptforDelete">When True, the user will be prompted to delete all /// created entities.</param> public void Run(ServerConnection.Configuration serverConfig, bool promptforDelete) { try { // Connect to the Organization service. // The using statement assures that the service proxy will be properly disposed. using (_serviceProxy = new OrganizationServiceProxy(serverConfig.OrganizationUri, serverConfig.HomeRealmUri, serverConfig.Credentials, serverConfig.DeviceCredentials)) { // This statement is required to enable early-bound type support. _serviceProxy.EnableProxyTypes(); CreateRequiredRecords(); #region Opportunity with negative estimated value // Create a new opportunity with user-specified negative // estimated value. Opportunity opportunity = new Opportunity { Name = "Example Opportunity", CustomerId = new EntityReference(Account.EntityLogicalName, _accountId), PriceLevelId = new EntityReference(PriceLevel.EntityLogicalName, _priceListId), IsRevenueSystemCalculated = false, EstimatedValue = new Money(-400.00m), FreightAmount = new Money(10.00m), ActualValue = new Money(-390.00m), OwnerId = new EntityReference { Id = _salesRepresentativeIds[0], LogicalName = SystemUser.EntityLogicalName } }; _opportunityId = _serviceProxy.Create(opportunity); opportunity.Id = _opportunityId; // Create a catalog product for the opportunity. OpportunityProduct catalogProduct = new OpportunityProduct { OpportunityId = opportunity.ToEntityReference(), ProductId = new EntityReference(Product.EntityLogicalName, _product1Id), UoMId = new EntityReference(UoM.EntityLogicalName, _defaultUnitId), Quantity = 8, Tax = new Money(12.42m), }; _catalogProductId = _serviceProxy.Create(catalogProduct); Console.WriteLine("Created opportunity with negative estimated value."); #endregion #region Quote with negative quantity // Create the quote. Quote quote = new Quote() { CustomerId = new EntityReference(Account.EntityLogicalName, _accountId), Name = "Sample Quote", PriceLevelId = new EntityReference(PriceLevel.EntityLogicalName, _priceListId) }; _quoteId = _serviceProxy.Create(quote); quote.Id = _quoteId; // Set the quote's product quantity to a negative value. QuoteDetail quoteDetail = new QuoteDetail() { ProductId = new EntityReference(Product.EntityLogicalName, _product1Id), Quantity = -4, QuoteId = quote.ToEntityReference(), UoMId = new EntityReference(UoM.EntityLogicalName, _defaultUnitId) }; _quoteDetailId = _serviceProxy.Create(quoteDetail); Console.WriteLine("Created quote with negative quantity."); #endregion #region Sales Order with negative price // Create the sales order. SalesOrder order = new SalesOrder() { Name = "Faux Order", DateFulfilled = new DateTime(2010, 8, 1), PriceLevelId = new EntityReference(PriceLevel.EntityLogicalName, _priceListId), CustomerId = new EntityReference(Account.EntityLogicalName, _accountId), FreightAmount = new Money(20.0M) }; _orderId = _serviceProxy.Create(order); order.Id = _orderId; // Add the product to the order with the price overriden with a // negative value. SalesOrderDetail orderDetail = new SalesOrderDetail() { ProductId = new EntityReference(Product.EntityLogicalName, _product1Id), Quantity = 4, SalesOrderId = order.ToEntityReference(), IsPriceOverridden = true, PricePerUnit = new Money(-40.0M), UoMId = new EntityReference(UoM.EntityLogicalName, _defaultUnitId) }; _orderDetailId = _serviceProxy.Create(orderDetail); Console.WriteLine("Created order with negative price per unit."); #endregion DeleteRequiredRecords(promptforDelete); } } // Catch any service fault exceptions that Microsoft Dynamics CRM throws. catch (FaultException <Microsoft.Xrm.Sdk.OrganizationServiceFault> ) { // You can handle an exception here or pass it back to the calling method. throw; } }
public bool ValidUnconfirmObject(SalesOrderDetail salesOrderDetail, IDeliveryOrderDetailService _deliveryOrderDetailService, IItemService _itemService) { salesOrderDetail.Errors.Clear(); VUnconfirmObject(salesOrderDetail, _deliveryOrderDetailService, _itemService); return(isValid(salesOrderDetail)); }
public void AddToSalesOrderDetails(SalesOrderDetail salesOrderDetail) { base.AddObject("SalesOrderDetails", salesOrderDetail); }
public bool isValid(SalesOrderDetail obj) { bool isValid = !obj.Errors.Any(); return(isValid); }
/// <summary> /// This method first connects to the Organization service. Afterwards, an /// opportunity is created to demonstrate a negative estimated value. This is /// followed by the creation of a quote with a negative product quantity. /// Finally, a sales order with a negative product price is shown. /// </summary> /// <param name="serverConfig">Contains server connection information.</param> /// <param name="promptforDelete">When True, the user will be prompted to delete all /// created entities.</param> public void Run(ServerConnection.Configuration serverConfig, bool promptforDelete) { try { //<snippetWorkingWithNegativePrices1> // Connect to the Organization service. // The using statement assures that the service proxy will be properly disposed. using (_serviceProxy = new OrganizationServiceProxy(serverConfig.OrganizationUri, serverConfig.HomeRealmUri,serverConfig.Credentials, serverConfig.DeviceCredentials)) { // This statement is required to enable early-bound type support. _serviceProxy.EnableProxyTypes(); CreateRequiredRecords(); #region Opportunity with negative estimated value // Create a new opportunity with user-specified negative // estimated value. Opportunity opportunity = new Opportunity { Name = "Example Opportunity", CustomerId = new EntityReference(Account.EntityLogicalName, _accountId), PriceLevelId = new EntityReference(PriceLevel.EntityLogicalName, _priceListId), IsRevenueSystemCalculated = false, EstimatedValue = new Money(-400.00m), FreightAmount = new Money(10.00m), ActualValue = new Money(-390.00m), OwnerId = new EntityReference { Id = _salesRepresentativeIds[0], LogicalName = SystemUser.EntityLogicalName } }; _opportunityId = _serviceProxy.Create(opportunity); opportunity.Id = _opportunityId; // Create a catalog product for the opportunity. OpportunityProduct catalogProduct = new OpportunityProduct { OpportunityId = opportunity.ToEntityReference(), ProductId = new EntityReference(Product.EntityLogicalName, _product1Id), UoMId = new EntityReference(UoM.EntityLogicalName, _defaultUnitId), Quantity = 8, Tax = new Money(12.42m), }; _catalogProductId = _serviceProxy.Create(catalogProduct); Console.WriteLine("Created opportunity with negative estimated value."); #endregion #region Quote with negative quantity // Create the quote. Quote quote = new Quote() { CustomerId = new EntityReference(Account.EntityLogicalName, _accountId), Name = "Sample Quote", PriceLevelId = new EntityReference(PriceLevel.EntityLogicalName, _priceListId) }; _quoteId = _serviceProxy.Create(quote); quote.Id = _quoteId; // Set the quote's product quantity to a negative value. QuoteDetail quoteDetail = new QuoteDetail() { ProductId = new EntityReference(Product.EntityLogicalName, _product1Id), Quantity = -4, QuoteId = quote.ToEntityReference(), UoMId = new EntityReference(UoM.EntityLogicalName, _defaultUnitId) }; _quoteDetailId = _serviceProxy.Create(quoteDetail); Console.WriteLine("Created quote with negative quantity."); #endregion #region Sales Order with negative price // Create the sales order. SalesOrder order = new SalesOrder() { Name = "Faux Order", DateFulfilled = new DateTime(2010, 8, 1), PriceLevelId = new EntityReference(PriceLevel.EntityLogicalName, _priceListId), CustomerId = new EntityReference(Account.EntityLogicalName, _accountId), FreightAmount = new Money(20.0M) }; _orderId = _serviceProxy.Create(order); order.Id = _orderId; // Add the product to the order with the price overriden with a // negative value. SalesOrderDetail orderDetail = new SalesOrderDetail() { ProductId = new EntityReference(Product.EntityLogicalName, _product1Id), Quantity = 4, SalesOrderId = order.ToEntityReference(), IsPriceOverridden = true, PricePerUnit = new Money(-40.0M), UoMId = new EntityReference(UoM.EntityLogicalName, _defaultUnitId) }; _orderDetailId = _serviceProxy.Create(orderDetail); Console.WriteLine("Created order with negative price per unit."); #endregion DeleteRequiredRecords(promptforDelete); } //</snippetWorkingWithNegativePrices1> } // Catch any service fault exceptions that Microsoft Dynamics CRM throws. catch (FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault>) { // You can handle an exception here or pass it back to the calling method. throw; } }
public void AddSalesOrderDetails(SalesOrderDetail salesOrderDetail) { _context.Entry(salesOrderDetail).State=EntityState.Added; _context.SaveChanges(); }