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; } }
public bool SaveIcon(List <IconBKInfo> iconList, string strSql) { SqlDBHelper sqlHelper = new SqlDBHelper(); sqlHelper.BeginTran(); try { sqlHelper.InsertOrUpdateTList <IconBKInfo>(iconList); sqlHelper.ExecuteNonQuery(strSql); sqlHelper.CommitTran(); //sqlHelper.RollBackTran(); ///////////////////////////////////////////////////////////////////////////////// return(true); } catch (Exception ex) { sqlHelper.RollBackTran(); throw ex; } }
public ResultInfo SaveIcon(List <HQSadDTICONInfo> sadDTIconList) { _sqlHelper.BeginTran(); try { foreach (HQSadDTICONInfo sadDTIcon in sadDTIconList) { List <SqlParameter> pars = new List <SqlParameter>(); pars.Add(SqlDBHelper.GetPar("Storenum", SqlDbType.NVarChar, sadDTIcon.Storenum)); pars.Add(SqlDBHelper.GetPar("IconNumber", SqlDbType.NVarChar, sadDTIcon.IconNumber)); pars.Add(SqlDBHelper.GetPar("effective_Date", SqlDbType.DateTime, sadDTIcon.effective_Date)); pars.Add(SqlDBHelper.GetPar("strgroup", SqlDbType.Int, sadDTIcon.strgroup)); pars.Add(SqlDBHelper.GetPar("upd_seq", SqlDbType.Int, sadDTIcon.upd_seq)); pars.Add(SqlDBHelper.GetPar("IconName", SqlDbType.NVarChar, sadDTIcon.IconName)); pars.Add(SqlDBHelper.GetPar("Status", SqlDbType.Bit, sadDTIcon.Status)); pars.Add(SqlDBHelper.GetPar("UpUser", SqlDbType.Int, sadDTIcon.UpUser)); pars.Add(SqlDBHelper.GetPar("UpDT", SqlDbType.DateTime, sadDTIcon.UpDT)); pars.Add(SqlDBHelper.GetPar("Editor", SqlDbType.NVarChar, sadDTIcon.Editor)); pars.Add(SqlDBHelper.GetPar("IconType", SqlDbType.Int, sadDTIcon.IconType)); pars.Add(SqlDBHelper.GetPar("deleted", SqlDbType.VarChar, sadDTIcon.deleted)); string cmdStr = string.Format(@" DELETE FROM _upd_sadDTICON WHERE Storenum=@Storenum AND IconNumber=@IconNumber AND effective_Date=@effective_Date AND strgroup=@strgroup ; INSERT INTO _upd_sadDTICON( [upd_seq],[Storenum],[IconNumber],[IconName],[Status],[effective_Date],[UpUser],[UpDT],[Editor],[IconType],[strgroup],[deleted] ) VALUES( @upd_seq,@Storenum,@IconNumber,@IconName,@Status,@effective_Date,@UpUser,@UpDT,@Editor,@IconType,@strgroup,@deleted ) ;" ); _sqlHelper.ExecuteNonQuery(cmdStr, pars.ToArray()); } _sqlHelper.CommitTran(); return(ResultInfo.Success); } catch (Exception ex) { _sqlHelper.RollBackTran(); return(ResultInfo.Fail); } }