public ResultInfo SaveIcon(int iconNumber, string iconName, FileInfo file) { byte[] bytes = BinaryHelper.FileToBytes(file.FullName); if (bytes == null) { return(ResultInfo.Fail); } SqlDBHelper sqlHelper = new SqlDBHelper(); sqlHelper.BeginTran(); try { string sqlStr = @"update sadDTICON set IconImage=@IconImage where iconNumber=@iconNumber"; SqlParameter[] pars = GetPars(iconNumber, bytes); int line = sqlHelper.ExecuteNonQuery(sqlStr, pars); if (line == 1) { sqlHelper.CommitTran(); return(ResultInfo.Cover); } else if (line > 1) { sqlHelper.RollBackTran(); return(ResultInfo.Fail); } else { //新增 if (iconNumber == 0) { iconNumber = Convert.ToInt32(sqlHelper.ExecuteScalar("select max(IconNumber)+1 from sadDTICON")); } if (iconName == "") { iconName = file.Name; } int calc_No = Convert.ToInt32(sqlHelper.ExecuteScalar("select max(Calc_No)+1 from sadDTICON")); sqlStr = string.Format("insert into sadDTICON values ({0},1,@IconImage,'{1}',1,13,GETDATE())", iconNumber, iconName); pars = GetPars(iconNumber, bytes); int lineIns = sqlHelper.ExecuteNonQuery(sqlStr, pars); if (lineIns == 1) { sqlHelper.CommitTran(); return(ResultInfo.Increase); } else { sqlHelper.RollBackTran(); return(ResultInfo.Fail); } } } catch (Exception ex) { sqlHelper.RollBackTran(); throw ex; } }
public ResultInfo SaveIcon(int iconNumber, string iconName,FileInfo file) { byte[] bytes = BinaryHelper.FileToBytes(file.FullName); if (bytes == null) { return ResultInfo.Fail; } SqlDBHelper sqlHelper = new SqlDBHelper(); sqlHelper.BeginTran(); try { string sqlStr = @"update sadDTICON set IconImage=@IconImage where iconNumber=@iconNumber"; SqlParameter[] pars = GetPars(iconNumber, bytes); int line = sqlHelper.ExecuteNonQuery(sqlStr, pars); if(line==1) { sqlHelper.CommitTran(); return ResultInfo.Cover; } else if (line > 1) { sqlHelper.RollBackTran(); return ResultInfo.Fail; } else { //新增 if (iconNumber == 0) { iconNumber =Convert.ToInt32( sqlHelper.ExecuteScalar("select max(IconNumber)+1 from sadDTICON")); } if (iconName=="") { iconName = file.Name; } int calc_No = Convert.ToInt32(sqlHelper.ExecuteScalar("select max(Calc_No)+1 from sadDTICON")); sqlStr = string.Format("insert into sadDTICON values ({0},1,@IconImage,'{1}',1,13,GETDATE())", iconNumber, iconName); pars = GetPars(iconNumber, bytes); int lineIns = sqlHelper.ExecuteNonQuery(sqlStr, pars); if (lineIns == 1) { sqlHelper.CommitTran(); return ResultInfo.Increase; } else { sqlHelper.RollBackTran(); return ResultInfo.Fail; } } } catch(Exception ex) { sqlHelper.RollBackTran(); throw ex; } }
/// <summary> /// 获取热点MAC总数量 /// </summary> /// <returns></returns> public int GetHotspotInfoLog() { try { string sql = "select COUNT(1) from wifi.Hotspot"; return(SqlDBHelper.ExecuteScalar(sql, CommandType.Text, null).GetInt32()); } catch (Exception ex) { LogHelper.Log.Error("数据库访问失败", ex); return(0); } }