public List <ZcProcessOrderItem> getItemByid(string orderId) { List <ZcProcessOrderItem> list = new List <ZcProcessOrderItem>(); OracleConnection conn = null; try { conn = OracleUtil.OpenConn(); string sql = "select * from zc_order_process_item where order_id='" + orderId + "'"; OracleCommand command = new OracleCommand(sql); command.Connection = conn; var reader = command.ExecuteReader(); while (reader.Read()) { ZcProcessOrderItem user = new ZcProcessOrderItem(); user.id = reader.IsDBNull(0) ? string.Empty : reader.GetString(0); user.createTime = reader.IsDBNull(1) ? default(DateTime) : reader.GetDateTime(1); user.updateTime = reader.IsDBNull(2) ? default(DateTime) : reader.GetDateTime(2); user.addon = reader.IsDBNull(3) ? default(double) : reader.GetDouble(3); user.amount = reader.IsDBNull(4) ? string.Empty : reader.GetString(4); user.bn = reader.IsDBNull(5) ? string.Empty : reader.GetString(5); user.cost = reader.IsDBNull(6) ? string.Empty : reader.GetString(6); user.g_price = reader.IsDBNull(7) ? string.Empty : reader.GetString(7); user.goodsState = reader.IsDBNull(8) ? string.Empty : reader.GetString(8); user.item_type = reader.IsDBNull(9) ? string.Empty : reader.GetString(9); user.name = reader.IsDBNull(10) ? string.Empty : reader.GetString(10); user.nums = reader.IsDBNull(11) ? string.Empty : reader.GetString(11); user.obj_id = reader.IsDBNull(12) ? string.Empty : reader.GetString(12); user.order_id = reader.IsDBNull(13) ? string.Empty : reader.GetString(13); user.price = reader.IsDBNull(14) ? string.Empty : reader.GetString(14); user.product_id = reader.IsDBNull(15) ? string.Empty : reader.GetString(15); user.score = reader.IsDBNull(16) ? string.Empty : reader.GetString(16); user.sendNum = reader.IsDBNull(17) ? string.Empty : reader.GetString(17); user.type_id = reader.IsDBNull(18) ? string.Empty : reader.GetString(18); user.weight = reader.IsDBNull(19) ? string.Empty : reader.GetString(19); user.goodsFile = reader.IsDBNull(20) ? string.Empty : reader.GetString(20); user.providerInfo = reader.IsDBNull(21) ? string.Empty : reader.GetString(21); list.Add(user); } } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { OracleUtil.CloseConn(conn); } return(list); }
public void updateStoreHouse(ZcProcessOrderItem zcProcessOrderItem) { string sql = "update zc_storehouse set store = :store, storemoney = :money where id = :id"; OracleConnection conn = null; OracleTransaction tran = null; OracleCommand cmd = new OracleCommand(); try { StoreHouse storeHouse = FindByGoodsFileId(zcProcessOrderItem.goodsFile); float old = float.Parse(storeHouse.Store); storeHouse.Store = (old - float.Parse(zcProcessOrderItem.nums)).ToString(); storeHouse.StoreMoney = ((old - float.Parse(zcProcessOrderItem.nums)) * (float.Parse(storeHouse.StoreMoney) / old)).ToString(); conn = OracleUtil.OpenConn(); tran = conn.BeginTransaction(); cmd.Connection = conn; cmd.CommandText = sql; cmd.Parameters.Add(":store", storeHouse.Store); cmd.Parameters.Add(":money", storeHouse.StoreMoney); cmd.Parameters.Add(":id", storeHouse.Id); cmd.ExecuteNonQuery(); tran.Commit(); } catch (Exception ex) { if (tran != null) { tran.Rollback(); } Console.WriteLine(ex.Message); } finally { OracleUtil.CloseConn(conn); } }
private void endButton_Click(object sender, EventArgs e) { if (sortFlag == false) { DataTable dt = ConstantUtil.Branchds.Tables["Zc_sorte_item"]; object sorteId = dt.Rows[0][8]; if (ConstantUtil.index + 1 >= dt.Rows.Count) { for (int i = 0; i < goodDataGridView.Rows.Count; i++) { string oldCount = goodDataGridView.Rows[i].Cells[3].Value == null ? "" : goodDataGridView.Rows[i].Cells[3].Value.ToString(); string newCount = goodDataGridView.Rows[i].Cells[4].Value == null ? "" : goodDataGridView.Rows[i].Cells[4].Value.ToString(); if (oldCount.Equals(newCount)) { } else { DialogResult dr = MessageBox.Show("存在分拣份数不符合的商品,确定结束分拣?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); if (dr == DialogResult.OK) { break; } else { return; } } } orderDao orderdao = new orderDao(); orderdao.deleteSorteStatus(ConstantUtil.ip1); orderdao.deleteSorteStatus(ConstantUtil.ip2); for (int i = 0; i < dt.Rows.Count; i++) { object id = dt.Rows[i][0]; object streetId = dt.Rows[i][14]; List <ZcProcessOrder> ZcProcessOrderList = orderdao.FindAll(streetId.ToString()); if (ZcProcessOrderList != null && ZcProcessOrderList.Count() > 0) { for (int a = 0; a < ZcProcessOrderList.Count; a++) { ZcProcessOrder zcprocessOrder = ZcProcessOrderList[a]; string orderId = zcprocessOrder.id; List <ZcProcessOrderItem> ZcProcessOrderItemList = orderdao.getItemByid(orderId); if (ZcProcessOrderItemList != null && ZcProcessOrderItemList.Count() > 0) { orderdao.AddtransitItem(ZcProcessOrderItemList); for (int b = 0; b < ZcProcessOrderItemList.Count; b++) { ZcProcessOrderItem zcProcessOrderItem = ZcProcessOrderItemList[b]; string itemId = zcProcessOrderItem.id; orderdao.deletePorcessItem(itemId); orderdao.updateStoreHouse(zcProcessOrderItem); } } if ("全部完成".Equals(zcprocessOrder.pullFlag)) { zcprocessOrder.orderStatus = "5"; orderdao.deletePorcessOrder(zcprocessOrder.id); int count = orderdao.getTransitOrderCount(zcprocessOrder.id); if (count == 0) { orderdao.AddtransitOrder(zcprocessOrder); } else { } } else { } } } } //改变订单状态 orderdao.UpdateStatus(sorteId); MessageBox.Show("分拣完毕!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); sortFlag = true; } else { MessageBox.Show("所有分店尚未分拣完毕,请分拣完毕后再提交数据"); } } else { MessageBox.Show("订单已分拣结束,请返回或退出操作"); } }