/// <summary> /// 展示订单中详细产品 /// </summary> private void GetOrderDetail() { //通过调试得知:第一次进入时GetOrderDetail执行一次,且第一个就是listViewOrders.SelectedItems.Count>0 //之后在触发事件,调用这个方法时,要执行两遍GetOrderDetail,第一遍listViewOrders.SelectedItems.Count>)不成立,第二遍成立 if (listViewOrders.SelectedItems.Count > 0) { toolStripButton4.Enabled = true; toolStripButton5.Enabled = true; toolStripButton6.Enabled = true; toolStripButton8.Enabled = true; ListViewItem item = listViewOrders.SelectedItems[0]; selectOrder = (Model.SalesOrdersModel)item.Tag; labelOrderNumber.Text = "[" + selectOrder.OrderNumber + "]"; labelOrderDate.Text = "[" + selectOrder.OrderDate.ToString("yyyy-MM-dd HH:mm:ss") + "]"; labelStatus.Text = "[" + selectOrder.Status + "]"; labelContract.Text = "[" + selectOrder.Contract + "]"; labelTel.Text = "[" + selectOrder.Tel + "]"; labelCustomerName.Text = "[" + selectOrder.CustomerName + "]"; labelAddress.Text = "[" + selectOrder.Address + "]"; BLLSalesOrders.SalesManagerServiceClient client = WCFServiceBLL.GetSalesService(); List <Model.SalesCommodityModel> salesCommoditiesList = client.GetSalesCommoditiesByID(selectOrder.ID).ToList(); dataGridViewCommoditiesList.DataSource = salesCommoditiesList; } else { clearShowOrderItmList(); } }
public bool PostSalesOrder(int id) { Model.SalesOrdersModel oneOrder = GetOneSalesOrder(id); if (oneOrder.Status.Equals("已出库")) { Exception oe = new Exception(); throw new FaultException <Exception>(oe, "订单已出库"); } List <Model.SalesCommodityModel> salesCommoditiesList = GetSalesCommoditiesByID(id).ToList(); List <Model.SalesCommodityModel> errorList = salesCommoditiesList.Where(u => u.CommodityInventory < u.Count).ToList(); //简单处理回滚,因为一条不成功,所有记录操作所有被回滚 //这儿确保安全无误后对库存进行更新 if (errorList.Count > 0) { Exception oe = new Exception(); string message = "提交失败!\r\n"; foreach (Model.SalesCommodityModel oneErrorSalesCommodity in errorList) { message += string.Format("{0}的当前库存({1})小于订单的数量({2})!\r\n", oneErrorSalesCommodity.CommodityName, oneErrorSalesCommodity.CommodityInventory, oneErrorSalesCommodity.Count); } throw new FaultException <Exception>(oe, message); } IDAL.ICommodityService commodityService = new MSSQLDAL.CommodityService(); foreach (Model.SalesCommodityModel oneSalesCommodity in salesCommoditiesList) { Model.CommodityModel oneCommodity = new Model.CommodityModel(); oneCommodity.ID = oneSalesCommodity.CommodityID; oneCommodity.Name = oneSalesCommodity.CommodityName; oneCommodity.Type = oneSalesCommodity.CommodityType; oneCommodity.Manufacturer = oneSalesCommodity.CommodityManufacturer; oneCommodity.Unit = oneSalesCommodity.CommodityUnit; oneCommodity.UnitPrice = oneSalesCommodity.CommodityUnitPrice; oneCommodity.Inventory = oneSalesCommodity.CommodityInventory - oneSalesCommodity.Count; commodityService.AddEntity(oneCommodity); } oneOrder.Status = "已出库"; IDAL.ISalesOrdersService salesOrderService = new MSSQLDAL.SalesOrderService(); //return salesOrderService.UpdateEntity(oneOrder); return(dataFactory.SalesOrderDal.UpdateEntity(oneOrder)); }
private void GetUpdateOrderDetail() { toolStripButton4.Enabled = true; toolStripButton5.Enabled = true; toolStripButton6.Enabled = true; toolStripButton8.Enabled = true; //ListViewItem item = listViewOrders.SelectedItems[0]; //selectOrder = (Model.SalesOrdersModel)item.Tag; BLLSalesOrders.SalesManagerServiceClient salesClient = WCFServiceBLL.GetSalesService(); selectOrder = salesClient.GetOneSalesOrder(salesID); labelOrderNumber.Text = "[" + selectOrder.OrderNumber + "]"; labelOrderDate.Text = "[" + selectOrder.OrderDate.ToString("yyyy-MM-dd HH:mm:ss") + "]"; labelContract.Text = "[" + selectOrder.Contract + "]"; labelTel.Text = "[" + selectOrder.Tel + "]"; labelCustomerName.Text = "[" + selectOrder.CustomerName + "]"; labelAddress.Text = "[" + selectOrder.Address + "]"; labelContract.Text = "[" + selectOrder.Contract + "]"; BLLSalesOrders.SalesManagerServiceClient client = WCFServiceBLL.GetSalesService(); List <SalesCommodityModel> salesCommoditiesList = client.GetSalesCommoditiesByID(selectOrder.ID).ToList(); dataGridViewCommoditiesList.DataSource = salesCommoditiesList; }
private void buttonOK_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(textBoxOrderNumber.Text)) { MessageBox.Show("订单编号不能为空"); return; } Model.SalesOrdersModel salesOrder = new Model.SalesOrdersModel(); salesOrder.OrderNumber = textBoxOrderNumber.Text; salesOrder.CustomerId = string.IsNullOrWhiteSpace(labelCustomerId.Text) ? 0 : int.Parse(labelCustomerId.Text); salesOrder.CustomerName = textBoxCustomer.Text; salesOrder.Address = textBoxAddress.Text; salesOrder.Tel = textBoxTel.Text; salesOrder.Contract = textBoxContract.Text; salesOrder.OrderDate = DateTime.Now; BLLSalesOrders.SalesManagerServiceClient salesClient = WCFServiceBLL.GetSalesService(); if (isUpdate) { salesOrder.ID = orderID; if (!salesClient.UpdateSalesOrder(salesOrder)) { MessageBox.Show("订单更新失败"); this.DialogResult = DialogResult.None; } } else { var order = salesClient.AddSalesOrder(salesOrder); if (order == null) { MessageBox.Show("新增订单失败"); this.DialogResult = DialogResult.None; } AddSalesID = order.ID; } }
public Model.SalesOrdersModel AddSalesOrder(Model.SalesOrdersModel oneSalesOrder) { //return new OracleDAL.SalesOrderService().AddEntity(oneSalesOrder); return(dataFactory.SalesOrderDal.AddEntity(oneSalesOrder)); }
public bool UpdateSalesOrder(Model.SalesOrdersModel oneSalesOrder) { //return new OracleDAL.SalesOrderService().UpdateEntity(oneSalesOrder); return(dataFactory.SalesOrderDal.UpdateEntity(oneSalesOrder)); }