protected void Page_Load(object sender, EventArgs e) { string workorder = Request.QueryString["workorder"]; string status = Request.QueryString["status"]; string partsdrawingno = Request.QueryString["partsdrawingno"]; string order = Request.QueryString["order"]; string starttime = Request.QueryString["starttime"]; string endtime = Request.QueryString["endtime"]; DateTime dtstart = DateTime.Today.AddDays(-100); DateTime dtend = DateTime.Now; if (!string.IsNullOrEmpty(starttime) && !string.IsNullOrEmpty(endtime)) { dtstart = Convert.ToDateTime(starttime); dtend = Convert.ToDateTime(endtime); } WorkOrder wo = new WorkOrder(); wo.WO = workorder; wo.STATUS = status == "4"?"":status; wo.PartsdrawingCode = partsdrawingno; wo.OrderNumber = order; wo.StartTime = dtstart; wo.EndTime = dtend; SystemBO _bal = BLLFactory.GetBal <SystemBO>(userInfo); IList <WorkOrder> woobjs = _bal.FindWorkOrderInfo(wo); WsSystem ws = new WsSystem(); if (woobjs == null || woobjs.Count == 0) { Response.Write("no data"); return; } HSSFWorkbook hssfWorkbook = new HSSFWorkbook(); Row row = null; Cell cell = null; Sheet hssfSheet = hssfWorkbook.CreateSheet("CapacityStatistics"); row = hssfSheet.CreateRow(0); //填充头 string objs = "工单单号,订单单号,零件图号,工单状态,机床类型,机床名称,负责人员,产品名称,计划开始,计划结束,批次,计划数量,生产数量,计划检验,计划入库"; for (int i = 0; i < objs.Split(',').Length; i++) { cell = row.CreateCell(i); cell.SetCellValue(objs.Split(',')[i]); } if (woobjs != null) { for (int i = 2; i <= woobjs.Count + 1; i++) { row = hssfSheet.CreateRow(i); cell = row.CreateCell(0); cell.SetCellValue(woobjs[i - 2].WO); cell = row.CreateCell(1); cell.SetCellValue(woobjs[i - 2].OrderNumber); cell = row.CreateCell(2); cell.SetCellValue(woobjs[i - 2].PartsdrawingCode); cell = row.CreateCell(3); cell.SetCellValue(woobjs[i - 2].MEMO); cell = row.CreateCell(4); cell.SetCellValue(woobjs[i - 2].MachineType); cell = row.CreateCell(5); cell.SetCellValue(woobjs[i - 2].MachineName); cell = row.CreateCell(6); cell.SetCellValue(woobjs[i - 2].WorkerName); cell = row.CreateCell(7); cell.SetCellValue(woobjs[i - 2].ProductName); cell = row.CreateCell(8); cell.SetCellValue(woobjs[i - 2].StartTime.ToString()); cell = row.CreateCell(9); cell.SetCellValue(woobjs[i - 2].EndTime.ToString()); cell = row.CreateCell(10); cell.SetCellValue(woobjs[i - 2].BatchNumber); cell = row.CreateCell(11); cell.SetCellValue(woobjs[i - 2].PlanQuantity.ToString()); cell = row.CreateCell(12); cell.SetCellValue(woobjs[i - 2].QUANTITY.ToString()); cell = row.CreateCell(13); cell.SetCellValue(woobjs[i - 2].CheckTime.ToString()); cell = row.CreateCell(14); cell.SetCellValue(woobjs[i - 2].InTime.ToString()); cell = row.CreateCell(15); cell.SetCellValue(ws.FindUserNameByCode(woobjs[i - 2].UpdatedBy)); cell = row.CreateCell(16); cell.SetCellValue(woobjs[i - 2].UpdatedDate == null ? woobjs[i - 2].CreatedDate.ToString() : woobjs[i - 2].UpdatedDate.ToString()); } } MemoryStream file = new MemoryStream(); hssfWorkbook.Write(file); String fileName = "CapacityStatistics" + DateTime.Now.ToString("yyyyMMddHHmmss"); Response.Clear(); Response.ClearContent(); Response.ClearHeaders(); Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}.xls", fileName)); Response.AddHeader("Content-Length", file.Length.ToString()); Response.AddHeader("Content-Transfer-Encoding", "binary"); Response.ContentType = "application/octet-stream"; Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8"); Response.BinaryWrite(file.GetBuffer()); Response.Flush(); Response.End(); }
protected void Page_Load(object sender, EventArgs e) { string custname = Request.QueryString["custname"]; string partsdrawing = Request.QueryString["partsdrawing"]; string starttime = Request.QueryString["starttime"]; string endtime = Request.QueryString["endtime"]; SystemBO _bal = BLLFactory.GetBal <SystemBO>(userInfo); WorkOrder wo = new WorkOrder(); wo.CustName = custname; wo.PartsdrawingCode = partsdrawing; if (!string.IsNullOrEmpty(starttime)) { wo.StartTime = Convert.ToDateTime(starttime); } if (!string.IsNullOrEmpty(endtime)) { wo.EndTime = Convert.ToDateTime(endtime); } IList <WorkOrder> objs = _bal.FindWorkOrderInfo(wo); if (objs == null || objs.Count == 0) { Response.Write("no data"); return; } HSSFWorkbook hssfWorkbook = new HSSFWorkbook(); Row row = null; Cell cell = null; Sheet hssfSheet = hssfWorkbook.CreateSheet("YieldQuery"); row = hssfSheet.CreateRow(0); //填充头 string objhead = "客户名称,工件图号,工件名称,批次,产出数量,合格数量,不良数量,返工数量,让步数量,废品数量,合格率,不良率,返工率,让步率,废品率"; for (int i = 0; i < objhead.Split(',').Length; i++) { cell = row.CreateCell(i); cell.SetCellValue(objhead.Split(',')[i]); } for (int i = 1; i < objs.Count + 1; i++) { row = hssfSheet.CreateRow(i); cell = row.CreateCell(0); cell.SetCellValue(objs[i - 1].CustName); cell = row.CreateCell(1); cell.SetCellValue(objs[i - 1].PartsdrawingCode); cell = row.CreateCell(2); cell.SetCellValue(objs[i - 1].ProductName); cell = row.CreateCell(3); cell.SetCellValue(objs[i - 1].BatchNumber); cell = row.CreateCell(4); cell.SetCellValue((objs[i - 1].QUANTITY == null ? 0 : objs[i - 1].QUANTITY).ToString()); int[] fails = _bal.FindYieldCountInfo("", objs[i - 1].PartsdrawingCode); int passcount = (int)(objs[i - 1].QUANTITY == null ? 0 : objs[i - 1].QUANTITY) - fails[0]; string passrate = (Math.Round((double)(passcount * 100 / (objs[i - 1].QUANTITY == null ? 1 : objs[i - 1].QUANTITY)), 2)).ToString() + "%"; string failrate = (Math.Round((double)(fails[0] * 100 / (objs[i - 1].QUANTITY == null ? 1 : objs[i - 1].QUANTITY)), 2)).ToString() + "%"; string returnrate = (Math.Round((double)(fails[1] * 100 / (objs[i - 1].QUANTITY == null ? 1 : objs[i - 1].QUANTITY)), 2)).ToString() + "%"; string secpassrate = (Math.Round((double)(fails[2] * 100 / (objs[i - 1].QUANTITY == null ? 1 : objs[i - 1].QUANTITY)), 2)).ToString() + "%"; string dicardrate = (Math.Round((double)(fails[3] * 100 / (objs[i - 1].QUANTITY == null ? 1 : objs[i - 1].QUANTITY)), 2)).ToString() + "%"; cell = row.CreateCell(5); cell.SetCellValue(passcount.ToString()); cell = row.CreateCell(6); cell.SetCellValue(fails[0].ToString()); cell = row.CreateCell(7); cell.SetCellValue(fails[1].ToString()); cell = row.CreateCell(8); cell.SetCellValue(fails[2].ToString()); cell = row.CreateCell(9); cell.SetCellValue(fails[3].ToString()); cell = row.CreateCell(10); cell.SetCellValue(passrate); cell = row.CreateCell(11); cell.SetCellValue(failrate); cell = row.CreateCell(12); cell.SetCellValue(returnrate); cell = row.CreateCell(13); cell.SetCellValue(secpassrate); cell = row.CreateCell(14); cell.SetCellValue(dicardrate); } MemoryStream file = new MemoryStream(); hssfWorkbook.Write(file); String fileName = "YieldQuery" + DateTime.Now.ToString("yyyyMMddHHmmss"); Response.Clear(); Response.ClearContent(); Response.ClearHeaders(); Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}.xls", fileName)); Response.AddHeader("Content-Length", file.Length.ToString()); Response.AddHeader("Content-Transfer-Encoding", "binary"); Response.ContentType = "application/octet-stream"; Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8"); Response.BinaryWrite(file.GetBuffer()); Response.Flush(); Response.End(); }
protected void Page_Load(object sender, EventArgs e) { string workorder = Request.QueryString["workorder"]; string partsdrawing = Request.QueryString["partsdrawing"]; string starttime = Request.QueryString["starttime"]; string endtime = Request.QueryString["endtime"]; if (workorder == "undefined") { workorder = ""; } if (partsdrawing == "undefined") { partsdrawing = ""; } if (starttime == "undefined") { starttime = ""; } if (endtime == "undefined") { endtime = ""; } SystemBO _bal = BLLFactory.GetBal <SystemBO>(userInfo); WorkOrder wo = new WorkOrder(); wo.WO = workorder; wo.PartsdrawingCode = partsdrawing; if (!string.IsNullOrEmpty(starttime) && starttime != "undefined") { wo.StartTime = Convert.ToDateTime(starttime); } if (!string.IsNullOrEmpty(endtime) && starttime != "undefined") { wo.EndTime = Convert.ToDateTime(endtime); } IList <WorkOrder> objs = _bal.FindWorkOrderInfo(wo); if (objs == null || objs.Count == 0) { Response.Write("no data"); return; } HSSFWorkbook hssfWorkbook = new HSSFWorkbook(); Row row = null; Cell cell = null; Sheet hssfSheet = hssfWorkbook.CreateSheet("ProductMarQuery"); row = hssfSheet.CreateRow(0); //填充头 string objhead = @"订单号码,工单号码,零件图号,产品名称,生产人员,机床名称 , 计划数量, 产出数量,合格数量,废品数量,额定工时,额定总工时,实际总工时"; for (int i = 0; i < objhead.Split(',').Length; i++) { cell = row.CreateCell(i); cell.SetCellValue(objhead.Split(',')[i]); } for (int i = 1; i < objs.Count + 1; i++) { row = hssfSheet.CreateRow(i); cell = row.CreateCell(0); cell.SetCellValue(objs[i - 1].OrderNumber); cell = row.CreateCell(1); cell.SetCellValue(objs[i - 1].WO); cell = row.CreateCell(2); cell.SetCellValue(objs[i - 1].PartsdrawingCode); cell = row.CreateCell(3); cell.SetCellValue(objs[i - 1].ProductName); cell = row.CreateCell(4); cell.SetCellValue(objs[i - 1].WorkerName); cell = row.CreateCell(5); cell.SetCellValue(objs[i - 1].MachineName); cell = row.CreateCell(6); cell.SetCellValue(objs[i - 1].PlanQuantity.ToString()); cell = row.CreateCell(7); cell.SetCellValue(objs[i - 1].QUANTITY.ToString()); cell = row.CreateCell(8); int[] fails = _bal.FindYieldCountInfo("", objs[i - 1].PartsdrawingCode); int passcount = (int)(objs[i - 1].QUANTITY == null ? 0 : objs[i - 1].QUANTITY) - fails[0]; //string passrate = (Math.Round((double)(passcount * 100 / (objs[i - 1].QUANTITY == null ? 1 : objs[i - 1].QUANTITY)), 2)).ToString() + "%"; //string failrate = (Math.Round((double)(fails[0] * 100 / (objs[i - 1].QUANTITY == null ? 1 : objs[i - 1].QUANTITY)), 2)).ToString() + "%"; //string returnrate = (Math.Round((double)(fails[1] * 100 / (objs[i - 1].QUANTITY == null ? 1 : objs[i - 1].QUANTITY)), 2)).ToString() + "%"; //string secpassrate = (Math.Round((double)(fails[2] * 100 / (objs[i - 1].QUANTITY == null ? 1 : objs[i - 1].QUANTITY)), 2)).ToString() + "%"; //string dicardrate = (Math.Round((double)(fails[3] * 100 / (objs[i - 1].QUANTITY == null ? 1 : objs[i - 1].QUANTITY)), 2)).ToString() + "%"; cell.SetCellValue(passcount.ToString()); cell = row.CreateCell(9); cell.SetCellValue(fails[3].ToString()); cell = row.CreateCell(10); cell.SetCellValue(objs[i - 1].UnitTime.ToString()); cell = row.CreateCell(11); cell.SetCellValue((objs[i - 1].QUANTITY * objs[i - 1].UnitTime).ToString()); cell = row.CreateCell(12); cell.SetCellValue(_bal.FindActualTotalUnitTime(objs[i - 1].WO, objs[i - 1].PartsdrawingCode)); } MemoryStream file = new MemoryStream(); hssfWorkbook.Write(file); String fileName = "ProductMarQuery" + DateTime.Now.ToString("yyyyMMddHHmmss"); Response.Clear(); Response.ClearContent(); Response.ClearHeaders(); Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}.xls", fileName)); Response.AddHeader("Content-Length", file.Length.ToString()); Response.AddHeader("Content-Transfer-Encoding", "binary"); Response.ContentType = "application/octet-stream"; Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8"); Response.BinaryWrite(file.GetBuffer()); Response.Flush(); Response.End(); }