private void DoAdd() { Model.BarCodeCreateRecord BarCodeCreateRecord = new Model.BarCodeCreateRecord(); BLL.BarCodeCreateRecord bll = new BLL.BarCodeCreateRecord(); Model.manager adminmodel = Session[DTKeys.SESSION_ADMIN_INFO] as Model.manager; BarCodeCreateRecord.GoodCount = int.Parse(txtGoodCount.Text); BarCodeCreateRecord.BoxSum = Convert.ToInt32(txtBoxsum.Text.Trim()); BarCodeCreateRecord.RetrospectCode = txtRetrospect.Text; BarCodeCreateRecord.Operator = adminmodel.id; BarCodeCreateRecord.Batch = txtBatch.Text.Trim(); BarCodeCreateRecord.State = 1; BarCodeCreateRecord.CreateTime = DateTime.Now; BarCodeCreateRecord.Remark = txtRemark.Text; BarCodeCreateRecord.GoodBarCode = txtGoodBarCode.Text.Trim(); //BarCodeCreateRecord.BrokerageRatio = Convert.ToDecimal(txtBrokerageRatio.Text.Trim()); //BarCodeCreateRecord.IntegralRatio = Convert.ToInt32(txtIntegralRatio.Text.Trim()); Model.BarCode BarCode = new Model.BarCode(); BarCode.CreateTime = DateTime.Now; BarCode.State = 1; Model.GoodCategory gc = new Model.GoodCategory(); BLL.GoodCategory bllgc = new BLL.GoodCategory(); try { bll.Add(BarCodeCreateRecord, BarCode); int i = bll.GetMaxID(); if (i != 0) { ExcelOut(i.ToString()); Response.Redirect("/admin/BarCode/BarCodeCreateDetail.aspx?id=" + i); } } catch (Exception e) { } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; DTcms.BLL.IntegralManage bllIntegralManage = new BLL.IntegralManage(); DTcms.BLL.BarCode bllBarCode = new BLL.BarCode(); DTcms.BLL.BarCodeCreateRecord bllBarCodeCreateRecord = new BLL.BarCodeCreateRecord(); DTcms.BLL.GoodCategory bllGoodCategory = new BLL.GoodCategory(); string type = context.Request.QueryString["type"]; switch (type) { case "select": //int pageIndex = int.Parse(context.Request.Form["page"]); //int pageSize = int.Parse(context.Request.Form["rows"]); List <Model.IntegralManage> listIntegralManage = bllIntegralManage.GetList(); List <Model.BarCode> listBarCode = bllBarCode.GetList(); List <Model.BarCodeCreateRecord> listBarCodeCreateRecord = bllBarCodeCreateRecord.GetList(); List <Model.GoodCategory> listGoodCategory = bllGoodCategory.GetList(); var query = listIntegralManage.Join(listBarCode, i => i.IntegralCode, b => b.IntegralCode, (i, b) => new { IntegralManageID = i.IntegralManageID, IntegralCode = i.IntegralCode, CreateTime = i.CreateTime, Remark = i.Remark, BarCodeCreateRecordID = b.BarCodeCreateRecordID }) .Join(listBarCodeCreateRecord, a => a.BarCodeCreateRecordID, c => c.BarCodeCreateRecordID, (a, c) => new { IntegralManageID = a.IntegralManageID, IntegralCode = a.IntegralCode, CreateTime = a.CreateTime, Remark = a.Remark, GoodCategoryID = c.GoodCategoryID }) .Join(listGoodCategory, d => d.GoodCategoryID, g => g.GoodCategoryID, (d, g) => new { IntegralManageID = d.IntegralManageID, IntegralCode = d.IntegralCode, CreateTime = d.CreateTime, Remark = d.Remark, IntegralRatio = g.IntegralRatio }); if (context.Request.QueryString["code"] != null) { query = query.Where(i => i.IntegralCode == context.Request.QueryString["code"]); } //query = query.Join(listBarCodeCreateRecord, i => i.BarCodeCreateRecordID, c => c.BarCodeCreateRecordID, (i, c) => new { IntegralManageID = i.IntegralManageID, IntegralCode = i.IntegralCode, CreateTime = i.CreateTime, Remark = i.Remark, GoodCategoryID = c.GoodCategoryID }); //query = query.Join(listBarCodeCreateRecord, i => i.BarCodeCreateRecordID, c => c.BarCodeCreateRecordID, (i, c) => new { aaa=i.BarCodeCreateRecordID}); string json = JsonConvert.SerializeObject(query); context.Response.Write(json); //context.Response.Write("{\"total\":" + "\"" + 50 + "\"" + ",\"rows\":" + json + "}"); break; } }
public void ExcelOut(string id) { Microsoft.Office.Interop.Excel.Application excel = new Microsoft.Office.Interop.Excel.Application(); Microsoft.Office.Interop.Excel.Workbook wb = null; Microsoft.Office.Interop.Excel.Sheets sh = null; excel.Application.Workbooks.Add(true); excel.Cells[1, 1] = "箱码"; excel.Cells[1, 2] = "物流码"; excel.Cells[1, 3] = "积分码";; string content = " 箱码 物流码 积分码\r\n"; BLL.BarCode bllBarCode = new BLL.BarCode(); System.Data.DataTable dt = bllBarCode.GetBarCodeCreateDetailByBarCodeCreateRecordID(id); BLL.BarCodeCreateRecord bllBarCodeCreateRecord = new BLL.BarCodeCreateRecord(); int num = 2; string FileName; FileName = Guid.NewGuid().ToString(); object OsPath, FilePathxls, FilePathtxt; //表格文件的保存地址 OsPath = Server.MapPath("/DownLoad/"); //这里我定义了桌面的地址 FilePathxls = string.Format("{0}{1}", (string)OsPath, FileName + ".xls"); //为了自定义地址,加了一个地址拼接 FilePathtxt = string.Format("{0}{1}", (string)OsPath, FileName + ".txt"); //为了自定义地址,加了一个地址拼接 FileStream fs = File.Create(FilePathtxt.ToString()); foreach (DataRow dr in dt.Rows) { excel.Cells[num, 1] = dr["BoxCode"]; excel.Cells[num, 2] = dr["LogisticsCode"]; excel.Cells[num, 3] = dr["IntegralCode"]; content += dr["BoxCode"].ToString() + " " + dr["LogisticsCode"] + " " + dr["IntegralCode"] + "\r\n"; num++; } byte[] buffer = Encoding.UTF8.GetBytes(content); fs.Write(buffer, 0, buffer.Length); //bllBarCodeCreateRecord.Update(id, "//DownLoad//" + FileName); bllBarCodeCreateRecord.Update(id, FileName); excel.Visible = false; excel.DisplayAlerts = false; excel.AlertBeforeOverwriting = false; excel.ActiveWorkbook.SaveAs(FilePathxls); excel.Quit(); //Response.Write("/DownLoad/" + FileName + ".txt"); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; BLL.BarCodeCreateRecord bllBarCodeCreateRecord = new BLL.BarCodeCreateRecord(); BLL.GoodCategory bllGoodCategory = new BLL.GoodCategory(); List <Model.BarCodeCreateRecord> listBarCodeCreateRecord = bllBarCodeCreateRecord.GetList(); List <Model.GoodCategory> listGoodCategory = bllGoodCategory.GetList(); var query = listGoodCategory.Where(g => g.GoodCategoryName == "旭贝尔乳基婴儿配方奶粉 1段(0-12个月)铁罐900g").Join(listBarCodeCreateRecord, g => g.GoodCategoryID, b => b.GoodCategoryID, (g, b) => new { g.Standard }).ToList(); //listBarCodeCreateRecord.Join(listGoodCategory,b=>b.GoodCategoryID,g=>g.GoodCategoryID); int param = int.Parse(context.Request.Form["param"]); if (query.Count() == 0 || param % query[0].Standard > 0) { context.Response.Write("{ \"info\":\"请输入" + query[0].Standard + "的倍数\", \"status\":\"n\" }"); } else { context.Response.Write("{ \"info\":\"\", \"status\":\"y\" }"); } }
public void ExcelOut(HttpContext context, string id) { BLL.BarCodeCreateRecord bllbcr = new BLL.BarCodeCreateRecord(); BLL.GoodCategory bllgc = new BLL.GoodCategory(); List <Model.GoodCategory> gList = bllgc.GetList(); List <Model.BarCodeCreateRecord> bList = bllbcr.GetList(); var model = bList.Where(b => b.BarCodeCreateRecordID == int.Parse(id)).ToList(); //var model = bList.Join(gList, b => b.GoodCategoryID, g => g.GoodCategoryID, (b, g) => new { GoodCategoryName = g.GoodCategoryName, BarCodeCreateRecordID = b.BarCodeCreateRecordID, DownLoad=b.DownLoad }).Where(b => b.BarCodeCreateRecordID == int.Parse(id)).ToList(); //Model.BarCodeCreateRecord model = bllbcr.GetModel(id); string aaa = context.Server.MapPath("/DownLoad/"); string FullFileName = aaa + model[0].DownLoad + ".txt"; FileInfo DownloadFile = new FileInfo(FullFileName); context.Response.Clear(); context.Response.ClearHeaders(); context.Response.Buffer = false; context.Response.ContentType = "application/octet-stream"; //context.Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(model[0].GoodCategoryName+".txt", System.Text.Encoding.UTF8)); context.Response.AppendHeader("Content-Disposition", "attachment;filename=" + model[0].RetrospectCode + ".txt"); context.Response.AppendHeader("Content-Length", DownloadFile.Length.ToString()); context.Response.WriteFile(DownloadFile.FullName); context.Response.Flush(); context.Response.End(); }