| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505 |
- using CallCenterApi.DB;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Data.SqlClient;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace CallCenterApi.DAL
- {
- /// <summary>
- /// 数据访问类:T_Rec_RegRecords
- /// </summary>
- public partial class T_Rec_RegRecords
- {
- public T_Rec_RegRecords()
- { }
- #region Method
- /// <summary>
- /// 是否存在该记录
- /// </summary>
- public bool Exists(int F_ID)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("select count(1) from T_Rec_RegRecords");
- strSql.Append(" where F_ID=@F_ID");
- SqlParameter[] parameters = {
- new SqlParameter("@F_ID", SqlDbType.Int,4)
- };
- parameters[0].Value = F_ID;
- return DbHelperSQL.Exists(strSql.ToString(), parameters);
- }
- /// <summary>
- /// 增加一条数据
- /// </summary>
- public int Add(CallCenterApi.Model.T_Rec_RegRecords model)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("insert into T_Rec_RegRecords(");
- strSql.Append(@"F_RecCode,F_CusID,F_Type,F_Direction,F_Complained,F_Content,
- F_Remark,F_CreateBy,F_CreateOn,F_IsDelete,F_DeleteOn,F_DeleteBy,F_Tel,F_CallId,
- F_userName,F_userPhone,F_userSex,F_userProvince,F_userCity,F_userArea,F_ProblemType,F_Unit,
- F_UnitOffice,F_CaseParty,F_CitizensType,F_PutRecord,F_ZXZType
- )");
- strSql.Append(" values (");
- strSql.Append(@"@F_RecCode,@F_CusID,@F_Type,@F_Direction,@F_Complained,@F_Content,
- @F_Remark,@F_CreateBy,@F_CreateOn,@F_IsDelete,@F_DeleteOn,@F_DeleteBy,@F_Tel,@F_CallId,
- @F_userName,@F_userPhone,@F_userSex,@F_userProvince,@F_userCity,@F_userArea,@F_ProblemType,@F_Unit,
- @F_UnitOffice,@F_CaseParty,@F_CitizensType,@F_PutRecord,@F_ZXZType
- )");
- strSql.Append(";select @@IDENTITY");
- SqlParameter[] parameters = {
- new SqlParameter("@F_RecCode", SqlDbType.NVarChar,50),
- new SqlParameter("@F_CusID", SqlDbType.Int,4),
- new SqlParameter("@F_Type", SqlDbType.Int,4),
- new SqlParameter("@F_Direction", SqlDbType.Int,4),
- new SqlParameter("@F_Complained", SqlDbType.VarChar,2000),
- new SqlParameter("@F_Content", SqlDbType.VarChar),
- new SqlParameter("@F_Remark", SqlDbType.VarChar),
- new SqlParameter("@F_CreateBy", SqlDbType.VarChar,50),
- new SqlParameter("@F_CreateOn", SqlDbType.DateTime),
- new SqlParameter("@F_IsDelete", SqlDbType.Int,4),
- new SqlParameter("@F_DeleteOn", SqlDbType.VarChar,50),
- new SqlParameter("@F_DeleteBy", SqlDbType.DateTime),
- new SqlParameter("@F_Tel", SqlDbType.VarChar,200),
- new SqlParameter("@F_CallId", SqlDbType.VarChar,50),
- new SqlParameter("@F_userName", SqlDbType.VarChar,50),
- new SqlParameter("@F_userPhone", SqlDbType.VarChar,50),
- new SqlParameter("@F_userSex", SqlDbType.VarChar,50),
- new SqlParameter("@F_userProvince", SqlDbType.VarChar,50),
- new SqlParameter("@F_userCity", SqlDbType.VarChar,50),
- new SqlParameter("@F_userArea", SqlDbType.VarChar,50),
- new SqlParameter("@F_ProblemType", SqlDbType.VarChar,50) ,
- new SqlParameter("@F_Unit", SqlDbType.VarChar,50),
- new SqlParameter("@F_UnitOffice", SqlDbType.VarChar,50),
- new SqlParameter("@F_CaseParty", SqlDbType.VarChar,50),
- new SqlParameter("@F_CitizensType", SqlDbType.VarChar,50),
- new SqlParameter("@F_PutRecord", SqlDbType.VarChar,50) ,
- new SqlParameter("@F_ZXZType", SqlDbType.VarChar,50)
- };
- parameters[0].Value = model.F_RecCode;
- parameters[1].Value = model.F_CusID;
- parameters[2].Value = model.F_Type;
- parameters[3].Value = model.F_Direction;
- parameters[4].Value = model.F_Complained;
- parameters[5].Value = model.F_Content;
- parameters[6].Value = model.F_Remark;
- parameters[7].Value = model.F_CreateBy;
- parameters[8].Value = model.F_CreateOn;
- parameters[9].Value = model.F_IsDelete;
- parameters[10].Value = model.F_DeleteOn;
- parameters[11].Value = model.F_DeleteBy;
- parameters[12].Value = model.F_Tel;
- parameters[13].Value = model.F_CallId;
- parameters[14].Value = model.F_userName;
- parameters[15].Value = model.F_userPhone;
- parameters[16].Value = model.F_userSex;
- parameters[17].Value = model.F_userProvince;
- parameters[18].Value = model.F_userCity;
- parameters[19].Value = model.F_userArea;
- parameters[20].Value = model.F_ProblemType;
- parameters[21].Value = model.F_Unit;
- parameters[22].Value = model.F_UnitOffice;
- parameters[23].Value = model.F_CaseParty;
- parameters[24].Value = model.F_CitizensType;
- parameters[25].Value = model.F_PutRecord;
- parameters[26].Value = model.F_ZXZType;
- object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
- if (obj == null)
- {
- return 0;
- }
- else
- {
- return Convert.ToInt32(obj);
- }
- }
- /// <summary>
- /// 更新一条数据
- /// </summary>
- public bool Update(CallCenterApi.Model.T_Rec_RegRecords model)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("update T_Rec_RegRecords set ");
- strSql.Append("F_RecCode=@F_RecCode,");
- strSql.Append("F_CusID=@F_CusID,");
- strSql.Append("F_Type=@F_Type,");
- strSql.Append("F_Direction=@F_Direction,");
- strSql.Append("F_Complained=@F_Complained,");
- strSql.Append("F_Content=@F_Content,");
- strSql.Append("F_Remark=@F_Remark,");
- strSql.Append("F_CreateBy=@F_CreateBy,");
- strSql.Append("F_CreateOn=@F_CreateOn,");
- strSql.Append("F_IsDelete=@F_IsDelete,");
- strSql.Append("F_DeleteOn=@F_DeleteOn,");
- strSql.Append("F_DeleteBy=@F_DeleteBy,");
- strSql.Append("F_Tel=@F_Tel,");
- strSql.Append("F_CallId=@F_CallId");
- strSql.Append("F_userName =@F_userName,");
- strSql.Append("F_userPhone =@F_userPhone,");
- strSql.Append("F_userSex =@F_userSex,");
- strSql.Append("F_userProvince=@F_userProvince,");
- strSql.Append("F_userCity =@F_userCity,");
- strSql.Append("F_userArea =@F_userArea,");
- strSql.Append("F_ProblemType =@F_ProblemType,");
- strSql.Append("F_Unit =@F_Unit, ");
- strSql.Append("F_UnitOffice =@F_UnitOffice,");
- strSql.Append("F_CaseParty =@F_CaseParty,");
- strSql.Append("F_CitizensType=@F_CitizensType,");
- strSql.Append("F_PutRecord =@F_PutRecord,");
- strSql.Append("F_ZXZType =@F_ZXZType,");
- strSql.Append(" where F_ID=@F_ID");
- SqlParameter[] parameters = {
- new SqlParameter("@F_RecCode", SqlDbType.NVarChar,50),
- new SqlParameter("@F_CusID", SqlDbType.Int,4),
- new SqlParameter("@F_Type", SqlDbType.Int,4),
- new SqlParameter("@F_Direction", SqlDbType.Int,4),
- new SqlParameter("@F_Complained", SqlDbType.VarChar,2000),
- new SqlParameter("@F_Content", SqlDbType.VarChar),
- new SqlParameter("@F_Remark", SqlDbType.VarChar),
- new SqlParameter("@F_CreateBy", SqlDbType.VarChar,50),
- new SqlParameter("@F_CreateOn", SqlDbType.DateTime),
- new SqlParameter("@F_IsDelete", SqlDbType.Int,4),
- new SqlParameter("@F_DeleteOn", SqlDbType.VarChar,50),
- new SqlParameter("@F_DeleteBy", SqlDbType.DateTime),
- new SqlParameter("@F_Tel", SqlDbType.VarChar,200),
- new SqlParameter("@F_CallId", SqlDbType.VarChar,50),
-
- new SqlParameter("@F_ID", SqlDbType.Int,4),
- new SqlParameter("@F_userName", SqlDbType.VarChar,50),
- new SqlParameter("@F_userPhone", SqlDbType.VarChar,50),
- new SqlParameter("@F_userSex", SqlDbType.VarChar,50),
- new SqlParameter("@F_userProvince", SqlDbType.VarChar,50),
- new SqlParameter("@F_userCity", SqlDbType.VarChar,50),
- new SqlParameter("@F_userArea", SqlDbType.VarChar,50),
- new SqlParameter("@F_ProblemType", SqlDbType.VarChar,50) ,
- new SqlParameter("@F_Unit", SqlDbType.VarChar,50),
- new SqlParameter("@F_UnitOffice", SqlDbType.VarChar,50),
- new SqlParameter("@F_CaseParty", SqlDbType.VarChar,50),
- new SqlParameter("@F_CitizensType", SqlDbType.VarChar,50),
- new SqlParameter("@F_PutRecord", SqlDbType.VarChar,50),
- new SqlParameter("@F_ZXZType", SqlDbType.VarChar,50)
- };
- parameters[0].Value = model.F_RecCode;
- parameters[1].Value = model.F_CusID;
- parameters[2].Value = model.F_Type;
- parameters[3].Value = model.F_Direction;
- parameters[4].Value = model.F_Complained;
- parameters[5].Value = model.F_Content;
- parameters[6].Value = model.F_Remark;
- parameters[7].Value = model.F_CreateBy;
- parameters[8].Value = model.F_CreateOn;
- parameters[9].Value = model.F_IsDelete;
- parameters[10].Value = model.F_DeleteOn;
- parameters[11].Value = model.F_DeleteBy;
- parameters[12].Value = model.F_Tel;
- parameters[13].Value = model.F_CallId;
- parameters[14].Value = model.F_ID;
- parameters[14].Value = model.F_userName;
- parameters[15].Value = model.F_userPhone;
- parameters[16].Value = model.F_userSex;
- parameters[17].Value = model.F_userProvince;
- parameters[18].Value = model.F_userCity;
- parameters[19].Value = model.F_userArea;
- parameters[20].Value = model.F_ProblemType;
- parameters[21].Value = model.F_Unit;
- parameters[22].Value = model.F_UnitOffice;
- parameters[23].Value = model.F_CaseParty;
- parameters[24].Value = model.F_CitizensType;
- parameters[25].Value = model.F_PutRecord;
- parameters[26].Value = model.F_ZXZType;
- int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
- if (rows > 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- /// <summary>
- /// 删除一条数据
- /// </summary>
- public bool Delete(int F_ID)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("delete from T_Rec_RegRecords ");
- strSql.Append(" where F_ID=@F_ID");
- SqlParameter[] parameters = {
- new SqlParameter("@F_ID", SqlDbType.Int,4)
- };
- parameters[0].Value = F_ID;
- int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
- if (rows > 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- /// <summary>
- /// 批量删除数据
- /// </summary>
- public bool DeleteList(string F_IDlist)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("delete from T_Rec_RegRecords ");
- strSql.Append(" where F_ID in (" + F_IDlist + ") ");
- int rows = DbHelperSQL.ExecuteSql(strSql.ToString());
- if (rows > 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- /// <summary>
- /// 得到一个对象实体
- /// </summary>
- public CallCenterApi.Model.T_Rec_RegRecords GetModel(int F_ID)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("select top 1 * from T_Rec_RegRecords ");
- strSql.Append(" where F_ID=@F_ID");
- SqlParameter[] parameters = {
- new SqlParameter("@F_ID", SqlDbType.Int,4)
- };
- parameters[0].Value = F_ID;
- CallCenterApi.Model.T_Rec_RegRecords model = new CallCenterApi.Model.T_Rec_RegRecords();
- DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
- if (ds.Tables[0].Rows.Count > 0)
- {
- return DataRowToModel(ds.Tables[0].Rows[0]);
- }
- else
- {
- return null;
- }
- }
- /// <summary>
- /// 得到一个对象实体
- /// </summary>
- public CallCenterApi.Model.T_Rec_RegRecords DataRowToModel(DataRow row)
- {
- CallCenterApi.Model.T_Rec_RegRecords model = new CallCenterApi.Model.T_Rec_RegRecords();
- if (row != null)
- {
- if (row["F_ID"] != null && row["F_ID"].ToString() != "")
- {
- model.F_ID = int.Parse(row["F_ID"].ToString());
- }
- if (row["F_RecCode"] != null && row["F_RecCode"].ToString() != "")
- {
- model.F_RecCode = row["F_RecCode"].ToString();
- }
- if (row["F_CusID"] != null && row["F_CusID"].ToString() != "")
- {
- model.F_CusID = int.Parse(row["F_CusID"].ToString());
- }
- if (row["F_Type"] != null && row["F_Type"].ToString() != "")
- {
- model.F_Type = int.Parse(row["F_Type"].ToString());
- }
- if (row["F_Direction"] != null && row["F_Direction"].ToString() != "")
- {
- model.F_Direction = int.Parse(row["F_Direction"].ToString());
- }
- if (row["F_Complained"] != null && row["F_Complained"].ToString() != "")
- {
- model.F_Complained = row["F_Complained"].ToString();
- }
- if (row["F_Content"] != null && row["F_Content"].ToString() != "")
- {
- model.F_Content = row["F_Content"].ToString();
- }
- if (row["F_Remark"] != null && row["F_Remark"].ToString() != "")
- {
- model.F_Remark = row["F_Remark"].ToString();
- }
- if (row["F_CreateBy"] != null && row["F_CreateBy"].ToString() != "")
- {
- model.F_CreateBy = row["F_CreateBy"].ToString();
- }
- if (row["F_CreateOn"] != null && row["F_CreateOn"].ToString() != "")
- {
- model.F_CreateOn = DateTime.Parse(row["F_CreateOn"].ToString());
- }
- if (row["F_IsDelete"] != null && row["F_IsDelete"].ToString() != "")
- {
- model.F_IsDelete = int.Parse(row["F_IsDelete"].ToString());
- }
- if (row["F_DeleteOn"] != null && row["F_DeleteOn"].ToString() != "")
- {
- model.F_DeleteOn = row["F_DeleteOn"].ToString();
- }
- if (row["F_DeleteBy"] != null && row["F_DeleteBy"].ToString() != "")
- {
- model.F_DeleteBy = DateTime.Parse(row["F_DeleteBy"].ToString());
- }
- if (row["F_Tel"] != null && row["F_Tel"].ToString() != "")
- {
- model.F_Tel = row["F_Tel"].ToString();
- }
- if (row["F_CallId"] != null && row["F_CallId"].ToString() != "")
- {
- model.F_CallId = row["F_CallId"].ToString();
- }
- if (row["F_userName"] != null && row["F_userName"].ToString() != "")
- { model.F_userName = row["F_userName"].ToString(); }
- if (row["F_userPhone"] != null && row["F_userPhone"].ToString() != "")
- { model.F_userPhone = row["F_userPhone"].ToString(); }
- if (row["F_userSex"] != null && row["F_userSex"].ToString() != "")
- { model.F_userSex = row["F_userSex"].ToString(); }
- if (row["F_userProvince"] != null && row["F_userProvince"].ToString() != "")
- { model.F_userProvince = row["F_userProvince"].ToString(); }
- if (row["F_userCity"] != null && row["F_userCity"].ToString() != "")
- { model.F_userCity = row["F_userCity"].ToString(); }
- if (row["F_userArea"] != null && row["F_userArea"].ToString() != "")
- { model.F_userArea = row["F_userArea"].ToString(); }
- if (row["F_ProblemType"] != null && row["F_ProblemType"].ToString() != "")
- { model.F_ProblemType = row["F_ProblemType"].ToString(); }
- if (row["F_Unit"] != null && row["F_Unit"].ToString() != "")
- { model.F_Unit = row["F_Unit"].ToString(); }
- if (row["F_UnitOffice"] != null && row["F_UnitOffice"].ToString() != "")
- { model.F_UnitOffice = row["F_UnitOffice"].ToString(); }
- if (row["F_CaseParty"] != null && row["F_CaseParty"].ToString() != "")
- { model.F_CaseParty = row["F_CaseParty"].ToString(); }
- if (row["F_CitizensType"] != null && row["F_CitizensType"].ToString() != "")
- { model.F_CitizensType = row["F_CitizensType"].ToString(); }
- if (row["F_PutRecord"] != null && row["F_PutRecord"].ToString() != "")
- { model.F_PutRecord = row["F_PutRecord"].ToString(); }
- if (row["F_ZXZType"] != null && row["F_ZXZType"].ToString() != "")
- { model.F_ZXZType = row["F_ZXZType"].ToString(); }
-
- }
- return model;
- }
- /// <summary>
- /// 获得数据列表
- /// </summary>
- public DataSet GetList(string strWhere)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("select * ");
- strSql.Append(" FROM T_Rec_RegRecords ");
- if (strWhere.Trim() != "")
- {
- strSql.Append(" where " + strWhere);
- }
- return DbHelperSQL.Query(strSql.ToString());
- }
- /// <summary>
- /// 获得前几行数据
- /// </summary>
- 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_Rec_RegRecords ");
- if (strWhere.Trim() != "")
- {
- strSql.Append(" where " + strWhere);
- }
- strSql.Append(" order by " + filedOrder);
- return DbHelperSQL.Query(strSql.ToString());
- }
- /// <summary>
- /// 获取记录总数
- /// </summary>
- public int GetRecordCount(string strWhere)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("select count(1) FROM T_Rec_RegRecords ");
- if (strWhere.Trim() != "")
- {
- strSql.Append(" where " + strWhere);
- }
- object obj = DbHelperSQL.GetSingle(strSql.ToString());
- if (obj == null)
- {
- return 0;
- }
- else
- {
- return Convert.ToInt32(obj);
- }
- }
- /// <summary>
- /// 分页获取数据列表
- /// </summary>
- public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("SELECT * FROM ( ");
- strSql.Append(" SELECT ROW_NUMBER() OVER (");
- if (!string.IsNullOrEmpty(orderby.Trim()))
- {
- strSql.Append("order by T." + orderby);
- }
- else
- {
- strSql.Append("order by T.F_ID desc");
- }
- strSql.Append(")AS Row, T.* from T_Rec_RegRecords T ");
- if (!string.IsNullOrEmpty(strWhere.Trim()))
- {
- strSql.Append(" WHERE " + strWhere);
- }
- strSql.Append(" ) TT");
- strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
- return DbHelperSQL.Query(strSql.ToString());
- }
- #endregion Method
- }
- }
|