/// <summary> /// 创建数据文件 /// </summary> /// <param name="orderDate"></param> /// <param name="batchNo"></param> private void CreateDataFile(string orderDate, int batchNo) { FileStream file = new FileStream(parameter["NoOneProFilePath"] + txtFile, FileMode.Create); StreamWriter writer = new StreamWriter(file, Encoding.UTF8); OrderScheduleDal orderDal = new OrderScheduleDal(); DataTable table; int columnCount; if (!this.isAbnormity) { //正常分拣打码 table = orderDal.GetOrder(orderDate, batchNo, 1, false); columnCount = table.Columns.Count; foreach (DataRow row in table.Rows) { string s = row["SORTNO"].ToString(); for (int i = 1; i < columnCount; i++) { s += ("," + row[i].ToString().Trim()); } s += ";"; writer.WriteLine(s); writer.Flush(); } } if (!this.isAbnormity) { //手工分拣打码 table = orderDal.GetOrder(orderDate, batchNo, 2, false); columnCount = table.Columns.Count; foreach (DataRow row in table.Rows) { string s = row["SORTNO"].ToString(); for (int i = 1; i < columnCount; i++) { s += ("," + row[i].ToString().Trim()); } s += ";"; writer.WriteLine(s); writer.Flush(); } } if (!this.isAbnormity) { //整件分拣打码 table = orderDal.GetOrder(orderDate, batchNo, 3, false); columnCount = table.Columns.Count; foreach (DataRow row in table.Rows) { string s = row["SORTNO"].ToString(); for (int i = 1; i < columnCount; i++) { s += ("," + row[i].ToString().Trim()); } s += ";"; writer.WriteLine(s); writer.Flush(); } } if (this.isAbnormity) { //异形分拣打码 table = orderDal.GetOrder(orderDate, batchNo, 4, isSortAbnormityOrderByOrder); columnCount = table.Columns.Count; int index_cigarette = 0; string cigaretteCode = ""; foreach (DataRow row in table.Rows) { string s = string.Empty; if (isSortAbnormityOrderByOrder) { s = row["SORTNO"].ToString(); for (int i = 1; i < columnCount; i++) { s += ("," + row[i].ToString().Trim()); } s += ";"; } else { if (cigaretteCode != row[4].ToString().Trim()) { index_cigarette++; cigaretteCode = row[4].ToString().Trim(); } s = row["SORTNO"].ToString(); s += ("," + index_cigarette.ToString()); for (int i = 2; i < columnCount; i++) { s += ("," + row[i].ToString().Trim()); } s += ";"; } writer.WriteLine(s); writer.Flush(); } } file.Close(); }