private void button11_Click(object sender, EventArgs e) { if (dataGridView3.Rows.Count == 0) { MessageBox.Show("没有统计的订单"); return; } list.Clear(); for (int i = 0; i < dataGridView3.Rows.Count; i++) { if (list.FindIndex(o => o.PickpointName == dataGridView3.Rows[i].Cells["ColumePickPoint1"].Value.ToString()) != -1) { int index = list.FindIndex(o => o.PickpointName == dataGridView3.Rows[i].Cells["ColumePickPoint1"].Value.ToString()); //得到索引 //item.PickpointName = dataGridView3.Rows[i].Cells["ColumePickPoint1"].ToString(); Details info = new Details(dataGridView3.Rows[i].Cells["ColumeGoodsNo1"].Value.ToString()); for (int j = 0; j < info.dataGridView1.Rows.Count; j++) { if (list[index].Goods.ContainsKey(info.dataGridView1.Rows[j].Cells["GoodsName"].Value.ToString())) { list[index].Goods[info.dataGridView1.Rows[j].Cells["GoodsName"].Value.ToString()] += Convert.ToInt32(info.dataGridView1.Rows[j].Cells["GoodsNum"].Value); } else { list[index].Goods.Add(info.dataGridView1.Rows[j].Cells["GoodsName"].Value.ToString(), Convert.ToInt32(info.dataGridView1.Rows[j].Cells["GoodsNum"].Value)); } } } else { Pickpoint item = new Pickpoint(); item.PickpointName = ""; item.Goods = new Dictionary <string, int>(); item.PickpointName = dataGridView3.Rows[i].Cells["ColumePickPoint1"].Value.ToString(); Details info = new Details(dataGridView3.Rows[i].Cells["ColumeGoodsNo1"].Value.ToString()); //info.ShowDialog(); for (int j = 0; j < info.dataGridView1.Rows.Count; j++) { if (item.Goods.ContainsKey(info.dataGridView1.Rows[j].Cells["GoodsName"].Value.ToString())) { item.Goods[info.dataGridView1.Rows[j].Cells["GoodsName"].Value.ToString()] += Convert.ToInt32(info.dataGridView1.Rows[j].Cells["GoodsNum"].Value); } else { item.Goods.Add(info.dataGridView1.Rows[j].Cells["GoodsName"].Value.ToString(), Convert.ToInt32(info.dataGridView1.Rows[j].Cells["GoodsNum"].Value)); } } list.Add(item); } } report newReport = new report(); for (int k = 0; k < list.Count; k++) { newReport.textBox1.Text += (list[k].PickpointName + ":" + "\r\n"); foreach (var item in list[k].Goods) { newReport.textBox1.Text += (item.Key + ":" + item.Value + "份" + "\r\n"); } newReport.textBox1.Text += "\r\n\r\n\r\n"; } Test.AddvanceSubInfo WriteInfo = new Test.AddvanceSubInfo(); WriteInfo.AddvanceSubState = 0; WriteInfo.CountTime = DateTime.Now; WriteInfo.Details = newReport.textBox1.Text; WriteInfo.OrderNum = dataGridView3.Rows.Count; DateTime time = DateTime.Now; string strtime = DateTime.Now.ToString("yyyyMMddHHmmssff"); WriteInfo.AddvanceId = "AD" + strtime; List <string> OrderNoList = new List <string>(); //统计关联表 for (int i = 0; i < dataGridView3.Rows.Count; i++) { OrderNoList.Add(dataGridView3.Rows[i].Cells["ColumeGoodsNo1"].Value.ToString()); } string[] OrderNoListData = OrderNoList.ToArray(); //写入关联表 SQL.InputAssociationList(OrderNoListData, WriteInfo.AddvanceId); //写入数据库 SQL.WriteIntoSub(WriteInfo); newReport.ShowDialog(); dataGridView3.Rows.Clear(); }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (dataGridView1.Columns[e.ColumnIndex].Name == "ViewDetails" && dataGridView1.Rows[e.RowIndex].Cells["ViewDetails"].Value != "已完成预分装") { report newreport = new report(); newreport.textBox1.Text = list[e.RowIndex].Details.ToString(); newreport.ShowDialog(); } //点击预分装 if (dataGridView1.Columns[e.ColumnIndex].Name == "AdvanceSub" && dataGridView1.Rows[e.RowIndex].Cells["AdvanceSub"].Value != "已完成预分装") { SQL.AlterSubStatus(1, Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells["ReportId"].Value)); List <string> list = SQL.getOrderList(dataGridView1.Rows[e.RowIndex].Cells["AddvanceId"].Value.ToString()).ToList(); //根据预分装号获取相应的订单编号 string[] listData = list.ToArray(); List <Test.GoodsOrder> GoodsOrderList = new List <Test.GoodsOrder>(); GoodsOrderList = SQL.getGoodsOrderListByAddvanceId(listData).ToList(); //获取详细订单信息 //写入发货单号 for (int i = 0; i < GoodsOrderList.Count; i++) { Test.BoxInfo BoxInfo = new Test.BoxInfo(); BoxInfo = SQL.GetBoxInfo(GoodsOrderList[i].OrderNo); if (BoxInfo.BoxGroupId != null && BoxInfo.BoxGroupOpenCode != null) { int BoxGroupId = Convert.ToInt32(BoxInfo.BoxGroupId); int BoxGroupOpenCode = Convert.ToInt32(BoxInfo.BoxGroupOpenCode); //生成发货单号 string ShoppingCode = DateTime.Now.ToString("yyyyMMdd") + BoxGroupId.ToString("000") + (BoxGroupOpenCode - 1).ToString("00") + DateTime.Now.ToString("HHmmssf"); SQL.WriteShoppingNo(ShoppingCode, GoodsOrderList[i].OrderNo);//执行数据库接口写入发货单号 } } SQL.alterGoodsOrderShoppingState(1, listData); //变更订单状态为打包中 //dataGridView1.Rows[e.RowIndex].Cells["ViewDetails"].Value = "已完成预分装"; dataGridView1.Rows[e.RowIndex].Cells["AdvanceSub"].Value = "已完成预分装"; dataGridView1.Rows[e.RowIndex].Cells["Delete"].Value = "已完成预分装"; dataGridView1.Rows[e.RowIndex].Cells["Print"].Value = "打印"; } if (dataGridView1.Columns[e.ColumnIndex].Name == "Delete" && dataGridView1.Rows[e.RowIndex].Cells["Delete"].Value != "已完成预分装") { SQL.DeleteSubInfo(Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells["ReportId"].Value)); string[] List = SQL.getOrderList(dataGridView1.Rows[e.RowIndex].Cells["AddvanceId"].Value.ToString()); SQL.AlterGoodsOderStatus(0, List); dataGridView1.Rows.RemoveAt(e.RowIndex); } if (dataGridView1.Columns[e.ColumnIndex].Name == "Print" && dataGridView1.Rows[e.RowIndex].Cells["Print"].Value != "") { PrintList newPrintWindow = new PrintList(dataGridView1.Rows[e.RowIndex].Cells["AddvanceId"].Value.ToString()); newPrintWindow.ShowDialog(); } }