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
{
///
/// 数据访问类:T_Vis_Telphone
///
public partial class T_Vis_Telphone
{
public T_Vis_Telphone()
{ }
#region BasicMethod
///
/// 是否存在该记录
///
public bool Exists(int F_TelID)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select count(1) from T_Vis_Telphone");
strSql.Append(" where F_TelID=@F_TelID");
SqlParameter[] parameters = {
new SqlParameter("@F_TelID", SqlDbType.Int,4)
};
parameters[0].Value = F_TelID;
return DbHelperSQL.Exists(strSql.ToString(), parameters);
}
///
/// 增加一条数据
///
public int Add(CallCenterApi.Model.T_Vis_Telphone model)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("insert into T_Vis_Telphone(");
strSql.Append("F_Sheng,F_Store,F_Prodate,F_Reciver,F_License,F_Brand,F_Models,F_CusName,F_CusTelphone,F_CusPhone,F_RepType,F_SurveyDate,F_TScore,F_RScore,F_RingS,F_WholeS,F_TotalS,F_Remark,F_VisResult,F_VisInfo,F_VisIS,F_RepItem,F_TheTeam,F_Elect,F_Sheetmetal,F_Paint,F_RepUser,F_WoNumber,F_NewCus,F_InputDate,F_InputUserID,F_InputUserName,F_VisUserID,F_VisUserName,F_VisDate,F_ISVis,F_CallUserID,F_CallUserName,F_CallDate,F_ISCall,F_CallResID,F_CallRes,F_ISCallRes,F_AllotUserID,F_AllotUserName,F_AllotZXID,F_AllotZXName,F_ISAllot,F_AllotDate,F_FileID)");
strSql.Append(" values (");
strSql.Append("@F_Sheng,@F_Store,@F_Prodate,@F_Reciver,@F_License,@F_Brand,@F_Models,@F_CusName,@F_CusTelphone,@F_CusPhone,@F_RepType,@F_SurveyDate,@F_TScore,@F_RScore,@F_RingS,@F_WholeS,@F_TotalS,@F_Remark,@F_VisResult,@F_VisInfo,@F_VisIS,@F_RepItem,@F_TheTeam,@F_Elect,@F_Sheetmetal,@F_Paint,@F_RepUser,@F_WoNumber,@F_NewCus,@F_InputDate,@F_InputUserID,@F_InputUserName,@F_VisUserID,@F_VisUserName,@F_VisDate,@F_ISVis,@F_CallUserID,@F_CallUserName,@F_CallDate,@F_ISCall,@F_CallResID,@F_CallRes,@F_ISCallRes,@F_AllotUserID,@F_AllotUserName,@F_AllotZXID,@F_AllotZXName,@F_ISAllot,@F_AllotDate,@F_FileID)");
strSql.Append(";select @@IDENTITY");
SqlParameter[] parameters = {
new SqlParameter("@F_Sheng", SqlDbType.NVarChar,500),
new SqlParameter("@F_Store", SqlDbType.NVarChar,500),
new SqlParameter("@F_Prodate", SqlDbType.NVarChar,500),
new SqlParameter("@F_Reciver", SqlDbType.NVarChar,500),
new SqlParameter("@F_License", SqlDbType.NVarChar,500),
new SqlParameter("@F_Brand", SqlDbType.NVarChar,500),
new SqlParameter("@F_Models", SqlDbType.NVarChar,500),
new SqlParameter("@F_CusName", SqlDbType.NVarChar,500),
new SqlParameter("@F_CusTelphone", SqlDbType.NVarChar,500),
new SqlParameter("@F_CusPhone", SqlDbType.NVarChar,500),
new SqlParameter("@F_RepType", SqlDbType.NVarChar,500),
new SqlParameter("@F_SurveyDate", SqlDbType.NVarChar,500),
new SqlParameter("@F_TScore", SqlDbType.NVarChar,500),
new SqlParameter("@F_RScore", SqlDbType.NVarChar,500),
new SqlParameter("@F_RingS", SqlDbType.NVarChar,500),
new SqlParameter("@F_WholeS", SqlDbType.NVarChar,500),
new SqlParameter("@F_TotalS", SqlDbType.NVarChar,500),
new SqlParameter("@F_Remark", SqlDbType.NVarChar,500),
new SqlParameter("@F_VisResult", SqlDbType.NVarChar,500),
new SqlParameter("@F_VisInfo", SqlDbType.NText),
new SqlParameter("@F_VisIS", SqlDbType.NVarChar,50),
new SqlParameter("@F_RepItem", SqlDbType.NVarChar,500),
new SqlParameter("@F_TheTeam", SqlDbType.NVarChar,500),
new SqlParameter("@F_Elect", SqlDbType.NVarChar,500),
new SqlParameter("@F_Sheetmetal", SqlDbType.NVarChar,500),
new SqlParameter("@F_Paint", SqlDbType.NVarChar,500),
new SqlParameter("@F_RepUser", SqlDbType.NVarChar,500),
new SqlParameter("@F_WoNumber", SqlDbType.NVarChar,500),
new SqlParameter("@F_NewCus", SqlDbType.NVarChar,500),
new SqlParameter("@F_InputDate", SqlDbType.DateTime),
new SqlParameter("@F_InputUserID", SqlDbType.Int,4),
new SqlParameter("@F_InputUserName", SqlDbType.NVarChar,50),
new SqlParameter("@F_VisUserID", SqlDbType.Int,4),
new SqlParameter("@F_VisUserName", SqlDbType.NVarChar,50),
new SqlParameter("@F_VisDate", SqlDbType.DateTime),
new SqlParameter("@F_ISVis", SqlDbType.Bit,1),
new SqlParameter("@F_CallUserID", SqlDbType.Int,4),
new SqlParameter("@F_CallUserName", SqlDbType.NVarChar,50),
new SqlParameter("@F_CallDate", SqlDbType.DateTime),
new SqlParameter("@F_ISCall", SqlDbType.Bit,1),
new SqlParameter("@F_CallResID", SqlDbType.Int,4),
new SqlParameter("@F_CallRes", SqlDbType.NVarChar,50),
new SqlParameter("@F_ISCallRes", SqlDbType.Bit,1),
new SqlParameter("@F_AllotUserID", SqlDbType.Int,4),
new SqlParameter("@F_AllotUserName", SqlDbType.NVarChar,50),
new SqlParameter("@F_AllotZXID", SqlDbType.Int,4),
new SqlParameter("@F_AllotZXName", SqlDbType.NVarChar,50),
new SqlParameter("@F_ISAllot", SqlDbType.Bit,1),
new SqlParameter("@F_AllotDate", SqlDbType.DateTime),
new SqlParameter("@F_FileID", SqlDbType.Int,4)};
parameters[0].Value = model.F_Sheng;
parameters[1].Value = model.F_Store;
parameters[2].Value = model.F_Prodate;
parameters[3].Value = model.F_Reciver;
parameters[4].Value = model.F_License;
parameters[5].Value = model.F_Brand;
parameters[6].Value = model.F_Models;
parameters[7].Value = model.F_CusName;
parameters[8].Value = model.F_CusTelphone;
parameters[9].Value = model.F_CusPhone;
parameters[10].Value = model.F_RepType;
parameters[11].Value = model.F_SurveyDate;
parameters[12].Value = model.F_TScore;
parameters[13].Value = model.F_RScore;
parameters[14].Value = model.F_RingS;
parameters[15].Value = model.F_WholeS;
parameters[16].Value = model.F_TotalS;
parameters[17].Value = model.F_Remark;
parameters[18].Value = model.F_VisResult;
parameters[19].Value = model.F_VisInfo;
parameters[20].Value = model.F_VisIS;
parameters[21].Value = model.F_RepItem;
parameters[22].Value = model.F_TheTeam;
parameters[23].Value = model.F_Elect;
parameters[24].Value = model.F_Sheetmetal;
parameters[25].Value = model.F_Paint;
parameters[26].Value = model.F_RepUser;
parameters[27].Value = model.F_WoNumber;
parameters[28].Value = model.F_NewCus;
parameters[29].Value = model.F_InputDate;
parameters[30].Value = model.F_InputUserID;
parameters[31].Value = model.F_InputUserName;
parameters[32].Value = model.F_VisUserID;
parameters[33].Value = model.F_VisUserName;
parameters[34].Value = model.F_VisDate;
parameters[35].Value = model.F_ISVis;
parameters[36].Value = model.F_CallUserID;
parameters[37].Value = model.F_CallUserName;
parameters[38].Value = model.F_CallDate;
parameters[39].Value = model.F_ISCall;
parameters[40].Value = model.F_CallResID;
parameters[41].Value = model.F_CallRes;
parameters[42].Value = model.F_ISCallRes;
parameters[43].Value = model.F_AllotUserID;
parameters[44].Value = model.F_AllotUserName;
parameters[45].Value = model.F_AllotZXID;
parameters[46].Value = model.F_AllotZXName;
parameters[47].Value = model.F_ISAllot;
parameters[48].Value = model.F_AllotDate;
parameters[49].Value = model.F_FileID;
object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
if (obj == null)
{
return 0;
}
else
{
return Convert.ToInt32(obj);
}
}
///
/// 更新一条数据
///
public bool Update(CallCenterApi.Model.T_Vis_Telphone model)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("update T_Vis_Telphone set ");
strSql.Append("F_Sheng=@F_Sheng,");
strSql.Append("F_Store=@F_Store,");
strSql.Append("F_Prodate=@F_Prodate,");
strSql.Append("F_Reciver=@F_Reciver,");
strSql.Append("F_License=@F_License,");
strSql.Append("F_Brand=@F_Brand,");
strSql.Append("F_Models=@F_Models,");
strSql.Append("F_CusName=@F_CusName,");
strSql.Append("F_CusTelphone=@F_CusTelphone,");
strSql.Append("F_CusPhone=@F_CusPhone,");
strSql.Append("F_RepType=@F_RepType,");
strSql.Append("F_SurveyDate=@F_SurveyDate,");
strSql.Append("F_TScore=@F_TScore,");
strSql.Append("F_RScore=@F_RScore,");
strSql.Append("F_RingS=@F_RingS,");
strSql.Append("F_WholeS=@F_WholeS,");
strSql.Append("F_TotalS=@F_TotalS,");
strSql.Append("F_Remark=@F_Remark,");
strSql.Append("F_VisResult=@F_VisResult,");
strSql.Append("F_VisInfo=@F_VisInfo,");
strSql.Append("F_VisIS=@F_VisIS,");
strSql.Append("F_RepItem=@F_RepItem,");
strSql.Append("F_TheTeam=@F_TheTeam,");
strSql.Append("F_Elect=@F_Elect,");
strSql.Append("F_Sheetmetal=@F_Sheetmetal,");
strSql.Append("F_Paint=@F_Paint,");
strSql.Append("F_RepUser=@F_RepUser,");
strSql.Append("F_WoNumber=@F_WoNumber,");
strSql.Append("F_NewCus=@F_NewCus,");
strSql.Append("F_InputDate=@F_InputDate,");
strSql.Append("F_InputUserID=@F_InputUserID,");
strSql.Append("F_InputUserName=@F_InputUserName,");
strSql.Append("F_VisUserID=@F_VisUserID,");
strSql.Append("F_VisUserName=@F_VisUserName,");
strSql.Append("F_VisDate=@F_VisDate,");
strSql.Append("F_ISVis=@F_ISVis,");
strSql.Append("F_CallUserID=@F_CallUserID,");
strSql.Append("F_CallUserName=@F_CallUserName,");
strSql.Append("F_CallDate=@F_CallDate,");
strSql.Append("F_ISCall=@F_ISCall,");
strSql.Append("F_CallResID=@F_CallResID,");
strSql.Append("F_CallRes=@F_CallRes,");
strSql.Append("F_ISCallRes=@F_ISCallRes,");
strSql.Append("F_AllotUserID=@F_AllotUserID,");
strSql.Append("F_AllotUserName=@F_AllotUserName,");
strSql.Append("F_AllotZXID=@F_AllotZXID,");
strSql.Append("F_AllotZXName=@F_AllotZXName,");
strSql.Append("F_ISAllot=@F_ISAllot,");
strSql.Append("F_AllotDate=@F_AllotDate,");
strSql.Append("F_FileID=@F_FileID");
strSql.Append(" where F_TelID=@F_TelID");
SqlParameter[] parameters = {
new SqlParameter("@F_Sheng", SqlDbType.NVarChar,500),
new SqlParameter("@F_Store", SqlDbType.NVarChar,500),
new SqlParameter("@F_Prodate", SqlDbType.NVarChar,500),
new SqlParameter("@F_Reciver", SqlDbType.NVarChar,500),
new SqlParameter("@F_License", SqlDbType.NVarChar,500),
new SqlParameter("@F_Brand", SqlDbType.NVarChar,500),
new SqlParameter("@F_Models", SqlDbType.NVarChar,500),
new SqlParameter("@F_CusName", SqlDbType.NVarChar,500),
new SqlParameter("@F_CusTelphone", SqlDbType.NVarChar,500),
new SqlParameter("@F_CusPhone", SqlDbType.NVarChar,500),
new SqlParameter("@F_RepType", SqlDbType.NVarChar,500),
new SqlParameter("@F_SurveyDate", SqlDbType.NVarChar,500),
new SqlParameter("@F_TScore", SqlDbType.NVarChar,500),
new SqlParameter("@F_RScore", SqlDbType.NVarChar,500),
new SqlParameter("@F_RingS", SqlDbType.NVarChar,500),
new SqlParameter("@F_WholeS", SqlDbType.NVarChar,500),
new SqlParameter("@F_TotalS", SqlDbType.NVarChar,500),
new SqlParameter("@F_Remark", SqlDbType.NVarChar,500),
new SqlParameter("@F_VisResult", SqlDbType.NVarChar,500),
new SqlParameter("@F_VisInfo", SqlDbType.NText),
new SqlParameter("@F_VisIS", SqlDbType.NVarChar,50),
new SqlParameter("@F_RepItem", SqlDbType.NVarChar,500),
new SqlParameter("@F_TheTeam", SqlDbType.NVarChar,500),
new SqlParameter("@F_Elect", SqlDbType.NVarChar,500),
new SqlParameter("@F_Sheetmetal", SqlDbType.NVarChar,500),
new SqlParameter("@F_Paint", SqlDbType.NVarChar,500),
new SqlParameter("@F_RepUser", SqlDbType.NVarChar,500),
new SqlParameter("@F_WoNumber", SqlDbType.NVarChar,500),
new SqlParameter("@F_NewCus", SqlDbType.NVarChar,500),
new SqlParameter("@F_InputDate", SqlDbType.DateTime),
new SqlParameter("@F_InputUserID", SqlDbType.Int,4),
new SqlParameter("@F_InputUserName", SqlDbType.NVarChar,50),
new SqlParameter("@F_VisUserID", SqlDbType.Int,4),
new SqlParameter("@F_VisUserName", SqlDbType.NVarChar,50),
new SqlParameter("@F_VisDate", SqlDbType.DateTime),
new SqlParameter("@F_ISVis", SqlDbType.Bit,1),
new SqlParameter("@F_CallUserID", SqlDbType.Int,4),
new SqlParameter("@F_CallUserName", SqlDbType.NVarChar,50),
new SqlParameter("@F_CallDate", SqlDbType.DateTime),
new SqlParameter("@F_ISCall", SqlDbType.Bit,1),
new SqlParameter("@F_CallResID", SqlDbType.Int,4),
new SqlParameter("@F_CallRes", SqlDbType.NVarChar,50),
new SqlParameter("@F_ISCallRes", SqlDbType.Bit,1),
new SqlParameter("@F_AllotUserID", SqlDbType.Int,4),
new SqlParameter("@F_AllotUserName", SqlDbType.NVarChar,50),
new SqlParameter("@F_AllotZXID", SqlDbType.Int,4),
new SqlParameter("@F_AllotZXName", SqlDbType.NVarChar,50),
new SqlParameter("@F_ISAllot", SqlDbType.Bit,1),
new SqlParameter("@F_AllotDate", SqlDbType.DateTime),
new SqlParameter("@F_FileID", SqlDbType.Int,4),
new SqlParameter("@F_TelID", SqlDbType.Int,4)};
parameters[0].Value = model.F_Sheng;
parameters[1].Value = model.F_Store;
parameters[2].Value = model.F_Prodate;
parameters[3].Value = model.F_Reciver;
parameters[4].Value = model.F_License;
parameters[5].Value = model.F_Brand;
parameters[6].Value = model.F_Models;
parameters[7].Value = model.F_CusName;
parameters[8].Value = model.F_CusTelphone;
parameters[9].Value = model.F_CusPhone;
parameters[10].Value = model.F_RepType;
parameters[11].Value = model.F_SurveyDate;
parameters[12].Value = model.F_TScore;
parameters[13].Value = model.F_RScore;
parameters[14].Value = model.F_RingS;
parameters[15].Value = model.F_WholeS;
parameters[16].Value = model.F_TotalS;
parameters[17].Value = model.F_Remark;
parameters[18].Value = model.F_VisResult;
parameters[19].Value = model.F_VisInfo;
parameters[20].Value = model.F_VisIS;
parameters[21].Value = model.F_RepItem;
parameters[22].Value = model.F_TheTeam;
parameters[23].Value = model.F_Elect;
parameters[24].Value = model.F_Sheetmetal;
parameters[25].Value = model.F_Paint;
parameters[26].Value = model.F_RepUser;
parameters[27].Value = model.F_WoNumber;
parameters[28].Value = model.F_NewCus;
parameters[29].Value = model.F_InputDate;
parameters[30].Value = model.F_InputUserID;
parameters[31].Value = model.F_InputUserName;
parameters[32].Value = model.F_VisUserID;
parameters[33].Value = model.F_VisUserName;
parameters[34].Value = model.F_VisDate;
parameters[35].Value = model.F_ISVis;
parameters[36].Value = model.F_CallUserID;
parameters[37].Value = model.F_CallUserName;
parameters[38].Value = model.F_CallDate;
parameters[39].Value = model.F_ISCall;
parameters[40].Value = model.F_CallResID;
parameters[41].Value = model.F_CallRes;
parameters[42].Value = model.F_ISCallRes;
parameters[43].Value = model.F_AllotUserID;
parameters[44].Value = model.F_AllotUserName;
parameters[45].Value = model.F_AllotZXID;
parameters[46].Value = model.F_AllotZXName;
parameters[47].Value = model.F_ISAllot;
parameters[48].Value = model.F_AllotDate;
parameters[49].Value = model.F_FileID;
parameters[50].Value = model.F_TelID;
int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
if (rows > 0)
{
return true;
}
else
{
return false;
}
}
///
/// 删除一条数据
///
public bool Delete(int F_TelID)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("delete from T_Vis_Telphone ");
strSql.Append(" where F_TelID=@F_TelID");
SqlParameter[] parameters = {
new SqlParameter("@F_TelID", SqlDbType.Int,4)
};
parameters[0].Value = F_TelID;
int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
if (rows > 0)
{
return true;
}
else
{
return false;
}
}
///
/// 批量删除数据
///
public bool DeleteList(string F_TelIDlist)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("delete from T_Vis_Telphone ");
strSql.Append(" where F_TelID in (" + F_TelIDlist + ") ");
int rows = DbHelperSQL.ExecuteSql(strSql.ToString());
if (rows > 0)
{
return true;
}
else
{
return false;
}
}
///
/// 得到一个对象实体
///
public CallCenterApi.Model.T_Vis_Telphone GetModel(int F_TelID)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select top 1 F_TelID,F_Sheng,F_Store,F_Prodate,F_Reciver,F_License,F_Brand,F_Models,F_CusName,F_CusTelphone,F_CusPhone,F_RepType,F_SurveyDate,F_TScore,F_RScore,F_RingS,F_WholeS,F_TotalS,F_Remark,F_VisResult,F_VisInfo,F_VisIS,F_RepItem,F_TheTeam,F_Elect,F_Sheetmetal,F_Paint,F_RepUser,F_WoNumber,F_NewCus,F_InputDate,F_InputUserID,F_InputUserName,F_VisUserID,F_VisUserName,F_VisDate,F_ISVis,F_CallUserID,F_CallUserName,F_CallDate,F_ISCall,F_CallResID,F_CallRes,F_ISCallRes,F_AllotUserID,F_AllotUserName,F_AllotZXID,F_AllotZXName,F_ISAllot,F_AllotDate,F_FileID from T_Vis_Telphone ");
strSql.Append(" where F_TelID=@F_TelID");
SqlParameter[] parameters = {
new SqlParameter("@F_TelID", SqlDbType.Int,4)
};
parameters[0].Value = F_TelID;
CallCenterApi.Model.T_Vis_Telphone model = new CallCenterApi.Model.T_Vis_Telphone();
DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
if (ds.Tables[0].Rows.Count > 0)
{
return DataRowToModel(ds.Tables[0].Rows[0]);
}
else
{
return null;
}
}
///
/// 得到一个对象实体
///
public CallCenterApi.Model.T_Vis_Telphone DataRowToModel(DataRow row)
{
CallCenterApi.Model.T_Vis_Telphone model = new CallCenterApi.Model.T_Vis_Telphone();
if (row != null)
{
if (row["F_TelID"] != null && row["F_TelID"].ToString() != "")
{
model.F_TelID = int.Parse(row["F_TelID"].ToString());
}
if (row["F_Sheng"] != null)
{
model.F_Sheng = row["F_Sheng"].ToString();
}
if (row["F_Store"] != null)
{
model.F_Store = row["F_Store"].ToString();
}
if (row["F_Prodate"] != null)
{
model.F_Prodate = row["F_Prodate"].ToString();
}
if (row["F_Reciver"] != null)
{
model.F_Reciver = row["F_Reciver"].ToString();
}
if (row["F_License"] != null)
{
model.F_License = row["F_License"].ToString();
}
if (row["F_Brand"] != null)
{
model.F_Brand = row["F_Brand"].ToString();
}
if (row["F_Models"] != null)
{
model.F_Models = row["F_Models"].ToString();
}
if (row["F_CusName"] != null)
{
model.F_CusName = row["F_CusName"].ToString();
}
if (row["F_CusTelphone"] != null)
{
model.F_CusTelphone = row["F_CusTelphone"].ToString();
}
if (row["F_CusPhone"] != null)
{
model.F_CusPhone = row["F_CusPhone"].ToString();
}
if (row["F_RepType"] != null)
{
model.F_RepType = row["F_RepType"].ToString();
}
if (row["F_SurveyDate"] != null)
{
model.F_SurveyDate = row["F_SurveyDate"].ToString();
}
if (row["F_TScore"] != null)
{
model.F_TScore = row["F_TScore"].ToString();
}
if (row["F_RScore"] != null)
{
model.F_RScore = row["F_RScore"].ToString();
}
if (row["F_RingS"] != null)
{
model.F_RingS = row["F_RingS"].ToString();
}
if (row["F_WholeS"] != null)
{
model.F_WholeS = row["F_WholeS"].ToString();
}
if (row["F_TotalS"] != null)
{
model.F_TotalS = row["F_TotalS"].ToString();
}
if (row["F_Remark"] != null)
{
model.F_Remark = row["F_Remark"].ToString();
}
if (row["F_VisResult"] != null)
{
model.F_VisResult = row["F_VisResult"].ToString();
}
if (row["F_VisInfo"] != null)
{
model.F_VisInfo = row["F_VisInfo"].ToString();
}
if (row["F_VisIS"] != null)
{
model.F_VisIS = row["F_VisIS"].ToString();
}
if (row["F_RepItem"] != null)
{
model.F_RepItem = row["F_RepItem"].ToString();
}
if (row["F_TheTeam"] != null)
{
model.F_TheTeam = row["F_TheTeam"].ToString();
}
if (row["F_Elect"] != null)
{
model.F_Elect = row["F_Elect"].ToString();
}
if (row["F_Sheetmetal"] != null)
{
model.F_Sheetmetal = row["F_Sheetmetal"].ToString();
}
if (row["F_Paint"] != null)
{
model.F_Paint = row["F_Paint"].ToString();
}
if (row["F_RepUser"] != null)
{
model.F_RepUser = row["F_RepUser"].ToString();
}
if (row["F_WoNumber"] != null)
{
model.F_WoNumber = row["F_WoNumber"].ToString();
}
if (row["F_NewCus"] != null)
{
model.F_NewCus = row["F_NewCus"].ToString();
}
if (row["F_InputDate"] != null && row["F_InputDate"].ToString() != "")
{
model.F_InputDate = DateTime.Parse(row["F_InputDate"].ToString());
}
if (row["F_InputUserID"] != null && row["F_InputUserID"].ToString() != "")
{
model.F_InputUserID = int.Parse(row["F_InputUserID"].ToString());
}
if (row["F_InputUserName"] != null)
{
model.F_InputUserName = row["F_InputUserName"].ToString();
}
if (row["F_VisUserID"] != null && row["F_VisUserID"].ToString() != "")
{
model.F_VisUserID = int.Parse(row["F_VisUserID"].ToString());
}
if (row["F_VisUserName"] != null)
{
model.F_VisUserName = row["F_VisUserName"].ToString();
}
if (row["F_VisDate"] != null && row["F_VisDate"].ToString() != "")
{
model.F_VisDate = DateTime.Parse(row["F_VisDate"].ToString());
}
if (row["F_ISVis"] != null && row["F_ISVis"].ToString() != "")
{
if ((row["F_ISVis"].ToString() == "1") || (row["F_ISVis"].ToString().ToLower() == "true"))
{
model.F_ISVis = true;
}
else
{
model.F_ISVis = false;
}
}
if (row["F_CallUserID"] != null && row["F_CallUserID"].ToString() != "")
{
model.F_CallUserID = int.Parse(row["F_CallUserID"].ToString());
}
if (row["F_CallUserName"] != null)
{
model.F_CallUserName = row["F_CallUserName"].ToString();
}
if (row["F_CallDate"] != null && row["F_CallDate"].ToString() != "")
{
model.F_CallDate = DateTime.Parse(row["F_CallDate"].ToString());
}
if (row["F_ISCall"] != null && row["F_ISCall"].ToString() != "")
{
if ((row["F_ISCall"].ToString() == "1") || (row["F_ISCall"].ToString().ToLower() == "true"))
{
model.F_ISCall = true;
}
else
{
model.F_ISCall = false;
}
}
if (row["F_CallResID"] != null && row["F_CallResID"].ToString() != "")
{
model.F_CallResID = int.Parse(row["F_CallResID"].ToString());
}
if (row["F_CallRes"] != null)
{
model.F_CallRes = row["F_CallRes"].ToString();
}
if (row["F_ISCallRes"] != null && row["F_ISCallRes"].ToString() != "")
{
if ((row["F_ISCallRes"].ToString() == "1") || (row["F_ISCallRes"].ToString().ToLower() == "true"))
{
model.F_ISCallRes = true;
}
else
{
model.F_ISCallRes = false;
}
}
if (row["F_AllotUserID"] != null && row["F_AllotUserID"].ToString() != "")
{
model.F_AllotUserID = int.Parse(row["F_AllotUserID"].ToString());
}
if (row["F_AllotUserName"] != null)
{
model.F_AllotUserName = row["F_AllotUserName"].ToString();
}
if (row["F_AllotZXID"] != null && row["F_AllotZXID"].ToString() != "")
{
model.F_AllotZXID = int.Parse(row["F_AllotZXID"].ToString());
}
if (row["F_AllotZXName"] != null)
{
model.F_AllotZXName = row["F_AllotZXName"].ToString();
}
if (row["F_ISAllot"] != null && row["F_ISAllot"].ToString() != "")
{
if ((row["F_ISAllot"].ToString() == "1") || (row["F_ISAllot"].ToString().ToLower() == "true"))
{
model.F_ISAllot = true;
}
else
{
model.F_ISAllot = false;
}
}
if (row["F_AllotDate"] != null && row["F_AllotDate"].ToString() != "")
{
model.F_AllotDate = DateTime.Parse(row["F_AllotDate"].ToString());
}
if (row["F_FileID"] != null && row["F_FileID"].ToString() != "")
{
model.F_FileID = int.Parse(row["F_FileID"].ToString());
}
}
return model;
}
///
/// 获得数据列表
///
public DataSet GetList(string strWhere)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select F_TelID,F_Sheng,F_Store,F_Prodate,F_Reciver,F_License,F_Brand,F_Models,F_CusName,F_CusTelphone,F_CusPhone,F_RepType,F_SurveyDate,F_TScore,F_RScore,F_RingS,F_WholeS,F_TotalS,F_Remark,F_VisResult,F_VisInfo,F_VisIS,F_RepItem,F_TheTeam,F_Elect,F_Sheetmetal,F_Paint,F_RepUser,F_WoNumber,F_NewCus,F_InputDate,F_InputUserID,F_InputUserName,F_VisUserID,F_VisUserName,F_VisDate,F_ISVis,F_CallUserID,F_CallUserName,F_CallDate,F_ISCall,F_CallResID,F_CallRes,F_ISCallRes,F_AllotUserID,F_AllotUserName,F_AllotZXID,F_AllotZXName,F_ISAllot,F_AllotDate,F_FileID ");
strSql.Append(" FROM T_Vis_Telphone ");
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(" F_TelID,F_Sheng,F_Store,F_Prodate,F_Reciver,F_License,F_Brand,F_Models,F_CusName,F_CusTelphone,F_CusPhone,F_RepType,F_SurveyDate,F_TScore,F_RScore,F_RingS,F_WholeS,F_TotalS,F_Remark,F_VisResult,F_VisInfo,F_VisIS,F_RepItem,F_TheTeam,F_Elect,F_Sheetmetal,F_Paint,F_RepUser,F_WoNumber,F_NewCus,F_InputDate,F_InputUserID,F_InputUserName,F_VisUserID,F_VisUserName,F_VisDate,F_ISVis,F_CallUserID,F_CallUserName,F_CallDate,F_ISCall,F_CallResID,F_CallRes,F_ISCallRes,F_AllotUserID,F_AllotUserName,F_AllotZXID,F_AllotZXName,F_ISAllot,F_AllotDate,F_FileID ");
strSql.Append(" FROM T_Vis_Telphone ");
if (strWhere.Trim() != "")
{
strSql.Append(" where " + strWhere);
}
strSql.Append(" order by " + filedOrder);
return DbHelperSQL.Query(strSql.ToString());
}
///
/// 获取记录总数
///
public int GetRecordCount(string strWhere)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select count(1) FROM T_Vis_Telphone ");
if (strWhere.Trim() != "")
{
strSql.Append(" where " + strWhere);
}
object obj = DbHelperSQL.GetSingle(strSql.ToString());
if (obj == null)
{
return 0;
}
else
{
return Convert.ToInt32(obj);
}
}
///
/// 分页获取数据列表
///
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_TelID desc");
}
strSql.Append(")AS Row, T.* from T_Vis_Telphone 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 BasicMethod
#region ExtensionMethod
///
/// 分配更新
///
///
public bool UpdateFP(int telid, int fpid, int zxid, string zxname, string fpname)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("update T_Vis_Telphone set ");
strSql.Append("F_ISAllot=1,");
strSql.Append("F_AllotDate=GetDate(),");
strSql.Append("F_AllotUserID=@F_AllotUserID,");
strSql.Append("F_AllotZXID=@F_AllotZXID,");
strSql.Append("F_AllotZXName=@F_AllotZXName,");
strSql.Append("F_AllotUserName=@F_AllotUserName");
strSql.Append(" where F_TelID=@F_TelID");
SqlParameter[] parameters = {
new SqlParameter("@F_AllotUserID", SqlDbType.Int,4),
new SqlParameter("@F_AllotZXID", SqlDbType.Int,4),
new SqlParameter("@F_AllotZXName", SqlDbType.VarChar,50),
new SqlParameter("@F_AllotUserName", SqlDbType.VarChar,50),
new SqlParameter("@F_TelID", SqlDbType.Int,4)};
parameters[0].Value = fpid;
parameters[1].Value = zxid;
parameters[2].Value = zxname;
parameters[3].Value = fpname;
parameters[4].Value = telid;
int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
if (rows > 0)
{
return true;
}
else
{
return false;
}
}
///
/// 呼叫状态更新
///
///
public bool UpdateHJ(int telid, int uid, string uname, int resid, string res)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("update T_Vis_Telphone set ");
strSql.Append("F_ISCall=1,");
strSql.Append("F_CallResID=@F_CallResID,");
strSql.Append("F_CallRes=@F_CallRes,");
strSql.Append("F_CallDate=GetDate(),");
strSql.Append("F_CallUserName=@F_CallUserName,");
strSql.Append("F_CallUserID=@F_CallUserID");
strSql.Append(" where F_TelID=@F_TelID");
SqlParameter[] parameters = {
new SqlParameter("@F_CallResID", SqlDbType.Int,4),
new SqlParameter("@F_CallRes", SqlDbType.VarChar,50),
new SqlParameter("@F_CallUserName", SqlDbType.VarChar,50),
new SqlParameter("@F_CallUserID", SqlDbType.Int,4),
new SqlParameter("@F_TelID", SqlDbType.Int,4)};
parameters[0].Value = resid;
parameters[1].Value = res;
parameters[2].Value = uname;
parameters[3].Value = uid;
parameters[4].Value = telid;
int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
if (rows > 0)
{
return true;
}
else
{
return false;
}
}
///
/// 回访更新
///
///
public bool UpdateHF(int telid, bool isvis, bool isres, int resid, string res, int uid, string uname,
string tscore, string rscore, string rings, string wholes, string totals, string remark,
string visresult, string visinfo, string visis)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("update T_Vis_Telphone set ");
strSql.Append("F_SurveyDate=@F_SurveyDate,");
strSql.Append("F_TScore=@F_TScore,");
strSql.Append("F_RScore=@F_RScore,");
strSql.Append("F_RingS=@F_RingS,");
strSql.Append("F_WholeS=@F_WholeS,");
strSql.Append("F_TotalS=@F_TotalS,");
strSql.Append("F_Remark=@F_Remark,");
strSql.Append("F_VisResult=@F_VisResult,");
strSql.Append("F_VisInfo=@F_VisInfo,");
strSql.Append("F_VisIS=@F_VisIS,");
strSql.Append("F_ISVis=@F_ISVis,");
strSql.Append("F_ISCallRes=@F_ISCallRes,");
strSql.Append("F_CallResID=@F_CallResID,");
strSql.Append("F_CallRes=@F_CallRes,");
strSql.Append("F_VisDate=GetDate(),");
strSql.Append("F_VisUserName=@F_VisUserName,");
strSql.Append("F_VisUserID=@F_VisUserID");
strSql.Append(" where F_TelID=@F_TelID");
SqlParameter[] parameters = {
new SqlParameter("@F_SurveyDate", SqlDbType.VarChar,50),
new SqlParameter("@F_TScore", SqlDbType.VarChar,50),
new SqlParameter("@F_RScore", SqlDbType.VarChar,50),
new SqlParameter("@F_RingS", SqlDbType.VarChar,50),
new SqlParameter("@F_WholeS", SqlDbType.VarChar,50),
new SqlParameter("@F_TotalS", SqlDbType.VarChar,50),
new SqlParameter("@F_Remark", SqlDbType.VarChar,50),
new SqlParameter("@F_VisResult", SqlDbType.VarChar,50),
new SqlParameter("@F_VisInfo", SqlDbType.VarChar,50),
new SqlParameter("@F_VisIS", SqlDbType.VarChar,50),
new SqlParameter("@F_ISVis", SqlDbType.Bit),
new SqlParameter("@F_ISCallRes", SqlDbType.Bit),
new SqlParameter("@F_CallResID", SqlDbType.Int,4),
new SqlParameter("@F_CallRes", SqlDbType.VarChar,50),
new SqlParameter("@F_VisUserName", SqlDbType.VarChar,50),
new SqlParameter("@F_VisUserID", SqlDbType.Int,4),
new SqlParameter("@F_TelID", SqlDbType.Int,4)};
parameters[0].Value = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
parameters[1].Value = tscore;
parameters[2].Value = rscore;
parameters[3].Value = rings;
parameters[4].Value = wholes;
parameters[5].Value = totals;
parameters[6].Value = remark;
parameters[7].Value = visresult;
parameters[8].Value = visinfo;
parameters[9].Value = visis;
parameters[10].Value = isvis;
parameters[11].Value = isres;
parameters[12].Value = resid;
parameters[13].Value = res;
parameters[14].Value = uname;
parameters[15].Value = uid;
parameters[16].Value = telid;
int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
if (rows > 0)
{
return true;
}
else
{
return false;
}
}
public bool UpdateBZ(int telid, string tscore)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("update T_Vis_TelBZ set ");
strSql.Append("F_Score=@F_Score");
strSql.Append(" where F_TelID=@F_TelID");
SqlParameter[] parameters = {
new SqlParameter("@F_Score", SqlDbType.VarChar,50),
new SqlParameter("@F_TelID", SqlDbType.Int,4)};
parameters[0].Value = tscore;
parameters[1].Value = telid;
int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
if (rows > 0)
{
return true;
}
else
{
return false;
}
}
///
/// 获取店面数
///
public DataSet GetListDQ(string strWhere)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select F_Sheng,F_Store,count(1) as c ");
strSql.Append(" FROM T_Vis_Telphone ");
if (strWhere.Trim() != "")
{
strSql.Append(" where " + strWhere);
}
strSql.Append(" group by F_Sheng,F_Store");
return DbHelperSQL.Query(strSql.ToString());
}
public DataSet GetListDQYX(string strWhere)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select F_Sheng, F_Store, COUNT(1) yscont, sum(CAST(F_TotalS as float)) totals ");
strSql.Append(" FROM T_Vis_Telphone ");
if (strWhere.Trim() != "")
{
strSql.Append(" where F_ISVis = 1" + strWhere);
}
strSql.Append(" group by F_Sheng,F_Store");
return DbHelperSQL.Query(strSql.ToString());
}
///
/// 获取服务人员
///
public DataSet GetListGW(string strWhere)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select F_Reciver,count(1) as c ");
strSql.Append(" FROM T_Vis_Telphone ");
if (strWhere.Trim() != "")
{
strSql.Append(" where " + strWhere);
}
strSql.Append(" group by F_Reciver");
return DbHelperSQL.Query(strSql.ToString());
}
public DataSet GetListGWYX(string strWhere)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select F_Reciver, COUNT(1) yscont, sum(CAST(F_TotalS as float)) totals ");
strSql.Append(" FROM T_Vis_Telphone ");
if (strWhere.Trim() != "")
{
strSql.Append(" where F_ISVis = 1" + strWhere);
}
strSql.Append(" group by F_Reciver ");
return DbHelperSQL.Query(strSql.ToString());
}
///
/// 获取班组
///
public DataSet GetListBZ(string strWhere)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select F_Sheng, F_Store, F_Leader,count(1) as c ");
strSql.Append(" FROM T_Vis_TelBZ ");
if (strWhere.Trim() != "")
{
strSql.Append(" where " + strWhere);
}
strSql.Append(" group by F_Sheng, F_Store, F_Leader");
return DbHelperSQL.Query(strSql.ToString());
}
public DataSet GetListBZYX(string strWhere)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select F_Sheng, F_Store, F_Leader, COUNT(1) yscont, sum(CAST(F_Score as float)) totals ");
strSql.Append(" FROM T_Vis_TelBZ ");
if (strWhere.Trim() != "")
{
strSql.Append(" where " + strWhere);
}
strSql.Append(" group by F_Sheng, F_Store, F_Leader");
return DbHelperSQL.Query(strSql.ToString());
}
public DataSet GetListExpt(string strWhere)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select ");
strSql.Append("F_Sheng,F_Store,F_Prodate,F_CusName,F_License,F_Brand,F_Models,F_Reciver,F_CusTelphone,");
strSql.Append("F_CusPhone,F_RepType,F_SurveyDate,F_TScore,F_RScore,F_RingS,F_WholeS,F_TotalS");
strSql.Append(",F_Remark,F_VisResult,F_VisInfo,F_VisIS,F_RepItem,F_TheTeam,F_Elect,F_Sheetmetal");
strSql.Append(",F_Paint,F_RepUser,F_WoNumber,F_NewCus,F_AllotZXName,F_InputDate,F_CallDate,F_VisDate");
strSql.Append(",case F_ISCall when 1 then '已呼叫' else '未呼叫' end F_CallState,");
strSql.Append(" case F_ISCallRes when 1 then '已接通' else '未接通' end F_CallResState, F_CallRes,");
strSql.Append(" case F_ISVis when 1 then '已回访' else '未回访' end F_ISVisState");
strSql.Append(" FROM T_Vis_Telphone ");
if (strWhere.Trim() != "")
{
strSql.Append(" where " + strWhere);
}
return DbHelperSQL.Query(strSql.ToString());
}
///
/// 根据文件删除
///
public bool DeleteListByFileID(string FileID)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("delete from T_Vis_Telphone ");
strSql.Append(" where F_Fileid =" + FileID + " ");
int rows = DbHelperSQL.ExecuteSql(strSql.ToString());
if (rows > 0)
{
return true;
}
else
{
return false;
}
}
#endregion ExtensionMethod
}
}