public w_DataReceive() { InitializeComponent(); CheckForIllegalCrossThreadCalls = false; pno = Convert.ToDecimal(ConfigurationManager.AppSettings["PNo"]); try { lmb = BLL_Data.GetAllBillInfo(pno); } catch { MessageBox.Show("数据库连接失败,请检查数据库网络并重新启动程序!"); foreach (Control item in Controls) { item.Enabled = false; } return; } DgvOrderData.DataSource = lmb; if (lmb.Count > 0) { Model_BillInfo info = new Model_BillInfo(); int packageno; try { packageno = lmb.Where(item => item.LabelingStatus == "未完成").Min(item => item.PackageNo); } catch { packageno = lmb.Where(item => item.LabelingStatus == "已完成").Max(item => item.PackageNo); } info = lmb.Where(item => item.PackageNo == packageno).FirstOrDefault(); lblID.Text = "流水编号:" + packageno.ToString(); lblCusName.Text = "客户名称:" + info.CusName; lblCusCount.Text = "商户总量:" + lmb.GroupBy(item => item.BillCode).Select(item => item.Key.Distinct()).Count().ToString(); lblCusAddress.Text = "客户地址:" + info.CusAddress.ToString(); lblPackageCount.Text = "总包数:" + lmb.Count().ToString(); } }
public static List <Model_BillInfo> GetAllBillInfo(decimal pno) { string sqlStr = "select PACKAGENO,CUSTOMERNAME,LABELINGSTATUS,LINENAME,BILLCODE,ORDERDATE,CUSTOMERADDRESS from t_produce_callback T " + "where PNO=" + pno + " GROUP BY PACKAGENO,CUSTOMERNAME,LABELINGSTATUS,LINENAME,BILLCODE,ORDERDATE,CUSTOMERADDRESS ORDER BY PACKAGENO "; OracleDataReader reader = OracleHelper.ExecuteReader(OracleHelper.ConnectionString, System.Data.CommandType.Text, sqlStr); List <Model_BillInfo> list = new List <Model_BillInfo>(); while (reader.Read()) { Model_BillInfo billInfo = new Model_BillInfo() { PackageNo = Convert.ToInt32(reader["PACKAGENO"].ToString().Trim()), BillCode = reader["BILLCODE"].ToString(), CusAddress = reader["CUSTOMERADDRESS"].ToString(), CusName = reader["CUSTOMERNAME"].ToString(), LabelingStatus = reader["LABELINGSTATUS"].ToString(), LineName = reader["LINENAME"].ToString(), OrderDate = reader["ORDERDATE"].ToString() }; list.Add(billInfo); } reader.Close(); return(list); }
private void BGWDataReceive_DoWork(object sender, DoWorkEventArgs e) { try { if (choosePath == "") { path = Application.StartupPath + @"\数据\" + DateTime.Now.ToString("yyyy-MM-dd") + ".txt"; } else { path = choosePath; } } catch (Exception ex) { MessageBox.Show(ex.Message); return; } string sr = ""; if (pno == 1) { List <Model_Data> lmd = FileRead.ReadUnFile(path, out sr); if (sr != "" && lmd.Count == 0) { MessageBox.Show(sr); return; } int index = 0; int id = BLL_Data.GetMaxID(pno); if (id == 0) { index = 0; } else if (id == lmd.Count) { index = lmd.Count; MessageBox.Show("数据已全部接收,如需重新接收数据,请先清除数据"); } else { index = id; } for (int i = index; i < lmd.Count; i++) { lmd[i].LabelingStatus = "0"; lmd[i].ID = i + 1; lmd[i].PNo = pno; BLL_Data.InsertUnnormalData(lmd[i]); } } else { List <Model_NormalData> lmdn = FileRead.ReadNormalFile(path, out sr); if (sr != "" && lmdn.Count == 0) { MessageBox.Show(sr); return; } int index = 0; int id = BLL_Data.GetMaxID(pno); if (id == 0) { index = 0; } else if (id == lmdn.Count) { index = lmdn.Count; MessageBox.Show("数据已全部接收,如需重新接收数据,请先清除数据"); return; } else { index = id; } for (int i = index; i < lmdn.Count; i++) { lmdn[i].LabelingStatus = "0"; lmdn[i].ID = i + 1; lmdn[i].PNo = pno; BLL_Data.InsertNormalData(lmdn[i]); } } lmb = new List <Model_BillInfo>(); lmb = BLL_Data.GetAllBillInfo(pno); Model_BillInfo info = new Model_BillInfo(); int packageno = lmb.Where(item => item.LabelingStatus == "未完成").Min(item => item.PackageNo); info = lmb.Where(item => item.PackageNo == packageno).FirstOrDefault(); lblID.Text = "流水编号:" + packageno.ToString(); lblCusName.Text = "客户名称:" + info.CusName; lblCusCount.Text = "商户总量:" + lmb.GroupBy(item => item.BillCode).Select(item => item.Key.Distinct()).Count().ToString(); lblCusAddress.Text = "客户地址:" + info.CusAddress.ToString(); lblPackageCount.Text = "总包数:" + lmb.Count().ToString(); DgvOrderData.DataSource = lmb; }