Пример #1
0
        //excel operation
        public bool IsToolsInfoRecordExist(string filePath)
        {
            string          sql    = "select * from 工具信息";
            OleDbDataReader reader = EXCELHelper.LoadDataFromExcel(filePath, sql);

            if (!reader.HasRows)
            {
                reader.Close();
                return(false);
            }
            reader.Close();
            return(true);
        }
Пример #2
0
        public List <ToolsInfo> getAllToolsFromExcel(string filePath)
        {
            string           sql    = "select * from 工具信息";
            OleDbDataReader  reader = EXCELHelper.LoadDataFromExcel(filePath, sql);
            List <ToolsInfo> list   = new List <ToolsInfo>();

            if (!reader.HasRows)
            {
                reader.Close();
                return(null);
            }
            while (reader.Read())
            {
                try
                {
                    list.Add(new ToolsInfo
                    {
                        SerialNum             = reader["工具序列号"].ToString(),
                        Model                 = reader["工具型号"].ToString(),
                        Category              = reader["工具类别"].ToString(),
                        Name                  = reader["工具名称"].ToString(),
                        TorqueMin             = double.Parse(reader["标定扭矩下限"].ToString()),
                        TorqueMax             = double.Parse(reader["标定扭矩上限"].ToString()),
                        Accuracy              = double.Parse(reader["精度"].ToString()),
                        Section               = reader["工段"].ToString(),
                        DemarcateCycle        = int.Parse(reader["标定周期"].ToString()),
                        Workstation           = reader["工位"].ToString(),
                        Status                = reader["工具状态"].ToString(),
                        QualityAssureDate     = reader["质保期至"].ToString(),
                        MaintainContractStyle = reader["保养合同类型"].ToString(),
                        MaintainContractDate  = reader["保养合同至"].ToString(),
                        RepairTimes           = int.Parse(reader["累计维修次数"].ToString() == "" ? "0" : reader["累计维修次数"].ToString()),
                        Remark                = reader["备注信息"].ToString()
                    });
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"getAllToolsFromExcel failed, error message is: {ex.Message}");
                }
            }
            if (reader != null)
            {
                reader.Close();
            }
            return(list);
        }
Пример #3
0
        public int InsertToolsInfo2ExcelTable(string filePath, object obj)
        {
            string sql = ExcelDeclare.InsertToolsInfoExcelSql;

            PropertyInfo[] propertys = obj.GetType().GetProperties();
            int            i         = 0;

            foreach (PropertyInfo pinfo in propertys)
            {
                if (i == 0)
                {
                    sql += " values(" + "'" + pinfo.GetValue(obj, null) + "'";
                }
                else
                {
                    sql += ", " + "'" + pinfo.GetValue(obj, null) + "'";
                }
                i++;
            }
            sql += ")";
            return(EXCELHelper.InsertExcelTable(filePath, obj, sql));
        }
Пример #4
0
        public int CreateToolsInfoExcelTable(string filePath)
        {
            string sql = ExcelDeclare.CreateToolsInfoExcelSql;

            return(EXCELHelper.CreateExcelTable(filePath, sql));
        }
Пример #5
0
 //excel operation
 public int CreateDemarcateHistoryExcelTable(string filePath)
 {
     return(EXCELHelper.CreateExcelTable(filePath, ExcelDeclare.CreateDemarcateHistoryExcelSql));
 }
Пример #6
0
 //excel operation
 public int CreateMaintainManageInfoExcelTable(string filePath)
 {
     return(EXCELHelper.CreateExcelTable(filePath, ExcelDeclare.CreateMaintainManageInfoExcelSql));
 }
Пример #7
0
 //excel operation
 public int CreatRepoSpareToolExcelTable(string filePath)
 {
     return(EXCELHelper.CreateExcelTable(filePath, ExcelDeclare.CreateRepoSpareToolExcelSql));
 }
Пример #8
0
 //excel operation
 public int CreateOnCallRecordExcelTable(string filePath)
 {
     return(EXCELHelper.CreateExcelTable(filePath, ExcelDeclare.CreateOnCallRecordExcelSql));
 }