using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using Uninpho.DBOperation.Model; using Uninpho.DBOperation.Operation; using System.IO; using DevExpress.XtraEditors; using DevExpress.XtraGrid.Views.Grid; using DevExpress.XtraGrid; using Uninpho.Tools.components.MTLFF; using ClosedXML.Excel; namespace Uninpho.Tools.components.ZZJH { class ZZJHCommon { static string UUID; public static T_zhuzhenjihe_filelist updataListMessage(GridView gv, string url, int row) { IXLWorksheet XLWorksheet = new XLWorkbook(url).Worksheet(1); T_zhuzhenjihe_filelist tm = new T_zhuzhenjihe_filelist() { Zhanming = XLWorksheet.Row(2).Cell(2).Value.ToString(), //Xianluming = XLWorksheet.Row(2).Cell(14).Value.ToString(), Xianluming = gv.GetRowCellValue(row, "Xianluming").ToString(), Daochahao = XLWorksheet.Row(2).Cell(4).Value.ToString(), Zhechahao = XLWorksheet.Row(2).Cell(6).Value.ToString(), Shejituhao = XLWorksheet.Row(2).Cell(8).Value.ToString(), Riqi = XLWorksheet.Row(2).Cell(10).Value.ToString(), Jiancharen = XLWorksheet.Row(3).Cell(2).Value.ToString() }; gv.SetRowCellValue(row, "Zhanming", tm.Zhanming); //gv.SetRowCellValue(row, "Xianluming", tm.Xianluming); gv.SetRowCellValue(row, "Daochahao", tm.Daochahao); gv.SetRowCellValue(row, "Zhechahao", tm.Zhechahao); gv.SetRowCellValue(row, "Shejituhao", tm.Shejituhao); gv.SetRowCellValue(row, "Riqi", tm.Riqi.Split(' ')[0]); gv.SetRowCellValue(row, "Jiancharen", tm.Jiancharen); return tm; } /// /// 保存至filelist表 /// public static string SaveExcel2PG() { T_zhuzhenjihe_filelist mtlf = new T_zhuzhenjihe_filelist(); mtlf.Zhanming = ExcelTools.chezhan; mtlf.Daochahao = ExcelTools.daocha; mtlf.Zhechahao = ExcelTools.zhecha; mtlf.Riqi = ExcelTools.jianceshijian; mtlf.Jiancharen = ExcelTools.jianceren; mtlf.Shejituhao = ExcelTools.shejituhao; mtlf.Xianluming = ExcelTools.xianluming; mtlf.Excelbytearr = ExcelTools.GetFileData(ExcelTools.filenameall); mtlf.Remark = DateTime.Now.ToString(); //mtlf.Gengxinriqi = DateTime.Now.ToString(); //mtlf.Gengxinren = UserInform.userinf.Username; UUID = DataAnalysisToPG.InsertZZJHListDataToPG(mtlf); return UUID; } /// /// 保存至exceldata表 /// public static void saveExcelData2PG() { var workbook = new XLWorkbook(ExcelTools.filenameall); IXLWorksheet XLWorksheet = workbook.Worksheet(1); List mtlfdata = new List(); GetmtlfExcelData(ref mtlfdata, XLWorksheet); //foreach (var item in mtlfdata) //{ // DataAnalysisToPG.InsertZZJHExcelDataToPG(item); //} DataAnalysisToPG.InsertZZJHExcelDataToPG(mtlfdata); } private static void GetmtlfExcelData(ref List mtlfdata, IXLWorksheet XLWorksheet) { int startZH = int.Parse(ExcelTools.zhenhaoqs); int endZH = int.Parse(ExcelTools.zhenhaozz); int startrow = 6; int rowcount = (int)Math.Ceiling((decimal)(endZH - startZH + 1) / 2); for (int i = 0; i < rowcount; i++) { mtlfdata.Add(new T_zhuzhenjihe_exceldata() { Filelistid=UUID, Zhenhao = XLWorksheet.Row(startrow + i).Cell(1).Value.ToString(), Zgguiju = XLWorksheet.Row(startrow + i).Cell(2).Value.ToString(), Zgshuiping = XLWorksheet.Row(startrow + i).Cell(3).Value.ToString(), Qgguiju = XLWorksheet.Row(startrow + i).Cell(4).Value.ToString(), Qgshuiping = XLWorksheet.Row(startrow + i).Cell(5).Value.ToString(), Remark = XLWorksheet.Row(startrow + i).Cell(11).Value.ToString() }); } for (int i = 0; i < endZH - startZH - rowcount + 1; i++) { mtlfdata.Add(new T_zhuzhenjihe_exceldata() { Filelistid = UUID, Zhenhao = XLWorksheet.Row(startrow + i).Cell(6).Value.ToString(), Zgguiju = XLWorksheet.Row(startrow + i).Cell(7).Value.ToString(), Zgshuiping = XLWorksheet.Row(startrow + i).Cell(8).Value.ToString(), Qgguiju = XLWorksheet.Row(startrow + i).Cell(9).Value.ToString(), Qgshuiping = XLWorksheet.Row(startrow + i).Cell(10).Value.ToString(), Remark = XLWorksheet.Row(startrow + i).Cell(11).Value.ToString() }); } } } }