New file |
| | |
| | | using NPOI.HSSF.UserModel; |
| | | using NPOI.SS.UserModel; |
| | | using Pub_Class; |
| | | using System; |
| | | using System.Data; |
| | | using System.Net; |
| | | using System.Net.Http; |
| | | using System.Net.Http.Headers; |
| | | using System.Runtime.InteropServices; |
| | | using System.Web.Http; |
| | | using System.Windows.Forms; |
| | | using WebAPI.Models; |
| | | //using Excel = Microsoft.Office.Interop.Excel; |
| | | |
| | | |
| | | namespace WebAPI.Controllers.åºç¡èµæ.åºç¡èµæ |
| | | { |
| | | public class Gy_SOPBillController : ApiController |
| | | { |
| | | public DBUtility.ClsPub.Enum_BillStatus BillStatus; |
| | | |
| | | private json objJsonResult = new json(); |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | DataSet ds; |
| | | DAL.ClsGy_SOPBill oBill = new DAL.ClsGy_SOPBill(); |
| | | |
| | | public DataGridView grdMain = new System.Windows.Forms.DataGridView(); |
| | | |
| | | #region ä½ä¸æå¯¼ä¹¦å表 |
| | | [Route("Gy_SOPBill/list")] |
| | | [HttpGet] |
| | | public object getSOPBillList(string sWhere, string user) |
| | | { |
| | | try |
| | | { |
| | | //æ¥çæé |
| | | //if (!DBUtility.ClsPub.Security_Log("Gy_SOPBillMain", 1, false, user)) |
| | | //{ |
| | | // objJsonResult.code = "0"; |
| | | // objJsonResult.count = 0; |
| | | // objJsonResult.Message = "æ æ¥çæéï¼"; |
| | | // objJsonResult.data = null; |
| | | // return objJsonResult; |
| | | //} |
| | | |
| | | if (sWhere == null || sWhere.Equals("")) |
| | | { |
| | | ds = oCN.RunProcReturn("select * from h_v_Gy_SOPBillList order by hmainid ", "h_v_Gy_SOPBillList"); |
| | | } |
| | | else |
| | | { |
| | | string sql1 = "select * from h_v_Gy_SOPBillList where 1 = 1 "; |
| | | string sql = sql1 + sWhere + " order by hmainid "; |
| | | ds = oCN.RunProcReturn(sql, "h_v_Gy_SOPBillList"); |
| | | } |
| | | |
| | | //if (ds.Tables[0].Rows.Count != 0 || ds != null) |
| | | //{ |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "Sucessï¼"; |
| | | objJsonResult.data = ds.Tables[0]; |
| | | return objJsonResult; |
| | | //} |
| | | //else |
| | | //{ |
| | | //objJsonResult.code = "0"; |
| | | //objJsonResult.count = 0; |
| | | //objJsonResult.Message = "æ æ°æ®"; |
| | | //objJsonResult.data = null; |
| | | //return objJsonResult; |
| | | //} |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "Exceptionï¼" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | #region å¼åº |
| | | [Route("Gy_SOPBill/SetExcel")] |
| | | [HttpGet] |
| | | public HttpResponseMessage Sc_StationInBillSetExcel(string sWhere) |
| | | { |
| | | HSSFWorkbook workbook = new HSSFWorkbook(); |
| | | ISheet sheet = workbook.CreateSheet("sheet1"); |
| | | IRow row = sheet.CreateRow(0); |
| | | |
| | | |
| | | row.CreateCell(0).SetCellValue("åæ®å·"); |
| | | row.CreateCell(1).SetCellValue("åæ®ç±»å"); |
| | | row.CreateCell(2).SetCellValue("å·¥èºåç§°"); |
| | | row.CreateCell(3).SetCellValue("ç©æä»£ç "); |
| | | row.CreateCell(4).SetCellValue("ç©æåç§°"); |
| | | row.CreateCell(5).SetCellValue("è§æ ¼åå·"); |
| | | row.CreateCell(6).SetCellValue("计éåä½ä»£ç "); |
| | | row.CreateCell(7).SetCellValue("计éåä½"); |
| | | row.CreateCell(8).SetCellValue("é»è®¤æå¯¼ä¹¦"); |
| | | row.CreateCell(9).SetCellValue("è¡¨å¤´å¤æ³¨"); |
| | | row.CreateCell(10).SetCellValue("å·¥åºå·"); |
| | | row.CreateCell(11).SetCellValue("å·¥åºä»£ç "); |
| | | row.CreateCell(12).SetCellValue("å·¥åº"); |
| | | row.CreateCell(13).SetCellValue("å·¥ä½ä¸å¿ä»£ç "); |
| | | row.CreateCell(14).SetCellValue("å·¥ä½ä¸å¿åç§°"); |
| | | row.CreateCell(15).SetCellValue("å·¥ä½ä»£ç "); |
| | | row.CreateCell(16).SetCellValue("å·¥ä½"); |
| | | row.CreateCell(17).SetCellValue("表ä½å¤æ³¨"); |
| | | row.CreateCell(18).SetCellValue("ä½¿ç¨æ è®°"); |
| | | row.CreateCell(19).SetCellValue("å¯ç¨äºº"); |
| | | row.CreateCell(20).SetCellValue("å¯ç¨æ¥æ"); |
| | | row.CreateCell(21).SetCellValue("å¶å人"); |
| | | row.CreateCell(22).SetCellValue("å¶åæ¥æ"); |
| | | row.CreateCell(23).SetCellValue("å®¡æ ¸äºº"); |
| | | row.CreateCell(24).SetCellValue("å®¡æ ¸æ¥æ"); |
| | | row.CreateCell(25).SetCellValue("ä¿®æ¹äºº"); |
| | | row.CreateCell(26).SetCellValue("ä¿®æ¹æ¥æ"); |
| | | row.CreateCell(27).SetCellValue("ä½åºäºº"); |
| | | row.CreateCell(28).SetCellValue("ä½åºæ¥æ"); |
| | | |
| | | |
| | | //精确æ§å¶å宽 |
| | | sheet.SetColumnWidth(1, 5000); |
| | | sheet.SetColumnWidth(2, 5000); |
| | | sheet.SetColumnWidth(3, 5000); |
| | | sheet.SetColumnWidth(4, 5000); |
| | | sheet.SetColumnWidth(5, 5000); |
| | | sheet.SetColumnWidth(6, 5000); |
| | | sheet.SetColumnWidth(7, 5000); |
| | | sheet.SetColumnWidth(8, 5000); |
| | | sheet.SetColumnWidth(9, 5000); |
| | | sheet.SetColumnWidth(10, 5000); |
| | | sheet.SetColumnWidth(11, 5000); |
| | | sheet.SetColumnWidth(12, 5000); |
| | | sheet.SetColumnWidth(13, 5000); |
| | | sheet.SetColumnWidth(14, 5000); |
| | | sheet.SetColumnWidth(15, 5000); |
| | | sheet.SetColumnWidth(16, 5000); |
| | | sheet.SetColumnWidth(17, 5000); |
| | | sheet.SetColumnWidth(18, 5000); |
| | | sheet.SetColumnWidth(19, 5000); |
| | | sheet.SetColumnWidth(20, 5000); |
| | | sheet.SetColumnWidth(21, 5000); |
| | | sheet.SetColumnWidth(22, 5000); |
| | | sheet.SetColumnWidth(23, 5000); |
| | | sheet.SetColumnWidth(24, 5000); |
| | | sheet.SetColumnWidth(25, 5000); |
| | | sheet.SetColumnWidth(26, 5000); |
| | | sheet.SetColumnWidth(27, 5000); |
| | | sheet.SetColumnWidth(28, 5000); |
| | | sheet.SetColumnWidth(29, 5000); |
| | | |
| | | |
| | | DataSet ds = oCN.RunProcReturn("select * from h_v_Gy_SOPBillList" + sWhere + " order by hmainid desc", "h_v_Gy_SOPBillList"); |
| | | for (var i = 0; i < ds.Tables[0].Rows.Count; i++) |
| | | { |
| | | IRow row1 = sheet.CreateRow(i + 1); |
| | | row1.CreateCell(0).SetCellValue(ds.Tables[0].Rows[i]["åæ®å·"].ToString()); |
| | | row1.CreateCell(1).SetCellValue(ds.Tables[0].Rows[i]["åæ®ç±»å"].ToString()); |
| | | row1.CreateCell(2).SetCellValue(ds.Tables[0].Rows[i]["å·¥èºåç§°"].ToString()); |
| | | row1.CreateCell(3).SetCellValue(ds.Tables[0].Rows[i]["ç©æä»£ç "].ToString()); |
| | | row1.CreateCell(4).SetCellValue(ds.Tables[0].Rows[i]["ç©æåç§°"].ToString()); |
| | | row1.CreateCell(5).SetCellValue(ds.Tables[0].Rows[i]["è§æ ¼åå·"].ToString()); |
| | | row1.CreateCell(6).SetCellValue(ds.Tables[0].Rows[i]["计éåä½ä»£ç "].ToString()); |
| | | row1.CreateCell(7).SetCellValue(ds.Tables[0].Rows[i]["计éåä½"].ToString()); |
| | | row1.CreateCell(8).SetCellValue(ds.Tables[0].Rows[i]["é»è®¤æå¯¼ä¹¦"].ToString()); |
| | | row1.CreateCell(9).SetCellValue(ds.Tables[0].Rows[i]["è¡¨å¤´å¤æ³¨"].ToString()); |
| | | row1.CreateCell(10).SetCellValue(ds.Tables[0].Rows[i]["å·¥åºå·"].ToString()); |
| | | row1.CreateCell(11).SetCellValue(ds.Tables[0].Rows[i]["å·¥åºä»£ç "].ToString()); |
| | | row1.CreateCell(12).SetCellValue(ds.Tables[0].Rows[i]["å·¥åº"].ToString()); |
| | | row1.CreateCell(13).SetCellValue(ds.Tables[0].Rows[i]["å·¥ä½ä¸å¿ä»£ç "].ToString()); |
| | | row1.CreateCell(14).SetCellValue(ds.Tables[0].Rows[i]["å·¥ä½ä¸å¿åç§°"].ToString()); |
| | | row1.CreateCell(15).SetCellValue(ds.Tables[0].Rows[i]["å·¥ä½ä»£ç "].ToString()); |
| | | row1.CreateCell(16).SetCellValue(ds.Tables[0].Rows[i]["å·¥ä½"].ToString()); |
| | | row1.CreateCell(17).SetCellValue(ds.Tables[0].Rows[i]["表ä½å¤æ³¨"].ToString()); |
| | | row1.CreateCell(18).SetCellValue(ds.Tables[0].Rows[i]["ä½¿ç¨æ è®°"].ToString()); |
| | | row1.CreateCell(19).SetCellValue(ds.Tables[0].Rows[i]["å¯ç¨äºº"].ToString()); |
| | | row1.CreateCell(20).SetCellValue(ds.Tables[0].Rows[i]["å¯ç¨æ¥æ"].ToString()); |
| | | row1.CreateCell(21).SetCellValue(ds.Tables[0].Rows[i]["å¶å人"].ToString()); |
| | | row1.CreateCell(22).SetCellValue(ds.Tables[0].Rows[i]["å¶åæ¥æ"].ToString()); |
| | | row1.CreateCell(23).SetCellValue(ds.Tables[0].Rows[i]["å®¡æ ¸äºº"].ToString()); |
| | | row1.CreateCell(24).SetCellValue(ds.Tables[0].Rows[i]["å®¡æ ¸æ¥æ"].ToString()); |
| | | row1.CreateCell(25).SetCellValue(ds.Tables[0].Rows[i]["ä¿®æ¹äºº"].ToString()); |
| | | row1.CreateCell(26).SetCellValue(ds.Tables[0].Rows[i]["ä¿®æ¹æ¥æ"].ToString()); |
| | | row1.CreateCell(27).SetCellValue(ds.Tables[0].Rows[i]["ä½åºäºº"].ToString()); |
| | | row1.CreateCell(28).SetCellValue(ds.Tables[0].Rows[i]["ä½åºæ¥æ"].ToString()); |
| | | |
| | | } |
| | | System.IO.MemoryStream ms = new System.IO.MemoryStream(); |
| | | workbook.Write(ms); |
| | | ms.Position = 0; |
| | | |
| | | var response = new HttpResponseMessage(HttpStatusCode.OK); |
| | | response.Content = new StreamContent(ms); |
| | | |
| | | response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); |
| | | var fileName = "ä½ä¸æå¯¼ä¹¦å表.xls"; |
| | | |
| | | response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment") |
| | | { |
| | | FileName = System.Web.HttpUtility.UrlEncode(fileName) |
| | | }; |
| | | return response; |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | // |
| | | private Int32 Fun_GetCol(string sCol) |
| | | { |
| | | return DBUtility.Xt_BaseBillFun.Fun_GetCol(sCol, grdMain); |
| | | } |
| | | #region ä½¿ç¨ |
| | | [Route("Gy_SOPBill/BatchUse")] |
| | | [HttpGet] |
| | | public object sy_Click() |
| | | { |
| | | long sOldInterID = 0; |
| | | for (int i = 0; i <= grdMain.SelectedRows.Count - 1; i++) |
| | | { |
| | | long HInterID = DBUtility.ClsPub.isLong(grdMain.SelectedRows[i].Cells[Fun_GetCol("HMainID")].Value); |
| | | if (HInterID == 0 || HInterID == sOldInterID) |
| | | { |
| | | continue; |
| | | } |
| | | else |
| | | { |
| | | sOldInterID = HInterID; |
| | | } |
| | | if (!oBill.Sub_RoutingCheckAndUsed(HInterID)) |
| | | { |
| | | continue; |
| | | } |
| | | } |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "æ¹é使ç¨å®æ¯ï¼"; |
| | | return objJsonResult; |
| | | } |
| | | #endregion |
| | | } |
| | | } |