using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using ZXDT.DBUtility; using System.Data.SqlClient; namespace ZXDT.CallCenter.DAL { //T_Fax_SentFax public partial class T_Fax_SentFax { public bool Exists(int FaxID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select count(1) from T_Fax_SentFax"); strSql.Append(" where "); strSql.Append(" FaxID = @FaxID "); SqlParameter[] parameters = { new SqlParameter("@FaxID", SqlDbType.Int,4) }; parameters[0].Value = FaxID; return DbHelperSQL.Exists(strSql.ToString(), parameters); } /// /// 增加一条数据 /// public void Add(Model.T_Fax_SentFax model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into T_Fax_SentFax("); strSql.Append("FaxID,SendTime,LastSentTime,CurSentCount,MaxSendCount,Info,FileState,State,F_UserID,F_CustomerID,F_Name,TelNum,F_FaxCode,WebFilePath,FileName,FilePath,TifFilePath,FileSize,FileType,Remark,CommitTime"); strSql.Append(") values ("); strSql.Append("@FaxID,@SendTime,@LastSentTime,@CurSentCount,@MaxSendCount,@Info,@FileState,@State,@F_UserID,@F_CustomerID,@F_Name,@TelNum,@F_FaxCode,@WebFilePath,@FileName,@FilePath,@TifFilePath,@FileSize,@FileType,@Remark,@CommitTime"); strSql.Append(") "); SqlParameter[] parameters = { new SqlParameter("@FaxID", SqlDbType.Int,4) , new SqlParameter("@SendTime", SqlDbType.DateTime) , new SqlParameter("@LastSentTime", SqlDbType.DateTime) , new SqlParameter("@CurSentCount", SqlDbType.Int,4) , new SqlParameter("@MaxSendCount", SqlDbType.Int,4) , new SqlParameter("@Info", SqlDbType.VarChar,200) , new SqlParameter("@FileState", SqlDbType.Int,4) , new SqlParameter("@State", SqlDbType.Int,4) , new SqlParameter("@F_UserID", SqlDbType.Int,4) , new SqlParameter("@F_CustomerID", SqlDbType.Int,4) , new SqlParameter("@F_Name", SqlDbType.NVarChar,50) , new SqlParameter("@TelNum", SqlDbType.VarChar,20) , new SqlParameter("@F_FaxCode", SqlDbType.VarChar,20) , new SqlParameter("@WebFilePath", SqlDbType.VarChar,200) , new SqlParameter("@FileName", SqlDbType.VarChar,50) , new SqlParameter("@FilePath", SqlDbType.VarChar,200) , new SqlParameter("@TifFilePath", SqlDbType.VarChar,200) , new SqlParameter("@FileSize", SqlDbType.Int,4) , new SqlParameter("@FileType", SqlDbType.VarChar,20) , new SqlParameter("@Remark", SqlDbType.VarChar,200) , new SqlParameter("@CommitTime", SqlDbType.DateTime) }; parameters[0].Value = model.FaxID; parameters[1].Value = model.SendTime; parameters[2].Value = model.LastSentTime; parameters[3].Value = model.CurSentCount; parameters[4].Value = model.MaxSendCount; parameters[5].Value = model.Info; parameters[6].Value = model.FileState; parameters[7].Value = model.State; parameters[8].Value = model.F_UserID; parameters[9].Value = model.F_CustomerID; parameters[10].Value = model.F_Name; parameters[11].Value = model.TelNum; parameters[12].Value = model.F_FaxCode; parameters[13].Value = model.WebFilePath; parameters[14].Value = model.FileName; parameters[15].Value = model.FilePath; parameters[16].Value = model.TifFilePath; parameters[17].Value = model.FileSize; parameters[18].Value = model.FileType; parameters[19].Value = model.Remark; parameters[20].Value = model.CommitTime; DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); } /// /// 重新发送 /// /// 发送的ID /// public int ReSend(string arrFaxID) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into T_Fax_SendFaxTask("); strSql.Append("TelNum,FilePath,TifFilePath,FileSize,FileType,Remark,CommitTime,SendTime,LastSentTime,CurSentCount,MaxSendCount,Info,FileState,State,F_UserID,F_CustomerID,F_Name,FileName)"); strSql.Append(" select TelNum,FilePath,TifFilePath,FileSize,FileType,Remark,getdate(),getdate(),null,0,MaxSendCount,'',FileState,0,F_UserID,F_CustomerID,F_Name,FileName "); strSql.Append(" from T_Fax_SentFax "); if (arrFaxID.IndexOf(",") == -1) { strSql.Append(" where FaxID = " + arrFaxID); } else { strSql.Append(" where FaxID in (" + arrFaxID + ") "); } return DbHelperSQL.ExecuteSql(strSql.ToString()); } /// /// 更新一条数据 /// public bool Update(Model.T_Fax_SentFax model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update T_Fax_SentFax set "); strSql.Append(" FaxID = @FaxID , "); strSql.Append(" SendTime = @SendTime , "); strSql.Append(" LastSentTime = @LastSentTime , "); strSql.Append(" CurSentCount = @CurSentCount , "); strSql.Append(" MaxSendCount = @MaxSendCount , "); strSql.Append(" Info = @Info , "); strSql.Append(" FileState = @FileState , "); strSql.Append(" State = @State , "); strSql.Append(" F_UserID = @F_UserID , "); strSql.Append(" F_CustomerID = @F_CustomerID , "); strSql.Append(" F_Name = @F_Name , "); strSql.Append(" TelNum = @TelNum , "); strSql.Append(" F_FaxCode = @F_FaxCode , "); strSql.Append(" WebFilePath = @WebFilePath , "); strSql.Append(" FileName = @FileName , "); strSql.Append(" FilePath = @FilePath , "); strSql.Append(" TifFilePath = @TifFilePath , "); strSql.Append(" FileSize = @FileSize , "); strSql.Append(" FileType = @FileType , "); strSql.Append(" Remark = @Remark , "); strSql.Append(" CommitTime = @CommitTime "); strSql.Append(" where FaxID=@FaxID "); SqlParameter[] parameters = { new SqlParameter("@FaxID", SqlDbType.Int,4) , new SqlParameter("@SendTime", SqlDbType.DateTime) , new SqlParameter("@LastSentTime", SqlDbType.DateTime) , new SqlParameter("@CurSentCount", SqlDbType.Int,4) , new SqlParameter("@MaxSendCount", SqlDbType.Int,4) , new SqlParameter("@Info", SqlDbType.VarChar,200) , new SqlParameter("@FileState", SqlDbType.Int,4) , new SqlParameter("@State", SqlDbType.Int,4) , new SqlParameter("@F_UserID", SqlDbType.Int,4) , new SqlParameter("@F_CustomerID", SqlDbType.Int,4) , new SqlParameter("@F_Name", SqlDbType.NVarChar,50) , new SqlParameter("@TelNum", SqlDbType.VarChar,20) , new SqlParameter("@F_FaxCode", SqlDbType.VarChar,20) , new SqlParameter("@WebFilePath", SqlDbType.VarChar,200) , new SqlParameter("@FileName", SqlDbType.VarChar,50) , new SqlParameter("@FilePath", SqlDbType.VarChar,200) , new SqlParameter("@TifFilePath", SqlDbType.VarChar,200) , new SqlParameter("@FileSize", SqlDbType.Int,4) , new SqlParameter("@FileType", SqlDbType.VarChar,20) , new SqlParameter("@Remark", SqlDbType.VarChar,200) , new SqlParameter("@CommitTime", SqlDbType.DateTime) }; parameters[0].Value = model.FaxID; parameters[1].Value = model.SendTime; parameters[2].Value = model.LastSentTime; parameters[3].Value = model.CurSentCount; parameters[4].Value = model.MaxSendCount; parameters[5].Value = model.Info; parameters[6].Value = model.FileState; parameters[7].Value = model.State; parameters[8].Value = model.F_UserID; parameters[9].Value = model.F_CustomerID; parameters[10].Value = model.F_Name; parameters[11].Value = model.TelNum; parameters[12].Value = model.F_FaxCode; parameters[13].Value = model.WebFilePath; parameters[14].Value = model.FileName; parameters[15].Value = model.FilePath; parameters[16].Value = model.TifFilePath; parameters[17].Value = model.FileSize; parameters[18].Value = model.FileType; parameters[19].Value = model.Remark; parameters[20].Value = model.CommitTime; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return true; } else { return false; } } /// /// 更新一条数据 /// public int UpdateWebFilePath(Model.T_Fax_SentFax model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update T_Fax_SentFax set "); strSql.Append("WebFilePath=@WebFilePath"); strSql.Append(" where FaxID=@FaxID "); SqlParameter[] parameters = { new SqlParameter("@FaxID", SqlDbType.Int,4), new SqlParameter("@WebFilePath", SqlDbType.VarChar,200)}; parameters[0].Value = model.FaxID; parameters[1].Value = model.WebFilePath; return DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); } /// /// 删除一条数据 /// public bool Delete(int FaxID) { StringBuilder strSql = new StringBuilder(); strSql.Append("delete from T_Fax_SentFax "); strSql.Append(" where FaxID=@FaxID "); SqlParameter[] parameters = { new SqlParameter("@FaxID", SqlDbType.Int,4) }; parameters[0].Value = FaxID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return true; } else { return false; } } /// /// 批量删除一批数据 /// public bool DeleteList(string FaxIDlist) { StringBuilder strSql = new StringBuilder(); strSql.Append("delete from T_Fax_SentFax "); strSql.Append(" where FaxID in (" + FaxIDlist + ") "); int rows = DbHelperSQL.ExecuteSql(strSql.ToString()); if (rows > 0) { return true; } else { return false; } } /// /// 得到一个对象实体 /// public Model.T_Fax_SentFax GetModel(int FaxID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select FaxID, SendTime, LastSentTime, CurSentCount, MaxSendCount, Info, FileState, State, F_UserID, F_CustomerID, F_Name, TelNum, F_FaxCode, WebFilePath, FileName, FilePath, TifFilePath, FileSize, FileType, Remark, CommitTime "); strSql.Append(" from T_Fax_SentFax "); strSql.Append(" where FaxID=@FaxID "); SqlParameter[] parameters = { new SqlParameter("@FaxID", SqlDbType.Int,4) }; parameters[0].Value = FaxID; Model.T_Fax_SentFax model = new Model.T_Fax_SentFax(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["FaxID"].ToString() != "") { model.FaxID = int.Parse(ds.Tables[0].Rows[0]["FaxID"].ToString()); } if (ds.Tables[0].Rows[0]["SendTime"].ToString() != "") { model.SendTime = DateTime.Parse(ds.Tables[0].Rows[0]["SendTime"].ToString()); } if (ds.Tables[0].Rows[0]["LastSentTime"].ToString() != "") { model.LastSentTime = DateTime.Parse(ds.Tables[0].Rows[0]["LastSentTime"].ToString()); } if (ds.Tables[0].Rows[0]["CurSentCount"].ToString() != "") { model.CurSentCount = int.Parse(ds.Tables[0].Rows[0]["CurSentCount"].ToString()); } if (ds.Tables[0].Rows[0]["MaxSendCount"].ToString() != "") { model.MaxSendCount = int.Parse(ds.Tables[0].Rows[0]["MaxSendCount"].ToString()); } model.Info = ds.Tables[0].Rows[0]["Info"].ToString(); if (ds.Tables[0].Rows[0]["FileState"].ToString() != "") { model.FileState = int.Parse(ds.Tables[0].Rows[0]["FileState"].ToString()); } if (ds.Tables[0].Rows[0]["State"].ToString() != "") { model.State = int.Parse(ds.Tables[0].Rows[0]["State"].ToString()); } if (ds.Tables[0].Rows[0]["F_UserID"].ToString() != "") { model.F_UserID = int.Parse(ds.Tables[0].Rows[0]["F_UserID"].ToString()); } if (ds.Tables[0].Rows[0]["F_CustomerID"].ToString() != "") { model.F_CustomerID = int.Parse(ds.Tables[0].Rows[0]["F_CustomerID"].ToString()); } model.F_Name = ds.Tables[0].Rows[0]["F_Name"].ToString(); model.TelNum = ds.Tables[0].Rows[0]["TelNum"].ToString(); model.F_FaxCode = ds.Tables[0].Rows[0]["F_FaxCode"].ToString(); model.WebFilePath = ds.Tables[0].Rows[0]["WebFilePath"].ToString(); model.FileName = ds.Tables[0].Rows[0]["FileName"].ToString(); model.FilePath = ds.Tables[0].Rows[0]["FilePath"].ToString(); model.TifFilePath = ds.Tables[0].Rows[0]["TifFilePath"].ToString(); if (ds.Tables[0].Rows[0]["FileSize"].ToString() != "") { model.FileSize = int.Parse(ds.Tables[0].Rows[0]["FileSize"].ToString()); } model.FileType = ds.Tables[0].Rows[0]["FileType"].ToString(); model.Remark = ds.Tables[0].Rows[0]["Remark"].ToString(); if (ds.Tables[0].Rows[0]["CommitTime"].ToString() != "") { model.CommitTime = DateTime.Parse(ds.Tables[0].Rows[0]["CommitTime"].ToString()); } return model; } else { return null; } } /// /// 获得数据列表 /// public DataSet GetList(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * "); strSql.Append(" FROM T_Fax_SentFax "); if (strWhere.Trim() != "") { strSql.Append(" where " + strWhere); } return DbHelperSQL.Query(strSql.ToString()); } /// /// 获得前几行数据 /// public DataSet GetList(int Top, string strWhere, string filedOrder) { StringBuilder strSql = new StringBuilder(); strSql.Append("select "); if (Top > 0) { strSql.Append(" top " + Top.ToString()); } strSql.Append(" * "); strSql.Append(" FROM T_Fax_SentFax "); if (strWhere.Trim() != "") { strSql.Append(" where " + strWhere); } strSql.Append(" order by " + filedOrder); return DbHelperSQL.Query(strSql.ToString()); } } }