public DeptBudgetAddForm(OrderEntity orderEntity) : base(orderEntity) { fbService = new FBEntityService(); fbService.QueryFBEntitiesCompleted += new EventHandler<QueryFBEntitiesCompletedEventArgs>(fbService_QueryFBEntitiesCompleted); this.EditForm.Saving += new EventHandler<SavingEventArgs>(EditForm_Saving); }
/// <summary> /// 个人经费下拨 构造函数 /// </summary> /// <param name="orderEntity"></param> public PersonMoneyAssignAAForm(OrderEntity orderEntity) : base(orderEntity) { fbService = new FBEntityService(); fbService.QueryFBEntitiesCompleted += new EventHandler<QueryFBEntitiesCompletedEventArgs>(fbService_QueryFBEntitiesCompleted); this.EditForm.Saving += new EventHandler<SavingEventArgs>(EditForm_Saving); }
void OrderView_FBBasePageLoaded(object sender, EventArgs e) { string typeName = this.Type; if (typeName == "AuditOrder") { AuditOrder ao = new AuditOrder(); ao.OrderType = typeName; ao.InitForm(); this.LayoutRoot.Children.Add(ao); currentPart = ao as IWebPart; } else { CommonView commonView = new CommonView(); Type type = CommonFunction.GetType(typeName, CommonFunction.TypeCategory.EntityObject); OrderEntity orderEntity = new OrderEntity(type); commonView.DefaultEntity = orderEntity; commonView.InitForm(); this.LayoutRoot.Children.Add(commonView); currentPart = commonView as IWebPart; } }
public static FBPage GetPage(OrderEntity orderEntity) { Type typeOfEditor = typeof(FBPage); FBPageEditor fbPageEditor = _EditorList.FirstOrDefault(item => { return item.OrderType == orderEntity.OrderType; }); if (fbPageEditor != null) { typeOfEditor = fbPageEditor.EditorType; } try { FBPage page = (FBPage)Activator.CreateInstance(typeOfEditor, orderEntity); page.InitForm(); return page; } catch (Exception ex) { throw ex; //return new FBPage(orderEntity); } }
private void InitData(Order order) { if (this.orderEntity.OrderStatus == EntityAdapter.EditStatus.New) { string typeName = orderEntity.OrderTypeName; this.orderEntity = new OrderEntity(orderEntity.OrderType); this.orderEntity.OrderTypeName = typeName; EmplyeerData itemOwner = DataCore.CurrentUser.CurrentPostInfo.Copy(); this.orderEntity.ReferencedData.Dictionary = order.ReferenceDataInfoList.Dictionary; this.orderEntity.ReferencedData["Entity.OWNERID"] = itemOwner; this.orderEntity.ReferencedData["Entity.OWNERDEPARTMENTID"] = itemOwner.DepartMent; this.orderEntity.ReferencedData["Entity.OWNERCOMPANYID"] = itemOwner.Company; this.orderEntity.SetValue("Entity.CREATEUSERID", DataCore.CurrentUser.UserID); this.orderEntity.SetValue("Entity.UPDATEUSERID", DataCore.CurrentUser.UserID); this.orderEntity.SetValue("Entity.CREATEDATE", DateTime.Now); this.orderEntity.SetValue("Entity.CREATEDEPARTMENTID", DataCore.CurrentUser.CurrentPostInfo.DepartMent.Value); this.orderEntity.SetValue("Entity.CREATECOMPANYID", DataCore.CurrentUser.CurrentPostInfo.Company.Value); this.orderEntity.SetValue("Entity.CREATEDEPARTMENTNAME", DataCore.CurrentUser.CurrentPostInfo.DepartMent.Text); this.orderEntity.SetValue("Entity.CREATECOMPANYNAME", DataCore.CurrentUser.CurrentPostInfo.Company.Text); //暂时 this.orderEntity.SetValue("Entity.OWNERPOSTID", DataCore.CurrentUser.CurrentPostInfo.Post.Value); this.orderEntity.SetValue("Entity.CREATEPOSTID", DataCore.CurrentUser.CurrentPostInfo.Post.Value); this.orderEntity.SetValue("Entity.CREATEPOSTNAME", DataCore.CurrentUser.CurrentPostInfo.Post.Text); this.orderEntity.SetValue("Entity.OWNERPOSTNAME", DataCore.CurrentUser.CurrentPostInfo.Post.Text); } else if (this.orderEntity.OrderStatus == EntityAdapter.EditStatus.Edit) { QueryExpression q = new QueryExpression(); q.PropertyName = orderEntity.Entity.EntityKey.EntityContainerName; q.PropertyValue = orderEntity.OrderID; q.Operation = QueryExpression.Operations.Equal; //orderEntity.Entity.EntityKey.EntityContainerName this.orderEntity = OrderSource.GetOrder(q)[0]; ObjectList<ReferencedDataInfo> list = order.ReferenceDataInfoList; for (int i = 0; i < order.ReferenceDataInfoList.Count; i++) { object key = this.orderEntity.GetValue(list[i].PropertyName); ITextValueItem item = null; if (key != null) { item = DataCore.FindRefData(list[i].ReferencedType, key.ToString()); } orderEntity.ReferencedData.Add(list[i].PropertyName, item); } } }
public CommonForm(OrderEntity orderEntity) : this() { this.orderEntity = orderEntity; OrderSource = CommonFunction.GetOrderSource(orderEntity.Entity.GetType()); Order order = ControlGenerator.GetOrder(orderEntity.OrderType); InitData(order); InitControl(order); }
public OrderForm(OrderEntity orderEntity) : this() { this.editForm.OrderEntity = orderEntity; this.Title = orderEntity.OrderTypeName; this.EditForm.LoadDataComplete += new EventHandler(editForm_LoadDataComplete); this.EditForm.LoadControlComplete += new EventHandler(EditForm_LoadControlComplete); this.EditForm.SaveCompleted += new EventHandler(EditForm_SaveCompleted); }
public CForm(OrderEntity source) { orderEntity = source; Type type = typeof(OrderSource<>).MakeGenericType(new Type[] { source.OrderType }); OrderSource = Activator.CreateInstance(type) as IOrderSource; if (string.IsNullOrEmpty(source.OrderID)) { OperationType = OperationTypes.New; this.GridToolBar_Delete.Visibility = Visibility.Collapsed; } else { OperationType = OperationTypes.Edit; } InitializeComponent(); List<string[]> FInfo = new List<string[]>(); FInfo.Add(new string[]{"单据编号", "OrderCode", "OrderCode", "0", "0"}); FInfo.Add(new string[] { "状态", "OrderStates", "OrderStates", "0", "0" }); FInfo.Add(new string[] { "创建人", "CreateUser", "CreateUser", "0", "0" }); FInfo.Add(new string[] { "创建时间", "CreateDate", "CreateDate", "0", "0" }); this.GForm.LeftFForm.Items = GetFieldItems(FInfo); this.GForm.LeftFForm.InitForm(); FInfo.Clear(); FInfo.Add(new string[] { "单据类型", "OrderType", "OrderType", "0", "0" }); FInfo.Add(new string[] { "申请人", "Applicant", "Applicant", "3", "1" }); FInfo.Add(new string[] { "申请部门", "AppliedDepartMent", "AppliedDepartMentData", "2", "1" }); FInfo.Add(new string[] { "申请公司", "Company", "CompanyData", "2", "1" }); this.GForm.RightForm.Items = GetFieldItems(FInfo); this.GForm.RightForm.InitForm(); FInfo.Clear(); FInfo.Add(new string[] { "备注", "Remark", "Remark", "4", "0" }); this.GFormRemark.Items = GetFieldItems(FInfo); this.GFormRemark.InitForm(); FInfo.Clear(); FInfo.Add(new string[] { "编号", "SerialNumber", "75", "1" }); FInfo.Add(new string[] { "预算项目", "ObjectName", "200", "1" }); FInfo.Add(new string[] { "可用金额", "UsableMoney", "100", "1" }); FInfo.Add(new string[] { "已用金额", "UsedMoney", "100", "0" }); FInfo.Add(new string[] { "费用类型", "ChargeType", "100", "1" }); this.AGrid.Items= GetDataGridItem(FInfo); this.AGrid.InitGrid(); BindingData(); }
public static OrderModel CreateFromEntity(OrderEntity o) { if (o == null) { return null; } return new OrderModel { OrderId = o.OrderId, UserId = o.UserId, OrderDate = o.OrderDate, SubTotal = o.SubTotal, Tax = o.Tax, OtherCharges = o.OtherCharges, Notes = o.Notes, Status = o.Status }; }
/// <summary> /// 更新Order 实体 /// </summary> /// <param name="entity">OrderModel对象</param> public void UpdateOrder(OrderEntity entity) { var parameters = new StatementParameterCollection(); parameters.AddInParameter("@OrderId", DbType.Int64, entity.OrderId); parameters.AddInParameter("@UserId", DbType.Int64, entity.UserId); parameters.AddInParameter("@Name", DbType.String, entity.Name); parameters.AddInParameter("@Price", DbType.Decimal, entity.Price); parameters.AddInParameter("@ProductId", DbType.Int64, entity.ProductId); parameters.AddInParameter("@CreateTime", DbType.DateTime, entity.CreateTime); parameters.AddInParameter("@UpdateTime", DbType.DateTime, entity.UpdateTime); try { DB.ExecSp("spA_Order_u", parameters); } catch (Exception ex) { throw new DalException("调用 OrderDal 时,访问 UpdateOrder 时出错", ex); } }
/// <summary> /// 向数据库中插入 Order 实体 /// </summary> /// <param name="entity">OrderModel对象</param> /// <returns>自增主键</returns> public long InsertOrder(OrderEntity entity) { var parameters = new StatementParameterCollection(); parameters.AddOutParameter("@OrderId", DbType.Int64, 8); parameters.AddInParameter("@UserId", DbType.Int64, entity.UserId); parameters.AddInParameter("@Name", DbType.String, entity.Name); parameters.AddInParameter("@Price", DbType.Decimal, entity.Price); parameters.AddInParameter("@ProductId", DbType.Int64, entity.ProductId); parameters.AddInParameter("@CreateTime", DbType.DateTime, entity.CreateTime); parameters.AddInParameter("@UpdateTime", DbType.DateTime, entity.UpdateTime); try { DB.ExecSp("spA_Order_i", parameters); return Convert.ToInt64(parameters["@OrderId"].Value); } catch (Exception ex) { throw new DalException("调用 OrderDal 时,访问 InsertOrder 时出错", ex); } }
public ChargeApplyForm(OrderEntity order ) : this() { GridItem dgi1 = new GridItem(); GridItem dgi2 = new GridItem(); GridItem dgi3 = new GridItem(); GridItem dgi4 = new GridItem(); GridItem dgi5 = new GridItem(); AGrid.Items.Add(dgi1); AGrid.Items.Add(dgi2); AGrid.Items.Add(dgi3); AGrid.Items.Add(dgi4); AGrid.Items.Add(dgi5); dgi1.PropertyDisplayName = "单据编号"; dgi1.PropertyName = "OrderCode"; dgi1.Width = 75; dgi2.PropertyDisplayName = "单据类型"; dgi2.PropertyName = "OrderType"; dgi2.Width = 75; dgi3.PropertyDisplayName = "状态"; dgi3.PropertyName = "OrderStates"; dgi3.Width = 75; dgi4.PropertyDisplayName = "申请人"; dgi4.PropertyName = "Applicant"; dgi4.Width = 75; dgi5.PropertyDisplayName = "申请部门"; dgi5.PropertyName = "AppliedDepartMent"; dgi5.Width = 75; AGrid.InitGrid(); }
protected void GetEditForm(OrderEntity orderEntity) { forms.ToList().ForEach( form => { form.Visibility = Visibility.Collapsed; }); if (orderEntity == null) { return; } string key = orderEntity.OrderType.Name; EditForm editForm = null; if (!forms.Dictionary.ContainsKey(key)) { editForm = new EditForm(orderEntity); editForm.RefreshEntityWhenLoad = false; editForm.LoadControlComplete += new EventHandler(editForm_LoadControlComplete); forms.Add(key, editForm); editForm.InitForm(); //editForm.HorizontalAlignment = HorizontalAlignment.Stretch; this.MainGrid.Children.Add(editForm); } else { editForm = forms[key]; editForm.OrderEntity = orderEntity; Title = orderEntity.OrderTypeName; editForm.InitForm(); editForm.Visibility = Visibility.Visible; } CurrentEditForm = editForm; }
public CommonView(OrderEntity orderEntity) : this() { this.DefaultEntity = orderEntity; InitForm(); }
public bool Save(OrderEntity order) { //validate return(repository.Update(order)); }
public async Task ThenTheOrderDescriptionForOrderWithIdIsSetToDaysAgo(int orderId, int days) { var actual = await OrderEntity.FetchOrderByOrderId(settings.ConnectionString, orderId); actual.CommencementDate?.Date.Should().Be(DateTime.Today.Date - TimeSpan.FromDays(days)); }
public void SetOrderStatus(OrderEntity order, OrderStatus status) { order.OrderStatus = OrderStatus.SentOut; DataBaseContext.SaveChanges(); }
public OrderEntity GetOrderByCode(long code) { OrderEntity _order = OrderDA.Instance.GetOrderByCode(code); return(_order); }
public ActionResult SubmitForm(OrderEntity orderEntity, UserLogOnEntity userLogOnEntity, string keyValue) { orderEntity.c_state = (int)OrderState.HadDeal; orderApp.SubmitForm(orderEntity, keyValue); return(Success("操作成功。")); }
public bool UpdateOrder(OrderEntity entity) { return(orderInsertDB.UpdateOrder(entity)); }
public long AddOrder(OrderEntity entity) { return(orderInsertDB.InsertOrder(entity)); }
/// <summary> /// 更新一条Order记录。 /// 该方法提供给界面等UI层调用 /// </summary> /// <param name="order">待更新的实体对象</param> /// <param name="columns">要更新的列名,不提供任何列名时默认将更新主键之外的所有列</param> public int UpdateOrder(OrderEntity order) { return(OrderDA.Instance.UpdateOrder(order)); }
public ActionResult SubmitForm(OrderEntity deviceEntity, string keyValue) { deviceApp.SubmitForm(deviceEntity, keyValue); return(Success("操作成功。")); }
public async Task ThenTheLastUpdatedNameIsUpdatedInTheDatabase(string expected, int orderId) { var actual = (await OrderEntity.FetchOrderByOrderId(settings.ConnectionString, orderId)).LastUpdatedByName; actual.Should().BeEquivalentTo(expected); }
protected List <OrderEntity> ResolveOrders(DataTable excelTable, string file, List <OrderEntity> items) { OrderDTO orderDTO = new OrderDTO(); orderDTO.orderStatus = OrderStatus.Predelivery; orderDTO.fileName = file; orderDTO.orderType = 0; for (int i = 0; i < excelTable.Rows.Count; i++) { var row = excelTable.Rows[i]; orderDTO.source = Name; orderDTO.sourceDesc = Util.Helpers.Reflection.GetDescription <OrderSource>(Name); orderDTO.sourceSN = Convert.ToString(row["平台单号"]); //订单号 if (string.IsNullOrEmpty(orderDTO.sourceSN)) { InputExceptionOrder(orderDTO, ExceptionType.SourceSnIsNull); continue; } var orderDateStr = Convert.ToString(row["下单时间"]); //订单创建时间 orderDTO.createdDate = DateTime.Parse(orderDateStr); orderDTO.productName = Convert.ToString(row["商品名称"]); //商品名称 // orderDTO.productsku = Convert.ToString(row[2]); //商品编号 orderDTO.count = Convert.ToInt32(row["数量"]); //数量 orderDTO.orderSN = string.Format("{0}-{1}_{2}", orderDTO.source, orderDTO.sourceSN, orderDTO.createdDate.ToString("yyyyMMdd")); if (CheckOrderInDataBase(orderDTO))//是否是重复订单 { continue; } var item = items.Find(o => o.OrderSn == orderDTO.orderSN); if (item == null) { // var productProps = Convert.ToString(row[5]); //商品属性 orderDTO.consigneeName = Convert.ToString(row["收件人姓名"]); //收件人 orderDTO.consigneePhone = Convert.ToString(row["手机号码"]); //联系电话 orderDTO.consigneePhone2 = string.Empty; orderDTO.consigneeProvince = Convert.ToString(row["省"]); orderDTO.consigneeCity = Convert.ToString(row["市"]); orderDTO.consigneeCounty = Convert.ToString(row["县"]); orderDTO.consigneeAddress = Convert.ToString(row["详细地址"]); //收货地区+详细地址 // orderDTO.consigneeZipCode = Convert.ToString(row["邮编"]); //邮编 // if (string.IsNullOrEmpty(orderDTO.consigneeProvince) && string.IsNullOrEmpty(orderDTO.consigneeCity) && !string.IsNullOrEmpty(orderDTO.consigneeAddress)) { var addrInfo = DistrictService.DistrictService.ResolveAddress(orderDTO.consigneeAddress); orderDTO.consigneeProvince = addrInfo.Province; orderDTO.consigneeCity = addrInfo.City; orderDTO.consigneeCounty = addrInfo.County; // consigneeAddress = addrInfo.Address; } var totalQuantity = orderDTO.count; orderDTO.PayType = PayType.None; OrderEntity orderItem = OrderEntityService.CreateOrderEntity(orderDTO); using (var db = new OMSContext()) { //查找联系人 if (!string.IsNullOrEmpty(orderItem.Consignee.Phone)) { OrderEntityService.InputConsigneeInfo(orderItem, db); } else //异常订单 { InputExceptionOrder(orderDTO, ExceptionType.PhoneNumOrPersonNameIsNull); continue; } if (!InputProductInfoWithoutSaveChange(db, orderDTO, orderItem)) { continue; } items.Add(orderItem); if (orderItem.OrderRepurchase == null) { orderItem.OrderRepurchase = new OrderRepurchase(); } db.OrderRepurchases.Add(orderItem.OrderRepurchase); db.OrderDateInfos.Add(orderItem.OrderDateInfo); db.SaveChanges(); } } else { orderDTO.productName = Convert.ToString(row["商品名称"]); //商品名称 orderDTO.count = Convert.ToInt32(row["数量"]); //数量 using (var db = new OMSContext()) { InputProductInfoWithoutSaveChange(db, orderDTO, item); } } } return(items); }
private void ShowEditForm(OrderEntity orderEntity, OperationTypes operationType) { //OrderForm caForm = CommonFunction.GetOrderForm(orderEntity); //caForm.Width = this.ActualWidth; //caForm.Height = this.ActualHeight; //caForm.Closed += (o, e) => //{ // if (caForm.IsNeedToRefresh) // { // this.GetOrders(); // } //}; //caForm.Show(); FBPage page = FBPage.GetPage(orderEntity); page.EditForm.OperationType = operationType; FrameworkElement plRoot = CommonFunction.ParentLayoutRoot; EntityBrowser eb = new EntityBrowser(page); eb.EntityScrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto; eb.Show<string>(DialogMode.Default, plRoot, "", (result) => { }); page.RefreshData += (o, e) => { this.GetOrders(); }; page.PageClosing += (o, e) => { eb.Close(); }; }
public ActionResult postOrder([FromBody] FormPutOrder formOrder) { // Lấy UserEntity đang đăng nhập từ jwt UserEntity user = (UserEntity)HttpContext.Items["User"]; Console.WriteLine("User: "******"User"] = null; //Xóa hết tất cả sản phẩm trong giỏ hàng orderDAO.deleteAllItemCart(user.Id); OrderEntity c = new OrderEntity(); c.AddressDelivery = formOrder.Address; c.Email = formOrder.Email; c.Phone = formOrder.Phone; c.Fullname = formOrder.Fullname; c.Note = formOrder.Note; c.UserId = user.Id; c = orderDAO.SaveOrder(c); // c = orderDAO.getOrder(c); if (c == null) { return(BadRequest("Not save orderEntity")); } Console.WriteLine("Order: {0}", c.Id); // if(c!=null) return Ok(c); ; // return Ok(c); foreach (OrderItem ci in formOrder.CartItems) { Console.WriteLine("productId: {0}, amount: {1}", ci.Idp, ci.Quantity); if (ci.Idp == 0) { return(BadRequest("Thiếu tham số idp.")); } Console.WriteLine("productSpecificId {0}", ci.Idp); Product2 p = product2DAO.getProduct(ci.Idp); if (p == null) { return(BadRequest()); } try { OrderItemEntity cartItemEntity = null; if (c.Items != null) { cartItemEntity = c.Items.Find(X => X.ProductId.CompareTo(ci.Idp) == 0); } else { c.Items = new List <OrderItemEntity>(); } Console.WriteLine("orderItemEntity: {0}", cartItemEntity); if (cartItemEntity == null) { cartItemEntity = new OrderItemEntity(); cartItemEntity.Quantity = ci.Quantity; cartItemEntity.ProductId = ci.Idp; cartItemEntity.OrderId = c.Id; cartItemEntity.Product = p; // if (cartItemEntity.Deleted == false) { c.Items.Add(cartItemEntity); } } else { Console.WriteLine("Increase amount"); cartItemEntity.Quantity += ci.Quantity; //cartItemEntity.Quantity = ci.Quantity; if (cartItemEntity.Quantity < 0) { return(BadRequest("Số lượng item trong giỏ hàng nhỏ hơn 0, hãy xóa item này khỏi giỏ hàng")); } } cartItemEntity.Actived = ci.Actived; cartItemEntity.Deleted = ci.Deleted; cartItemEntity = orderDAO.SaveOrder(cartItemEntity); } catch (Exception e) { if (e.InnerException != null) { Console.WriteLine(e.InnerException.Message); } return(BadRequest(e.Message)); } } //Payment c = orderDAO.getOrder(c); PaymentEntity paymentEntity = new PaymentEntity(); paymentEntity.userId = user.Id; paymentEntity.Amount = c.TotalPrice * 100; paymentEntity.CurrCode = "VND"; //paymentEntity.UrlReturn = "htpp://localhost:3000/accept"; paymentEntity.UrlReturn = formOrder.UrlReturn; paymentEntity.CreateTime = DateTime.Now; paymentEntity.IpAddress = "119.17.249.22"; paymentEntity = paymentDAO.AddPayment(paymentEntity); paymentEntity.gender("https://localhost:25002/payment/redirect"); paymentEntity = paymentDAO.UpdatePayment(paymentEntity); c.Payment = paymentEntity; c.PaymentId = paymentEntity.Id; Console.WriteLine("REST-Payment Id: {0}", c.PaymentId); orderDAO.UpdateOrder(c); c = orderDAO.getOrder(c); // return Ok((OrderDTO)c); return(Ok(new OrderDTO(c))); //return Ok(c); }
public void DeleteOrder(OrderEntity entity) { orderInsertDB.DeleteOrder(entity); }
public void Save(OrderEntity orderEntity) { FBEntity newEntity = orderEntity.GetModifiedFBEntity(); Save(newEntity); }
public static void CreateBakOrder(OrderEntity entity, string type) { if (IsExistOrder(entity.UserId, entity.OrderId)) { return; } #region var master = new TakeMasterMeta(); master.BuyState = type == "Sale" ? BuyTakeBuyState.Sale : BuyTakeBuyState.Pre; master.State = BuyTakeState.Success; master.PayType = BuyTakePayType.Paid; master.OptTime = entity.OptTime.ToString(); master.MemoStr = entity.MemoStr; master.DeliverFee = entity.DeliverFee; master.DeliverAddress = entity.DeliverAddress; master.DeliverTime = entity.DeliverTime > entity.OptTime ? entity.DeliverTime.ToString() : entity.OptTime.ToString(); master.UserMobile = entity.UserMobile; master.UserName = entity.UserName; master.Consume = entity.Consume; master.TtlPrice = entity.TtlPrice; master.OrderType = type == "Sale" ? BuyTakeOrderType.Sale : BuyTakeOrderType.Pre; master.OrderId = entity.OrderId; master.TakeType = (BuyTakeType)entity.TakeType; var details = new BuyDetailList(); foreach (var dtl in entity.OrderDtls) { details.Add(new BuyDetailMeta { ProdName = dtl.ProdName, ProdNo = dtl.ProdNo, ProdUnit = dtl.ProdUnit, Price = dtl.Price, ItemCnt = dtl.ItemCnt, ItemSum = dtl.ItemSum }); } #endregion //处理远程创建订单死锁的问题,循环5次 //var times = 0; //int[] seconds = { 2000, 5000, 10000, 30000, 60000 }; //while (times < 5) //{ try { var conn = GetConnect(entity.UserId); if (conn is null) { return; } var takeBill = new BuyTakeBill(conn); string err; if (type == "Sale") { takeBill.SaleSave(entity.ShopNo, master, details, out err); } else { takeBill.PreSave(entity.ShopNo, master, details, out err); } conn.Close(); } catch (Exception e) { // ignored } //await Task.Delay(seconds[times]); //Thread.Sleep(seconds[times]); //times++; }
public static int CreateOrder(OrderEntity entity) { return(1); }
/// <summary> /// 保存表单(新增、修改) /// </summary> /// <param name="keyValue">主键值</param> /// <param name="orderEntity">实体对象</param> /// <param name="orderEntryList">明细实体对象</param> /// <returns></returns> public void SaveForm(string keyValue, OrderEntity orderEntity, List <OrderEntryEntity> orderEntryList, List <Client_OrderDescriptionEntity> orderDescriptionList) { IRepository db = new RepositoryFactory().BaseRepository().BeginTrans(); try { if (!string.IsNullOrEmpty(keyValue)) { //主表 orderEntity.Modify(keyValue); db.Update(orderEntity); //明细 db.Delete <OrderEntryEntity>(t => t.OrderId.Equals(keyValue)); foreach (OrderEntryEntity orderEntryEntity in orderEntryList) { orderEntryEntity.OrderId = orderEntity.OrderId; db.Insert(orderEntryEntity); } if (orderDescriptionList != null) { //备注明细 db.Delete <Client_OrderDescriptionEntity>(t => t.OrderId.Equals(keyValue)); foreach (Client_OrderDescriptionEntity orderDescriptionEntity in orderDescriptionList) { orderDescriptionEntity.OrderId = orderEntity.OrderId; if (orderDescriptionEntity.DescriptionId == string.Empty) { orderDescriptionEntity.DescriptionId = Guid.NewGuid().ToString(); } //orderDescriptionEntity.CreateDate = DateTime.Now; //orderDescriptionEntity.CreateUserId = OperatorProvider.Provider.Current().UserId; //orderDescriptionEntity.CreateUserName = OperatorProvider.Provider.Current().UserName; db.Insert(orderDescriptionEntity); } } } else { //主表 orderEntity.Create(); db.Insert(orderEntity); coderuleService.UseRuleSeed(orderEntity.CreateUserId, "", ((int)CodeRuleEnum.Customer_OrderCode).ToString(), db);//占用单据号 //明细 foreach (OrderEntryEntity orderEntryEntity in orderEntryList) { orderEntryEntity.Create(); orderEntryEntity.OrderId = orderEntity.OrderId; db.Insert(orderEntryEntity); } if (orderDescriptionList != null) { //备注明细 foreach (Client_OrderDescriptionEntity orderDescriptionEntity in orderDescriptionList) { orderDescriptionEntity.Create(); orderDescriptionEntity.OrderId = orderEntity.OrderId; db.Insert(orderDescriptionEntity); } } } db.Commit(); } catch (Exception) { db.Rollback(); throw; } }
public async Task <int> PlaceOrder(OrderEntity cookie) { return(await _mediator.Send(new CreateOrder.Command { Order = cookie })); }
public long WeChatPay(string code) { using (MyDbContext dbc = new MyDbContext()) { OrderEntity order = dbc.GetAll <OrderEntity>().SingleOrDefault(o => o.Code == code); if (order == null) { return(-1); } if (order.OrderState.Name != "待付款") { return(-4); } UserEntity user = dbc.GetAll <UserEntity>().Where(u => u.IsNull == false).SingleOrDefault(u => u.Id == order.BuyerId); if (user == null) { return(-2); } //更新库存、销量 UpdateGoodsInfo(dbc, order); #region 订单商品遍历 // var orderlists = dbc.GetAll<OrderListEntity>().Where(o => o.OrderId == order.Id).ToList(); // decimal totalAmount = 0; /* * foreach (var orderlist in orderlists) * { * GoodsEntity goods = dbc.GetAll<GoodsEntity>().SingleOrDefault(g => g.Id == orderlist.GoodsId); * * totalAmount = totalAmount + orderlist.TotalFee; * * if (goods == null) * { * continue; * } * * if (!goods.IsPutaway) * { * return -5; * } * * if (goods.Inventory < orderlist.Number) * { * return -3; * } * * BonusRatioEntity bonusRatio = dbc.GetAll<BonusRatioEntity>().SingleOrDefault(b => b.GoodsId == goods.Id); * decimal one = 0; * decimal two = 0; * decimal three = 0; * * long journalTypeId = dbc.GetId<IdNameEntity>(i => i.Name == "佣金收入"); * * UserEntity oneer = dbc.GetAll<UserEntity>().Where(u => u.IsNull == false).SingleOrDefault(u => u.Id == user.Recommend.RecommendId); * if (oneer != null && oneer.Recommend.RecommendPath != "0") * { * one = bonusRatio.CommonOne * orderlist.Number; * * //if (oneer.Level.Name == "普通会员" && bonusRatio != null) * //{ * // one = bonusRatio.CommonOne / 100; * //} * //else if (oneer.Level.Name == "黄金会员" && bonusRatio != null) * //{ * // one = bonusRatio.GoldOne / 100; * //} * //else if (oneer.Level.Name == "铂金会员" && bonusRatio != null) * //{ * // one = bonusRatio.PlatinumOne / 100; * //} * * oneer.Amount = oneer.Amount + one; * oneer.BonusAmount = oneer.BonusAmount + orderlist.TotalFee * one; * * JournalEntity journal1 = new JournalEntity(); * journal1.UserId = oneer.Id; * //journal1.BalanceAmount = oneer.Amount; * journal1.InAmount = one; * journal1.Remark = "商品佣金收入"; * journal1.JournalTypeId = journalTypeId; * journal1.OrderCode = order.Code; * journal1.GoodsId = goods.Id; * journal1.IsEnabled = false; * dbc.Journals.Add(journal1); * * UserEntity twoer = dbc.GetAll<UserEntity>().Where(u => u.IsNull == false).SingleOrDefault(u => u.Id == oneer.Recommend.RecommendId); * if (twoer != null && twoer.Recommend.RecommendPath != "0") * { * two = bonusRatio.CommonTwo * orderlist.Number; * //if (twoer.Level.Name == "普通会员" && bonusRatio != null) * //{ * // two = bonusRatio.CommonTwo / 100; * //} * //else if (twoer.Level.Name == "黄金会员" && bonusRatio != null) * //{ * // two = bonusRatio.GoldTwo / 100; * //} * //else if (twoer.Level.Name == "铂金会员" && bonusRatio != null) * //{ * // two = bonusRatio.PlatinumTwo / 100; * //} * * twoer.Amount = twoer.Amount + two; * twoer.BonusAmount = twoer.BonusAmount + two; * * JournalEntity journal2 = new JournalEntity(); * journal2.UserId = twoer.Id; * //journal2.BalanceAmount = twoer.Amount; * journal2.InAmount = two; * journal2.Remark = "商品佣金收入"; * journal2.JournalTypeId = journalTypeId; * journal2.OrderCode = order.Code; * journal2.GoodsId = goods.Id; * journal2.IsEnabled = false; * dbc.Journals.Add(journal2); * * UserEntity threer = dbc.GetAll<UserEntity>().Where(u => u.IsNull == false).SingleOrDefault(u => u.Id == twoer.Recommend.RecommendId); * if (threer != null && threer.Recommend.RecommendPath != "0") * { * three = bonusRatio.CommonThree * orderlist.Number; * //if (threer.Level.Name == "普通会员" && bonusRatio != null) * //{ * // three = bonusRatio.CommonThree / 100; * //} * //else if (threer.Level.Name == "黄金会员" && bonusRatio != null) * //{ * // three = bonusRatio.GoldThree / 100; * //} * //else if (threer.Level.Name == "铂金会员" && bonusRatio != null) * //{ * // three = bonusRatio.PlatinumThree / 100; * //} * * threer.FrozenAmount = threer.FrozenAmount + three; * //threer.BonusAmount = threer.BonusAmount + orderlist.TotalFee * three; * * JournalEntity journal3 = new JournalEntity(); * journal3.UserId = threer.Id; * //journal3.BalanceAmount = threer.Amount; * journal3.InAmount = three; * journal3.Remark = "商品佣金收入"; * journal3.JournalTypeId = journalTypeId; * journal3.OrderCode = order.Code; * journal3.GoodsId = goods.Id; * journal3.IsEnabled = false; * dbc.Journals.Add(journal3); * } * } * } * goods.Inventory = goods.Inventory - orderlist.Number; * goods.SaleNum = goods.SaleNum + orderlist.Number; * } */ #endregion int upLevelId = 1; order.PayTime = DateTime.Now; order.PayTypeId = dbc.GetId <IdNameEntity>(i => i.Name == "微信"); order.OrderStateId = dbc.GetId <IdNameEntity>(i => i.Name == "待发货"); if (order.Deliver == "无需物流") { order.OrderStateId = dbc.GetId <IdNameEntity>(i => i.Name == "已完成"); } JournalEntity journal = new JournalEntity(); journal.UserId = user.Id; journal.BalanceAmount = user.Amount; journal.OutAmount = order.Amount; journal.Remark = "微信支付购买商品"; journal.JournalTypeId = 1; journal.LevelId = upLevelId; journal.OrderCode = order.Code; dbc.Journals.Add(journal); if (dbc.SaveChanges() > 0) { CalcSroce(user.Id, order.Amount); // 累计业绩 } log.DebugFormat("微信支付后订单状态:{0}", order.OrderStateId); return(1); } }
public void OrderNew(MessageModel message) { IEleShopService shopservice = new EleShopService(); IOrderService orderService = new OrderService(); var shop = shopservice.GetByShopId(message.shopId); if (shop is null) { return; } var model = JsonConvert.DeserializeObject <OrderModel>(message.message); //if (orderService.IsExist(model.id)) return; if (orderService.IsExist(model.orderId)) { return; } var entity = new OrderEntity() { UserId = shop.UserId, ShopNo = shop.ShopNo, TakeType = 1, OrderId = model.orderId ?? model.id, TtlPrice = model.originalPrice, Consume = model.totalPrice, UserName = model.consignee, UserMobile = string.Join(",", model.phoneList), DeliverTime = model.deliverTime == null ? new DateTime(1970, 1, 1) : DateTime.Parse(model.deliverTime.ToString()), DeliverAddress = model.address, DeliverFee = model.deliverFee, MemoStr = model.description, OptTime = model.activeAt, //PayType = 0, State = model.status.GetOrder(), DaySeq = model.daySn, Greeting = model.userExtraInfo.greeting //祝福语(饿了么) }; var list = new List <OrderDtlEntity>(); foreach (var group in model.groups) { if (group.type != "normal") { continue; //type:normal extra ,排除其他 } foreach (var item in group.items) { var prodNo = item.extendCode ?? ""; //如果商品未映射,且价格为0,则忽略,排除广告 if (string.IsNullOrWhiteSpace(prodNo) && item.price == 0) { continue; } var prodCountList = prodNo.Trim('X').Split('X').GroupBy(a => a).Select(a => new { ProdNo = a.Key, Count = a.Count() }); foreach (var prodCount in prodCountList) { //list.Add(new OrderDtlEntity() //{ // ProdNo = prodCount.ProdNo, // ProdName = item.name, // ProdUnit = "", // Price = item.price / prodCount.Count, // ItemCnt = item.quantity * prodCount.Count, // ItemSum = item.price * item.quantity //}); //改为取365商品信息,如果未匹配上365商品,则取饿了么商品信息 var prod = Bak365Service.GetProd(entity.UserId, prodCount.ProdNo); list.Add(new OrderDtlEntity() { ProdNo = prod.ProdNo ?? "", ProdName = string.IsNullOrWhiteSpace(prod.ProdName) ? item.name : prod.ProdName + item.attributes?.Aggregate(" ", (x, y) => x + (y.value + ",")).TrimEnd(','), //咖啡 热,不需要 ProdUnit = prod.ProdUnit ?? "", Price = double.Parse(prod.Price ?? item.price.ToString()), ItemCnt = item.quantity * prodCount.Count, ItemSum = double.Parse(prod.Price ?? item.price.ToString()) * item.quantity * prodCount.Count }); } } } entity.OrderDtls = list; try { //判断商品中是否有预订商品 if (_preProdService.hasPreProd(shop.UserId, list.Select(a => a.ProdNo).ToArray())) { entity.OrderType = 1; entity.BuyState = 2; //0未生成现购单 1已生成现购单 2已生成预定单 3已提货 4已预定作废 Bak365Service.CreateBakOrder(entity, "Pre"); ////处理远程创建订单死锁的问题,循环5次 //var times = 0; //int[] seconds = { 2000, 5000, 10000, 30000, 60000 }; //while (times < 5) //{ // Bak365Service.CreateBakOrder(entity, "Pre"); // //如果生成预订单成功,则更改生成状态 // if (string.IsNullOrWhiteSpace("")) // { // break; // } // await Task.Delay(seconds[times]); // times++; //} } } catch (Exception e) { _log.DebugFormat("【系统错误】类型:CreateOrder 信息:{0} 错误:{1}", JsonConvert.SerializeObject(model), e.Message); } finally { orderService.Add(entity); //发送通知 Bak365Service.SendBakNotice(entity.UserId, entity.OrderId, entity.ShopNo, 0); } //是否自动接单 //var shopConfig = _shopConfigService.GetAsync(shop.UserId, shop.ShopNo).Result; //if (shopConfig.EleAutoConfirm == 0) //{ // //var controller = new OrderController(); // //controller.Confirm(shop.UserId, shop.ShopNo, 1, model.orderId); // var service = new EleOrderApiService(); // var res = service.ConfirmOrderLite(shop.AccessToken, model.orderId); //} }
/// <summary> /// 判断对象是否存在 /// </summary> /// <param name="dicEnum"></param> /// <returns></returns> public bool IsExist(OrderEntity order) { return(OrderDA.Instance.ExistNum(order) > 0); }
/// <summary> /// 验证金额 /// </summary> /// <param name="info"></param> /// <param name="dataEntity"></param> /// <param name="order"></param> /// <returns></returns> protected virtual bool ValidateOrderReceivedAmount(OrderPayEntity info, OrderPayEntity dataEntity, OrderEntity order) { if (order == null) { return(true); } if (!info.HasSaveProperty(it => it.Amount)) { return(true); } if (dataEntity != null && dataEntity.Amount == info.Amount) { return(true); } var amount = info.Amount; if (dataEntity != null) { amount = amount - dataEntity.Amount; } if (order.TotalAmount < order.PayAmount + amount) { info.AddErrorByName(typeof(OrderEntity).FullName, "AmountLessPayAmount"); return(false); } return(true); }
/// <summary> /// 添加 部门项目actived 改变时,触发事件 /// </summary> /// <param name="departmentEntity"></param> private void AttachEventToSubjectDepartment(OrderEntity departmentEntity) { ObservableCollection<FBEntity> listOfSubjectDepartmentFB = departmentEntity.GetRelationFBEntities(typeof(T_FB_SUBJECTDEPTMENT).Name); listOfSubjectDepartmentFB.ToList().ForEach(item => { item.Entity.PropertyChanged += new PropertyChangedEventHandler(SubjectDepartment_PropertyChanged); }); }
/// <summary> /// 导入借款单 /// Creator:安凯航 /// 日期:2011年5月30日 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void btnImportBorrowData_Click(object sender, RoutedEventArgs e) { //导入时间 DateTime createTime = DateTime.Now; OpenFileDialog dialog = new OpenFileDialog() { Multiselect = false, Filter = "Excel 2007-2010 File(*.xlsx)|*.xlsx" }; bool? userClickedOK = dialog.ShowDialog(); // Process input if the user clicked OK. if (userClickedOK != true) { return; } try { //待保存数据列表 List<OrderEntity> orders = new List<OrderEntity>(); #region 读取Excel文件 XLSXReader reader = new XLSXReader(dialog.File); List<string> subItems = reader.GetListSubItems(); var maseters = reader.GetData(subItems[0]); var listm = maseters.ToDataSource(); var details = reader.GetData(subItems[1]); var listd = details.ToDataSource(); List<dynamic> masterList = new List<dynamic>(); foreach (var item in listm) { dynamic d = item; masterList.Add(d); } //排除第一行信息 masterList.Remove(masterList.First()); List<dynamic> detailList = new List<dynamic>(); foreach (var item in listd) { dynamic d = item; detailList.Add(d); } //排除第一行信息 detailList.Remove(detailList.First()); #endregion #region 添加主表 List<T_FB_BORROWAPPLYMASTER> import = new List<T_FB_BORROWAPPLYMASTER>(); foreach (var item in masterList) { //构造OrderEntity数据 OrderEntity oe = new OrderEntity(typeof(T_FB_BORROWAPPLYMASTER)); orders.Add(oe); T_FB_BORROWAPPLYMASTER t = oe.FBEntity.Entity as T_FB_BORROWAPPLYMASTER; t.BORROWAPPLYMASTERID = Guid.NewGuid().ToString(); t.BORROWAPPLYMASTERCODE = item.单据号; if (item.借款类型 == "普通借款") { t.REPAYTYPE = 1; } else if (item.借款类型 == "备用金借款") { t.REPAYTYPE = 2; } else if (item.借款类型 == "专项借款") { t.REPAYTYPE = 3; } else { continue; } t.REMARK = item.备注; import.Add(t); } #endregion #region 添加子表 foreach (var item in detailList) { OrderEntity oe = orders.FirstOrDefault(oen => { T_FB_BORROWAPPLYMASTER bm = oen.FBEntity.Entity as T_FB_BORROWAPPLYMASTER; if (bm.BORROWAPPLYMASTERCODE == item.单据号) { return true; } else { return false; } }); if (oe == null) { string message = "导入的借款单明细借款单号为\"" + item.单据号 + "\"的明细,没有相应的借款单对应.请检查借款Excel中是否有此借款单的数据"; throw new InvalidOperationException(message); } FBEntity fbdetail = oe.CreateFBEntity<T_FB_BORROWAPPLYDETAIL>(); T_FB_BORROWAPPLYDETAIL d = fbdetail.Entity as T_FB_BORROWAPPLYDETAIL; d.BORROWAPPLYDETAILID = Guid.NewGuid().ToString(); d.REMARK = item.摘要; d.BORROWMONEY = Convert.ToDecimal(item.借款金额); d.UNREPAYMONEY = Convert.ToDecimal(item.未还款金额); d.T_FB_SUBJECT = d.T_FB_SUBJECT ?? new T_FB_SUBJECT(); d.T_FB_SUBJECT.SUBJECTID = item.借款科目; d.CREATEDATE = createTime; d.CREATEUSERID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID; d.UPDATEDATE = createTime; d.UPDATEUSERID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID; } #endregion //服务 OrderEntityService service = new OrderEntityService(); #region 得到科目信息 QueryExpression reExp = QueryExpressionHelper.Equal("OWNERID", SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID); QueryExpression exp = QueryExpressionHelper.Equal("OWNERPOSTID", SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].PostID); exp.QueryType = "T_FB_BORROWAPPLYDETAIL"; exp.RelatedExpression = reExp; exp.IsUnCheckRight = true; #endregion #region 获取申请人信息 ObservableCollection<string> numbers = new ObservableCollection<string>(); masterList.ForEach(item => numbers.Add(item.申请人身份证号));//拿到所有身份证号 SMT.Saas.Tools.PersonnelWS.PersonnelServiceClient client = new Saas.Tools.PersonnelWS.PersonnelServiceClient(); client.GetEmployeesByIdnumberAsync(numbers); #endregion #region 先获取申请人信息,待申请人信息填充完毕之后进行下一步操作 client.GetEmployeesByIdnumberCompleted += new EventHandler<Saas.Tools.PersonnelWS.GetEmployeesByIdnumberCompletedEventArgs>((oo, ee) => { if (ee.Error == null) { string message = null; try { masterList.ForEach(m => { //添加owner和creator SMT.Saas.Tools.PersonnelWS.V_EMPLOYEEVIEW userview = null; try { userview = ee.Result.First(t => t.IDNUMBER == m.申请人身份证号); } catch (InvalidOperationException ex) { message = ex.Message + "\n" + "在系统中找不到身份证号为\"" + m.申请人身份证号 + "\"的,员工信息.也可能是您没有相应的权限."; throw new InvalidOperationException(message); } T_FB_BORROWAPPLYMASTER master = null; try { master = import.First(t => t.BORROWAPPLYMASTERCODE == m.单据号); } catch (InvalidOperationException ex) { message = ex.Message + "\n" + "导入的借款单明细借款单号为\"" + m.单据号 + "\"的明细,没有相应的借款单对应.请检查借款Excel中是否有此借款单的数据"; throw new InvalidOperationException(message); } master.OWNERCOMPANYID = userview.OWNERCOMPANYID; master.OWNERCOMPANYNAME = userview.OWNERCOMPANYID; master.OWNERDEPARTMENTID = userview.OWNERDEPARTMENTID; master.OWNERID = userview.EMPLOYEEID; master.OWNERPOSTID = userview.OWNERPOSTID; master.CREATECOMPANYID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].CompanyID; master.CREATECOMPANYNAME = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].CompanyName; master.CREATEDEPARTMENTID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].DepartmentID; master.CREATEDEPARTMENTNAME = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].DepartmentName; master.CREATEPOSTID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].PostID; master.CREATEPOSTNAME = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].PostName; master.CREATEUSERID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID; master.CREATEUSERNAME = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeName; master.CREATEDATE = createTime; master.UPDATEUSERID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID; master.UPDATEUSERNAME = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeName; master.UPDATEDATE = createTime; }); //填充完申请人信息之后开始填充科目信息 service.QueryFBEntities(exp); } catch (Exception ex) { SMT.SaaS.FrameworkUI.ChildWidow.ComfirmWindow.ConfirmationBoxs("导入出错", ex.Message, "确定", MessageIcon.Exclamation); } } }); #endregion #region 填充完申请人信息之后开始填充科目信息 service.QueryFBEntitiesCompleted += new EventHandler<QueryFBEntitiesCompletedEventArgs>((o, args) => { if (args.Error == null) { //构造明细科目及账务信息 string message = null; try { import.ForEach(m => { OrderEntity oe = orders.FirstOrDefault(oen => { T_FB_BORROWAPPLYMASTER bm = oen.FBEntity.Entity as T_FB_BORROWAPPLYMASTER; if (bm.BORROWAPPLYMASTERCODE == m.BORROWAPPLYMASTERCODE) { return true; } else { return false; } }); var dlist = oe.GetRelationFBEntities("T_FB_BORROWAPPLYDETAIL"); List<T_FB_BORROWAPPLYDETAIL> detailslist = new List<T_FB_BORROWAPPLYDETAIL>(); dlist.ForEach(ddd => { detailslist.Add(ddd.Entity as T_FB_BORROWAPPLYDETAIL); }); detailslist.ForEach(d => { FBEntity en = null; try { en = args.Result.First(a => ((T_FB_BORROWAPPLYDETAIL)a.Entity).T_FB_SUBJECT.SUBJECTCODE == d.T_FB_SUBJECT.SUBJECTID); } catch (InvalidOperationException ex) { message = ex.Message + "\n" + "导入的借款单明细中,在系统中找不到ID为\"" + d.T_FB_SUBJECT.SUBJECTID + "\"的科目,也可能是您没有相应的权限"; throw new InvalidOperationException(message); } T_FB_BORROWAPPLYDETAIL t = en.Entity as T_FB_BORROWAPPLYDETAIL; if (t != null) { t.T_FB_SUBJECT.T_FB_BORROWAPPLYDETAIL.Clear(); d.T_FB_SUBJECT = t.T_FB_SUBJECT; d.CHARGETYPE = t.CHARGETYPE; d.USABLEMONEY = t.USABLEMONEY; #region 清理科目信息中的无用数据 t.T_FB_SUBJECT.T_FB_BORROWAPPLYDETAIL.Clear(); t.T_FB_SUBJECT.T_FB_BUDGETACCOUNT.Clear(); t.T_FB_SUBJECT.T_FB_BUDGETCHECK.Clear(); t.T_FB_SUBJECT.T_FB_CHARGEAPPLYDETAIL.Clear(); t.T_FB_SUBJECT.T_FB_COMPANYBUDGETAPPLYDETAIL.Clear(); t.T_FB_SUBJECT.T_FB_COMPANYBUDGETMODDETAIL.Clear(); t.T_FB_SUBJECT.T_FB_COMPANYBUDGETMODDETAIL.Clear(); t.T_FB_SUBJECT.T_FB_COMPANYTRANSFERDETAIL.Clear(); t.T_FB_SUBJECT.T_FB_DEPTBUDGETADDDETAIL.Clear(); t.T_FB_SUBJECT.T_FB_DEPTBUDGETAPPLYDETAIL.Clear(); t.T_FB_SUBJECT.T_FB_DEPTTRANSFERDETAIL.Clear(); t.T_FB_SUBJECT.T_FB_EXTENSIONORDERDETAIL.Clear(); t.T_FB_SUBJECT.T_FB_PERSONBUDGETADDDETAIL.Clear(); t.T_FB_SUBJECT.T_FB_PERSONBUDGETAPPLYDETAIL.Clear(); t.T_FB_SUBJECT.T_FB_PERSONMONEYASSIGNDETAIL.Clear(); t.T_FB_SUBJECT.T_FB_REPAYAPPLYDETAIL.Clear(); t.T_FB_SUBJECT.T_FB_SUBJECTCOMPANY.Clear(); t.T_FB_SUBJECT.T_FB_SUBJECTDEPTMENT.Clear(); t.T_FB_SUBJECT.T_FB_SUBJECTPOST.Clear(); t.T_FB_SUBJECT.T_FB_TRAVELEXPAPPLYDETAIL.Clear(); #endregion } }); }); //保存 service.SaveList(orders); } catch (Exception ex) { SMT.SaaS.FrameworkUI.ChildWidow.ComfirmWindow.ConfirmationBoxs("导入出错", ex.Message, "确定", MessageIcon.Exclamation); } } }); #endregion #region 所有信息构造完成之后保存数据 service.SaveListCompleted += new EventHandler<ActionCompletedEventArgs<bool>>((s, evgs) => { if (evgs.Result) { SMT.SaaS.FrameworkUI.ChildWidow.ComfirmWindow.ConfirmationBox("导入成功", "导入成功", "确定"); } else { SMT.SaaS.FrameworkUI.ChildWidow.ComfirmWindow.ConfirmationBox("导入失败", "导入失败", "确定"); } }); #endregion } catch (Exception ex) { SMT.SaaS.FrameworkUI.ChildWidow.ComfirmWindow.ConfirmationBoxs("导入出错", ex.Message, "确定", MessageIcon.Exclamation); } }
public OrderEntity IsPersonChanged(OrderEntity oe, T_FB_SUBJECTDEPTMENT subjectDepartment) { if (subjectDepartment.ISPERSON == 1) { oe.FBEntity.CollectionEntity.ForEach(p => { p.FBEntities.ForEach(f => { T_FB_SUBJECTPOST post = f.Entity as T_FB_SUBJECTPOST; if (post != null && subjectDepartment.T_FB_SUBJECT.SUBJECTID == post.T_FB_SUBJECT.SUBJECTID) post.ISPERSON = 1; }); }); } else { oe.FBEntity.CollectionEntity.ForEach(p => { p.FBEntities.ForEach(f => { T_FB_SUBJECTPOST post = f.Entity as T_FB_SUBJECTPOST; if (post != null && subjectDepartment.T_FB_SUBJECT.SUBJECTID == post.T_FB_SUBJECT.SUBJECTID) post.ISPERSON = 0; }); }); } return oe; }
void btnNew_Click(object sender, RoutedEventArgs e) { OrderEntity orderEntity = new OrderEntity(this.DefaultEntity.OrderType); ShowEditForm(orderEntity, OperationTypes.Add); }
private void CreateNonActionSubjectPost(T_FB_SUBJECTDEPTMENT sd, T_FB_SUBJECTPOST post, VirtualPost virtualPost) { ObservableCollection<FBEntity> listFBEntities = new ObservableCollection<FBEntity>(); post.ACTIVED = 0; post.UPDATEDATE = DateTime.Now; FBEntity fbEntityPostNew = post.ToFBEntity(); fbEntityPostNew.FBEntityState = FBEntityState.Modified; listFBEntities.Add(fbEntityPostNew); FBEntity postFBEntity = virtualPost.ToFBEntity(); postFBEntity.AddFBEntities<T_FB_SUBJECTPOST>(listFBEntities); OrderEntity entityPost = new OrderEntity(postFBEntity); EntityList.Add(entityPost); }
public DeptBudgetSumForm(OrderEntity orderEntity) : base(orderEntity) { this.EditForm.Saving += new EventHandler<SavingEventArgs>(EditForm_Saving); }
void fbService_GetFBEntityCompleted(object sender, GetFBEntityCompletedEventArgs e) { FBBaseControl fb = new FBBaseControl(); if (e.Error != null) { CommonFunction.ShowErrorMessage("操作失败, " + e.Error.Message); } if (e.Result == null) { CommonFunction.ShowErrorMessage("无可用数据"); fb.CloseProcess(); } if (GetEntityCompleted != null) { OrderEntity entityAdapter = new OrderEntity(e.Result); ActionCompletedEventArgs<OrderEntity> se = new ActionCompletedEventArgs<OrderEntity>(entityAdapter); GetEntityCompleted(this, se); } }
public static Order ToObject(this OrderEntity entity) { // TODO: use ValueInjecter to do the custom conversion and possible flattening here. return(new Order(entity)); }
internal static BzjOrderEntity ToBzjOrderEntity(OrderEntity entity) { //string orderType = ""; //switch (entity.OrderType) //{ // case 1: // orderType = "提货单"; // break; // case 2: // orderType = "买跌单"; // break; // case 3: // orderType = "买跌单"; // break; // case4: // orderType = "金生金"; // break; //} //string state = ""; //switch (entity.State) //{ // case 1: // state = "新定单"; // break; // case 2: // state = "已完成"; // break; // case 3: // state = "已取消"; // break; // case4: // state = "已过期"; // break; //} return(new BzjOrderEntity() { OrderNO = entity.OrderNo, //单号 Name = entity.Name, // 姓名 OrderCode = entity.OrderCode, // 提货码 Au = entity.Au, // au数量 Ag = entity.Ag, // Ag数量 Pt = entity.Pt, Pd = entity.Pd, AuT = entity.AuT, // au可开发票总额 AgT = entity.AgT, // ag可开发票总额 PtT = entity.PtT, PdT = entity.PdT, //CardType = entity.CardType == 1 ? "身份证" : "营业执照", // 卡类别 1,身份证,2.营业执照 CardType = entity.CardType == 1 ? "身份证" : (entity.CardType == 2 ? "机构代码" : "其它"), // 身份证号 = 1, 机构代码 = 2, 营业执照 = 3 CardNum = entity.CardNum, // 身份证号 PhoneNum = entity.PhoneNum, // 电话 State = entity.State, // 状态 新定单 = 1,已完成 = 2,已取消 = 3,已过期 = 4 OrderType = entity.OrderType, // 定单类别 提货单 = 1,买跌单 = 2, 买跌单 = 3,金生金 = 4 //todo:调整版本 //IDType = entity.IDType,//定单卡类别 IDNo = entity.IDNo, //定单号 Phone = entity.Phone, //定单电话 UserId = entity.UserId, Account = entity.Account, AgP = entity.AgP, //平均价 AuP = entity.AuP, PdP = entity.PdP, PtP = entity.PtP, }); }
protected void GetEditForm(OrderEntity orderEntity) { editForm.OrderEntity = orderEntity; if (orderEntity != null) { Title = orderEntity.OrderTypeName; } editForm.InitForm(); }
internal bool Change(OrderEntity obje) { db.Entry(obje).State = EntityState.Modified; db.SaveChanges(); return(true); }
private void TreeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e) { if (sender != null) { var treeView = sender as TreeView; currTreeItmes = treeView.SelectedItem as TreeViewItem; } TreeViewItem treeViewItem = e.NewValue as TreeViewItem; if (treeViewItem != null) { QuerySubjectCompanyData(treeViewItem); this.currentTreeViewItem = treeViewItem; VirtualPost virtualPost = currentTreeViewItem.DataContext as VirtualPost; if (virtualPost != null) { this.CurrentOrderEntity = CreatePostEntity(virtualPost, treeViewItem, string.Empty); } else { OrderEntity entity = currentTreeViewItem.DataContext as OrderEntity; this.CurrentOrderEntity = entity; } } }
internal OrderEntity Remove(OrderEntity obje) { Order = db.OrderEntities.Remove(obje); db.SaveChanges(); return(Order); }
/// <summary> /// 创建或获取相应岗位科目 /// </summary> /// <param name="virtualPost"></param> /// <returns></returns> private OrderEntity CreatePostEntity(VirtualPost virtualPost, TreeViewItem treeViewItem, string strFlag) { ObservableCollection<FBEntity> listFBEntities = new ObservableCollection<FBEntity>(); OrderEntity oeDepartment = dictDepartment[virtualPost.VirtualDepartment]; // 已存在的岗位科目 ObservableCollection<FBEntity> listOfSubjectDepartmentFB = oeDepartment.GetRelationFBEntities(typeof(T_FB_SUBJECTDEPTMENT).Name); // 1. 获取所有已启用的部门科目 var itemsDepartmentActived = listOfSubjectDepartmentFB.Where(item => { return (item.Entity as T_FB_SUBJECTDEPTMENT).ACTIVED == 1; }); // 2. 遍历所有已启用的部门科目, 添加相应的岗位科目,已有科目的,则加上原有的,没有的,则新增 foreach (FBEntity entityDepartment in itemsDepartmentActived) { T_FB_SUBJECTDEPTMENT sd = entityDepartment.Entity as T_FB_SUBJECTDEPTMENT; // 是否已有岗位科目的记录 List<FBEntity> listPost = entityDepartment.GetRelationFBEntities(typeof(T_FB_SUBJECTPOST).Name, item => { return (item.Entity as T_FB_SUBJECTPOST).OWNERPOSTID == virtualPost.ID; }); // 已有岗位科目,添加。没有,就新增 if (listPost.Count > 0) { T_FB_SUBJECTPOST post = listPost[0].Entity as T_FB_SUBJECTPOST; if (post.ACTIVED != sd.ACTIVED) { listPost[0].FBEntityState = FBEntityState.Modified; } //岗位默认处理 if (post != null) post = SubjectPostChanged(sd, post, strFlag); listPost[0].Entity = post; listFBEntities.Add(listPost[0]); } else { //临时添加防止重复数据 var a = staticobpost.FirstOrDefault(item => (item.Entity as T_FB_SUBJECTPOST).OWNERPOSTID == virtualPost.ID && (item.Entity as T_FB_SUBJECTPOST).T_FB_SUBJECT != null && (item.Entity as T_FB_SUBJECTPOST).T_FB_SUBJECT.SUBJECTID == sd.T_FB_SUBJECT.SUBJECTID); if (a == null && sd.ACTIVED == 1) { FBEntity fbEntityPostNew = this.CreateSubjectPost(sd, virtualPost, strFlag); listFBEntities.Add(fbEntityPostNew); staticobpost.Add(fbEntityPostNew); } else { listFBEntities.Add(a); } } } FBEntity postFBEntity = virtualPost.ToFBEntity(); postFBEntity.AddFBEntities<T_FB_SUBJECTPOST>(listFBEntities); OrderEntity entityPost = new OrderEntity(postFBEntity); Binding binding = new Binding(); binding.Path = new PropertyPath("Entity.Name"); treeViewItem.SetBinding(TreeViewItem.HeaderProperty, binding); treeViewItem.DataContext = entityPost; EntityList.Add(entityPost); return entityPost; }
public HttpResponseMessage PassAudit([FromBody] BrokerRECClientModel brokerRecClientModel) { if (brokerRecClientModel.Id == 0) { return(PageHelper.toJson(PageHelper.ReturnValue(false, "Id不能为空"))); } var model = _brokerRecClientService.GetBrokerRECClientById(brokerRecClientModel.Id); model.Status = brokerRecClientModel.Status; //if (brokerRecClientModel.Status == EnumBRECCType.等待上访) //{ // //查询商品详情 // var product = _productService.GetProductById(model.Projectid); // //创建订单详情 // OrderDetailEntity ode = new OrderDetailEntity(); // ode.Adddate = DateTime.Now; // ode.Adduser = model.Adduser.ToString(CultureInfo.InvariantCulture); // ode.Commission = product.Commission; // ode.RecCommission = product.RecCommission; // ode.Dealcommission = product.Dealcommission; // ode.Price = product.Price; // ode.Product = product; // ode.Productname = product.Productname; // //ode.Remark = product. // //ode.Snapshoturl = orderDetailModel.Snapshoturl, // ode.Upddate = DateTime.Now; // ode.Upduser = model.Adduser.ToString(CultureInfo.InvariantCulture); // //创建订单 // OrderEntity oe = new OrderEntity(); // oe.Adddate = DateTime.Now; // oe.Adduser = model.Adduser.ToString(CultureInfo.InvariantCulture); // oe.AgentId = model.Broker.Id;//model.Adduser;此处存的应该是经纪人ID // oe.Agentname = _brokerService.GetBrokerByUserId(model.Adduser).Brokername; // oe.Agenttel = model.Phone; // oe.BusId = product.Bussnessid; // oe.Busname = product.BussnessName; // oe.Customname = model.Clientname; // oe.Ordercode = _orderService.CreateOrderNumber(1); // oe.OrderDetail = ode;//订单详情; // oe.Ordertype = EnumOrderType.推荐订单; // oe.Remark = "前端经纪人提交"; // oe.Shipstatus = (int)EnumBRECCType.审核中; // oe.Status = (int)EnumOrderStatus.默认; // oe.Upddate = DateTime.Now; // oe.Upduser = model.Adduser.ToString(CultureInfo.InvariantCulture); // _orderService.Create(oe); // model.RecOrder = oe.Id; // _brokerRecClientService.Update(model); //} //else if (brokerRecClientModel.Status == EnumBRECCType.审核不通过) { return PageHelper.toJson(PageHelper.ReturnValue(false, "审核不通过")); } //else if (brokerRecClientModel.Status == EnumBRECCType.审核中) //{} //else if (brokerRecClientModel.Status == EnumBRECCType.洽谈中) //{ // var recOrder = _orderService.GetOrderById(model.RecOrder); // int a = (int)Enum.Parse(typeof(EnumBRECCType), brokerRecClientModel.Status.ToString()); // recOrder.Shipstatus = a; // recOrder.Status = (int)EnumOrderStatus.审核通过; // recOrder.Upduser = _workContext.CurrentUser.Id.ToString(CultureInfo.InvariantCulture); // recOrder.Upddate = DateTime.Now; // _orderService.Update(recOrder); //} //else if (brokerRecClientModel.Status == EnumBRECCType.洽谈成功) //{ // var recOrder = _orderService.GetOrderById(model.RecOrder); // int a = (int)Enum.Parse(typeof(EnumBRECCType), brokerRecClientModel.Status.ToString()); // recOrder.Shipstatus = a; // recOrder.Status = (int)EnumOrderStatus.审核通过; // recOrder.Upduser = _workContext.CurrentUser.Id.ToString(CultureInfo.InvariantCulture); // recOrder.Upddate = DateTime.Now; // _orderService.Update(recOrder); //} //else if (brokerRecClientModel.Status == EnumBRECCType.洽谈失败) //{ // var recOrder = _orderService.GetOrderById(model.RecOrder); // int a = (int)Enum.Parse(typeof(EnumBRECCType), brokerRecClientModel.Status.ToString()); // recOrder.Shipstatus = a; // model.DelFlag = EnumDelFlag.删除; // recOrder.Upduser = _workContext.CurrentUser.Id.ToString(CultureInfo.InvariantCulture); // recOrder.Upddate = DateTime.Now; // _orderService.Update(recOrder); //} //else if (brokerRecClientModel.Status == EnumBRECCType.客人未到) //{ // var recOrder = _orderService.GetOrderById(model.RecOrder); // int a = (int)Enum.Parse(typeof(EnumBRECCType), brokerRecClientModel.Status.ToString()); // recOrder.Shipstatus = a; // recOrder.Status = (int)EnumOrderStatus.审核失败; // recOrder.Upduser = _workContext.CurrentUser.Id.ToString(CultureInfo.InvariantCulture); // recOrder.Upddate = DateTime.Now; // _orderService.Update(recOrder); //} switch (brokerRecClientModel.Status) { case EnumBRECCType.审核中: break; case EnumBRECCType.审核不通过: _brokerRecClientService.Delete(model); return(PageHelper.toJson(PageHelper.ReturnValue(false, "操作成功"))); case EnumBRECCType.等待上访: //查询商品详情 var product = _productService.GetProductById(model.Projectid); //创建订单详情 OrderDetailEntity ode = new OrderDetailEntity(); ode.Adddate = DateTime.Now; ode.Adduser = model.Adduser.ToString(CultureInfo.InvariantCulture); ode.Commission = product.Commission; ode.RecCommission = product.RecCommission; ode.Dealcommission = product.Dealcommission; ode.Price = product.Price; ode.Product = product; ode.Productname = product.Productname; //ode.Remark = product. //ode.Snapshoturl = orderDetailModel.Snapshoturl, ode.Upddate = DateTime.Now; ode.Upduser = model.Adduser.ToString(CultureInfo.InvariantCulture); //创建订单 OrderEntity oe = new OrderEntity(); oe.Adddate = DateTime.Now; oe.Adduser = model.Adduser.ToString(CultureInfo.InvariantCulture); oe.AgentId = model.Broker.Id;//model.Adduser;此处存的应该是经纪人ID oe.Agentname = _brokerService.GetBrokerByUserId(model.Adduser).Brokername; oe.Agenttel = model.Phone; oe.BusId = product.Bussnessid; oe.Busname = product.BussnessName; oe.Customname = model.Clientname; oe.Ordercode = _orderService.CreateOrderNumber(1); oe.OrderDetail = ode; //订单详情; oe.Ordertype = EnumOrderType.推荐订单; oe.Remark = "前端经纪人提交"; oe.Shipstatus = (int)EnumBRECCType.审核中; oe.Status = (int)EnumOrderStatus.默认; oe.Upddate = DateTime.Now; oe.Upduser = model.Adduser.ToString(CultureInfo.InvariantCulture); _orderService.Create(oe); model.RecOrder = oe.Id; _brokerRecClientService.Update(model); break; case EnumBRECCType.洽谈中: var recOrder = _orderService.GetOrderById(model.RecOrder); int a = (int)Enum.Parse(typeof(EnumBRECCType), brokerRecClientModel.Status.ToString()); recOrder.Shipstatus = a; recOrder.Status = (int)EnumOrderStatus.审核通过; recOrder.Upduser = _workContext.CurrentUser.Id.ToString(CultureInfo.InvariantCulture); recOrder.Upddate = DateTime.Now; _orderService.Update(recOrder); break; case EnumBRECCType.洽谈成功: recOrder = _orderService.GetOrderById(model.RecOrder); a = (int)Enum.Parse(typeof(EnumBRECCType), brokerRecClientModel.Status.ToString()); recOrder.Shipstatus = a; recOrder.Status = (int)EnumOrderStatus.审核通过; recOrder.Upduser = _workContext.CurrentUser.Id.ToString(CultureInfo.InvariantCulture); recOrder.Upddate = DateTime.Now; _orderService.Update(recOrder); break; case EnumBRECCType.洽谈失败: recOrder = _orderService.GetOrderById(model.RecOrder); a = (int)Enum.Parse(typeof(EnumBRECCType), brokerRecClientModel.Status.ToString()); recOrder.Shipstatus = a; model.DelFlag = EnumDelFlag.除; recOrder.Upduser = _workContext.CurrentUser.Id.ToString(CultureInfo.InvariantCulture); recOrder.Upddate = DateTime.Now; _orderService.Update(recOrder); break; case EnumBRECCType.客人未到: recOrder = _orderService.GetOrderById(model.RecOrder); a = (int)Enum.Parse(typeof(EnumBRECCType), brokerRecClientModel.Status.ToString()); recOrder.Shipstatus = a; recOrder.Status = (int)EnumOrderStatus.审核失败; recOrder.Upduser = _workContext.CurrentUser.Id.ToString(CultureInfo.InvariantCulture); recOrder.Upddate = DateTime.Now; _orderService.Update(recOrder); break; } model.Uptime = DateTime.Now; model.Upuser = _workContext.CurrentUser.Id; _brokerRecClientService.Update(model); return(PageHelper.toJson(PageHelper.ReturnValue(true, "确认成功"))); }
public void Save() { ObservableCollection<FBEntity> listOfFBEntity = new ObservableCollection<FBEntity>(); for (int i = 0; i < EntityList.Count; i++) { OrderEntity item = EntityList[i]; FBEntity fbEntitySave = item.GetModifiedFBEntity(); ObservableCollection<FBEntity> listSave = null; if (fbEntitySave.Entity.GetType() == typeof(VirtualDepartment)) { listSave = fbEntitySave.GetRelationFBEntities(typeof(T_FB_SUBJECTDEPTMENT).Name); //活动经费 CheckMoneyAssign(listSave); } else { listSave = fbEntitySave.GetRelationFBEntities(typeof(T_FB_SUBJECTPOST).Name); // 删除 不是active的岗位项目记录 //listSave.RemoveAll(itemRemove => //{ // bool isAdded = itemRemove.FBEntityState == FBEntityState.Added; // // bool isNew = (itemRemove.Entity as T_FB_SUBJECTPOST).ACTIVED != 1; // //return isAdded && isNew; // return isAdded; //}); } listSave.ToList().ForEach(fbEntity => { bool tf = true;//外键为空的不处理 #region 公共参数赋值 if (fbEntity.IsNewEntity()) { fbEntity.FBEntityState = FBEntityState.Added; fbEntity.SetObjValue("Entity.CREATECOMPANYID", item.LoginUser.Company.Value); fbEntity.SetObjValue("Entity.CREATECOMPANYNAME", item.LoginUser.Company.Text); fbEntity.SetObjValue("Entity.CREATEDEPARTMENTID", item.LoginUser.Department.Value); fbEntity.SetObjValue("Entity.CREATEDEPARTMENTNAME", item.LoginUser.Department.Text); fbEntity.SetObjValue("Entity.CREATEPOSTID", item.LoginUser.Post.Value); fbEntity.SetObjValue("Entity.CREATEPOSTNAME", item.LoginUser.Post.Text); fbEntity.SetObjValue("Entity.CREATEUSERID", item.LoginUser.Value); fbEntity.SetObjValue("Entity.CREATEUSERNAME", item.LoginUser.Text); fbEntity.SetObjValue("Entity.EDITSTATES", decimal.Parse("1")); } fbEntity.SetObjValue("Entity.UPDATEUSERID", item.LoginUser.Value); fbEntity.SetObjValue("Entity.UPDATEUSERNAME", item.LoginUser.Text); #endregion T_FB_SUBJECTPOST sp = fbEntity.Entity as T_FB_SUBJECTPOST; // 去除实体之间的关联,如有关联存在,上传服务端时,会有异常 if (sp == null) { T_FB_SUBJECTDEPTMENT sd = fbEntity.Entity as T_FB_SUBJECTDEPTMENT; if (sd.T_FB_SUBJECTCOMPANY != null && sd.T_FB_SUBJECT != null) { sd.T_FB_SUBJECTCOMPANYReference.EntityKey = sd.T_FB_SUBJECTCOMPANY.EntityKey; sd.T_FB_SUBJECTCOMPANY = null; sd.T_FB_SUBJECTReference.EntityKey = sd.T_FB_SUBJECT.EntityKey; sd.T_FB_SUBJECT = null; sd.T_FB_SUBJECTPOST = null; fbEntity.CollectionEntity.Clear(); } else { tf = false; } } else { if (sp.T_FB_SUBJECTDEPTMENT != null && sp.T_FB_SUBJECT != null) { EntityKey parentKey = sp.T_FB_SUBJECTDEPTMENT.EntityKey; if (parentKey.EntityKeyValues == null) { EntityKeyMember em = new EntityKeyMember(); em.Key = "SUBJECTDEPTMENTID"; em.Value = sp.T_FB_SUBJECTDEPTMENT.SUBJECTDEPTMENTID; EntityKey newKey = new EntityKey(); newKey.EntityContainerName = parentKey.EntityContainerName; newKey.EntitySetName = parentKey.EntitySetName; newKey.EntityKeyValues = new ObservableCollection<EntityKeyMember>(); newKey.EntityKeyValues.Add(em); parentKey = newKey; } sp.T_FB_SUBJECTDEPTMENTReference = new EntityReferenceOfT_FB_SUBJECTDEPTMENTZ5CrhPbu(); sp.T_FB_SUBJECTDEPTMENTReference.EntityKey = parentKey; sp.T_FB_SUBJECTDEPTMENT = null; sp.T_FB_SUBJECTReference = new EntityReferenceOfT_FB_SUBJECTZ5CrhPbu(); sp.T_FB_SUBJECTReference.EntityKey = sp.T_FB_SUBJECT.EntityKey; sp.T_FB_SUBJECT = null; // 清除已删除实体,这些实体会在 T_FB_SUBJECTDEPTMENT 实体中处理 . fbEntity.GetRelationFBEntities(Args.DELETE_ENTITYTYPE).Clear(); } else { tf = false; } } if (tf) listOfFBEntity.Add(fbEntity); }); } if (listOfFBEntity.Count > 0) { this.CurrentOrderEntity = new OrderEntity(typeof(VirtualCompany)); this.orderEntityService.SaveList(listOfFBEntity); } else { CloseProcess(); } }
protected List <OrderEntity> ResolveOrders(DataTable excelTable, DataFileInfo file, List <OrderEntity> items) { OrderDTO orderDTO = new OrderDTO(); orderDTO.orderStatus = OrderStatus.Confirmed; orderDTO.fileName = file.FullName; orderDTO.orderType = 0; orderDTO.orderStatus = OrderStatus.Confirmed; for (int i = 0; i < excelTable.Rows.Count; i++) { var row = excelTable.Rows[i]; orderDTO.createdDate = file.FileDate; orderDTO.source = this.Name; orderDTO.sourceDesc = Util.Helpers.Reflection.GetDescription <OrderSource>(this.Name); orderDTO.sourceSN = Convert.ToString(row["交易号"]); //订单号 if (string.IsNullOrEmpty(orderDTO.sourceSN)) { InputExceptionOrder(orderDTO, ExceptionType.SourceSnIsNull); continue; } orderDTO.productName = Convert.ToString(row[2]); //商品名称 // orderDTO.productsku = Convert.ToString(row[2]); //商品编号 try { orderDTO.count = Convert.ToInt32(row["数量"]); //数量 } catch (Exception) { orderDTO.count = Convert.ToInt32(row["通知数量"]); //数量 } orderDTO.orderSN = string.Format("{0}-{1}_{2}", orderDTO.source, orderDTO.sourceSN, orderDTO.createdDate.ToString("yyyyMMdd")); if (CheckOrderInDataBase(orderDTO))//是否是重复订单 { continue; } var item = items.Find(o => o.OrderSn == orderDTO.orderSN); if (item == null) { orderDTO.consigneeName = Convert.ToString(row["收货人"]); //收件人 orderDTO.consigneePhone = Convert.ToString(row["手机"]); //联系电话 orderDTO.consigneePhone2 = string.Empty; orderDTO.consigneeProvince = string.Empty; orderDTO.consigneeCity = string.Empty; orderDTO.consigneeCounty = string.Empty; orderDTO.consigneeAddress = Convert.ToString(row["地址"]); //收货地区+详细地址 // orderDTO.consigneeZipCode = Convert.ToString(row[9]); //邮编 // if (string.IsNullOrEmpty(orderDTO.consigneeProvince) && string.IsNullOrEmpty(orderDTO.consigneeCity) && !string.IsNullOrEmpty(orderDTO.consigneeAddress)) { var addrInfo = DistrictService.DistrictService.ResolveAddress(orderDTO.consigneeAddress); orderDTO.consigneeProvince = addrInfo.Province; orderDTO.consigneeCity = addrInfo.City; orderDTO.consigneeCounty = addrInfo.County; // consigneeAddress = addrInfo.Address; } OrderEntity orderItem = OrderEntityService.CreateOrderEntity(orderDTO); using (var db = new OMSContext()) { //查找联系人 if (!string.IsNullOrEmpty(orderItem.Consignee.Phone)) { OrderEntityService.InputConsigneeInfo(orderItem, db); } else //异常订单 { InputExceptionOrder(orderDTO, ExceptionType.PhoneNumOrPersonNameIsNull); continue; } if (!InputProductInfoWithoutSaveChange(db, orderDTO, orderItem)) { continue; } items.Add(orderItem); if (orderItem.OrderRepurchase == null) { orderItem.OrderRepurchase = new OrderRepurchase(); } db.OrderRepurchases.Add(orderItem.OrderRepurchase); db.OrderDateInfos.Add(orderItem.OrderDateInfo); db.SaveChanges(); } } else { orderDTO.consigneeName = Convert.ToString(row["收货人"]); //收件人 orderDTO.consigneePhone = Convert.ToString(row["手机"]); //联系电话 try { orderDTO.count = Convert.ToInt32(row["数量"]); //数量 } catch (Exception) { orderDTO.count = Convert.ToInt32(row["通知数量"]); //数量 } using (var db = new OMSContext()) { InputProductInfoWithoutSaveChange(db, orderDTO, item); } } } return(items); }
/// <summary> /// 预算汇总设置 构造函数 /// </summary> /// <param name="orderEntity"></param> public SumSettingsForm(OrderEntity orderEntity) : base(orderEntity) { fbService = new FBEntityService(); this.EditForm.Saving += new EventHandler<SavingEventArgs>(EditForm_Saving); }
public void Save(OrderEntity order) { _db.Orders.Add(order); _db.SaveChanges(); }
public void Delete(OrderEntity orderEntity) { orderEntity.FBEntityState = FBEntityState.Deleted; this.Save(orderEntity); }
Order MapEntity(CourierEntity courier, OrderEntity order) =>
void fbService_SaveCompleted(object sender, SaveCompletedEventArgs e) { FBEntity fbEntity = null; if (e.Error != null) { CommonFunction.ShowErrorMessage("操作失败, " + e.Error.Message); } else if (e.Result.Exception != null) { CommonFunction.ShowErrorMessage(e.Result.Exception); } fbEntity = e.Result.FBEntity; if (SaveCompleted != null) { OrderEntity entityAdapter = null; if (fbEntity != null) { entityAdapter = new OrderEntity(e.Result.FBEntity); } ActionCompletedEventArgs<OrderEntity> se = new ActionCompletedEventArgs<OrderEntity>(entityAdapter); SaveCompleted(this, se); } }
public async Task <SuccessResponseModel> ConfirmAsync(string userId, OrderModel model) { if (model.Dishes == null || model.Dishes.Count == 0) { throw new ApiException("Блюда не найдено", 400); } OrderEntity order = new OrderEntity { Id = await GetRandomId(), PaymentTypeId = model.PaymentTypeId, DeliveryTypeId = model.DeliveryTypeId, DeliveryMinutes = model.DeliveryMinutes, DeliverySum = model.DeliverySum, Tip = model.Tip, UserId = userId, AddressId = model.AddressId, RestaurantId = (await _context.Dishes.FirstOrDefaultAsync(x => x.Id == model.Dishes[0].Id)).RestaurantId }; await _context.Orders.AddAsync(order); decimal totalSum = 0; foreach (var dish in model.Dishes) { var entity = await _context.Dishes.FirstOrDefaultAsync(d => d.Id == dish.Id); if (entity == null) { throw new ApiException("Блюдо не найдено", 400); } if (entity.IsBlock) { throw new ApiException("Блюдо заблокировано. Удалите блюдо из корзины", 400); } if (entity.Price != dish.Sum / dish.Count) { throw new ApiException("Цена блюда изменилась", 400); } if (entity.RestaurantId != order.RestaurantId) { throw new ApiException("Невозможно cделать заказ cблюдами из разных ресторанов", 400); } OrderDishEntity od = new OrderDishEntity { DishId = dish.Id, Count = dish.Count, Sum = dish.Sum, Order = order }; totalSum += dish.Sum; //if (dish.Description != null) // od.Description.Add(dish.Description); await _context.OrderDishes.AddAsync(od); } order.Sum = totalSum; await _statisticsService.UpdateOrdersCountAsync(totalSum); await _context.SaveChangesAsync(); return(new SuccessResponseModel { Id = order.Id }); }