/** 版本信息模板在安装目录下,可自行修改。
* T_Cus_CustomerBase.cs
*
* 功 能: N/A
* 类 名: T_Cus_CustomerBase
*
* Ver 变更日期 负责人 变更内容
* ───────────────────────────────────
* V0.01 2015/2/27 16:05:58 N/A 初版
*
* Copyright (c) 2012 Maticsoft Corporation. All rights reserved.
*┌──────────────────────────────────┐
*│ 此技术信息为本公司机密信息,未经本公司书面同意禁止向第三方披露. │
*│ 版权所有:动软卓越(北京)科技有限公司 │
*└──────────────────────────────────┘
*/
using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using YTSoft.DBUtility;//Please add references
namespace YTSoft.BaseCallCenter.DAL
{
///
/// 数据访问类:T_Cus_CustomerBase
///
public partial class T_Cus_CustomerBase
{
public T_Cus_CustomerBase()
{ }
#region BasicMethod
///
/// 得到最大ID
///
public int GetMaxId()
{
return DbHelperSQL.GetMaxID("F_CustomerId", "T_Cus_CustomerBase");
}
///
/// 是否存在该记录
///
public bool Exists(int F_CustomerId)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select count(1) from T_Cus_CustomerBase");
strSql.Append(" where F_CustomerId=@F_CustomerId");
SqlParameter[] parameters = {
new SqlParameter("@F_CustomerId", SqlDbType.Int,4)
};
parameters[0].Value = F_CustomerId;
return DbHelperSQL.Exists(strSql.ToString(), parameters);
}
///
/// 增加一条数据
///
public int Add(YTSoft.BaseCallCenter.Model.T_Cus_CustomerBase model)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("insert into T_Cus_CustomerBase(");
strSql.Append("F_CustomerName,F_CustomerCode,F_CustomerEName,F_CustomerPym,F_Layer,F_CustomerLayer,F_CategoryId,F_TradeId,F_RegionId,F_IndustryId,F_Address,F_Url,F_Telephone,F_Mobile,F_Fax,F_Email,F_Website,F_PostCode,F_ScaleResume,F_BusinessProfile,F_BusinessLicenseID,F_TaxID,F_OpeningBank,F_BankAccount,F_LegalRepresentative,F_LegalRepresentativeCardID,F_Nature,F_Kind,F_CustomerType,F_MainProduct,F_CustomerFrom,F_TrackInfo,F_TrackState,F_ImportDegree,F_IntentProduct,F_CreateBy,F_CreatedOn,F_ModifyBy,F_ModifiedOn,F_DeleteFlag,F_StatusCode,F_ServiceDept,F_ChargeName,F_ChargeTelephone,F_Province,F_ProductLine,F_ChargeDept,F_AfterSaleName,F_CustomerNature,F_CustomerClass,F_CustomerIndustry,F_RelationShipClass,F_CurrentVersion,F_SystemStartTime,F_QualityGuaranteeEndTime,F_AfterSaleTelephone,F_Notes,F_SystemType,F_City,F_CustomerStatus,F_DeviceCount,F_MaintenanceType,F_ERPCustomerCode,F_ServiceDeptID,F_ProductLineID,F_AfterSaleNameID,F_CustomerNatureID,F_CustomerClassID,F_RelationShipClassID,F_CityID)");
strSql.Append(" values (");
strSql.Append("@F_CustomerName,@F_CustomerCode,@F_CustomerEName,@F_CustomerPym,@F_Layer,@F_CustomerLayer,@F_CategoryId,@F_TradeId,@F_RegionId,@F_IndustryId,@F_Address,@F_Url,@F_Telephone,@F_Mobile,@F_Fax,@F_Email,@F_Website,@F_PostCode,@F_ScaleResume,@F_BusinessProfile,@F_BusinessLicenseID,@F_TaxID,@F_OpeningBank,@F_BankAccount,@F_LegalRepresentative,@F_LegalRepresentativeCardID,@F_Nature,@F_Kind,@F_CustomerType,@F_MainProduct,@F_CustomerFrom,@F_TrackInfo,@F_TrackState,@F_ImportDegree,@F_IntentProduct,@F_CreateBy,@F_CreatedOn,@F_ModifyBy,@F_ModifiedOn,@F_DeleteFlag,@F_StatusCode,@F_ServiceDept,@F_ChargeName,@F_ChargeTelephone,@F_Province,@F_ProductLine,@F_ChargeDept,@F_AfterSaleName,@F_CustomerNature,@F_CustomerClass,@F_CustomerIndustry,@F_RelationShipClass,@F_CurrentVersion,@F_SystemStartTime,@F_QualityGuaranteeEndTime,@F_AfterSaleTelephone,@F_Notes,@F_SystemType,@F_City,@F_CustomerStatus,@F_DeviceCount,@F_MaintenanceType,@F_ERPCustomerCode,@F_ServiceDeptID,@F_ProductLineID,@F_AfterSaleNameID,@F_CustomerNatureID,@F_CustomerClassID,@F_RelationShipClassID,@F_CityID)");
strSql.Append(";select @@IDENTITY");
SqlParameter[] parameters = {
new SqlParameter("@F_CustomerName", SqlDbType.NVarChar,200),
new SqlParameter("@F_CustomerCode", SqlDbType.VarChar,100),
new SqlParameter("@F_CustomerEName", SqlDbType.NVarChar,800),
new SqlParameter("@F_CustomerPym", SqlDbType.NVarChar,50),
new SqlParameter("@F_Layer", SqlDbType.SmallInt,2),
new SqlParameter("@F_CustomerLayer", SqlDbType.NVarChar,50),
new SqlParameter("@F_CategoryId", SqlDbType.Int,4),
new SqlParameter("@F_TradeId", SqlDbType.Int,4),
new SqlParameter("@F_RegionId", SqlDbType.Int,4),
new SqlParameter("@F_IndustryId", SqlDbType.Int,4),
new SqlParameter("@F_Address", SqlDbType.NVarChar,300),
new SqlParameter("@F_Url", SqlDbType.NVarChar,200),
new SqlParameter("@F_Telephone", SqlDbType.NVarChar,200),
new SqlParameter("@F_Mobile", SqlDbType.NVarChar,200),
new SqlParameter("@F_Fax", SqlDbType.NVarChar,200),
new SqlParameter("@F_Email", SqlDbType.VarChar,200),
new SqlParameter("@F_Website", SqlDbType.VarChar,200),
new SqlParameter("@F_PostCode", SqlDbType.NVarChar,50),
new SqlParameter("@F_ScaleResume", SqlDbType.NVarChar,2000),
new SqlParameter("@F_BusinessProfile", SqlDbType.NVarChar,2000),
new SqlParameter("@F_BusinessLicenseID", SqlDbType.VarChar,80),
new SqlParameter("@F_TaxID", SqlDbType.VarChar,80),
new SqlParameter("@F_OpeningBank", SqlDbType.NVarChar,100),
new SqlParameter("@F_BankAccount", SqlDbType.VarChar,80),
new SqlParameter("@F_LegalRepresentative", SqlDbType.VarChar,50),
new SqlParameter("@F_LegalRepresentativeCardID", SqlDbType.VarChar,30),
new SqlParameter("@F_Nature", SqlDbType.NVarChar,80),
new SqlParameter("@F_Kind", SqlDbType.NVarChar,80),
new SqlParameter("@F_CustomerType", SqlDbType.Int,4),
new SqlParameter("@F_MainProduct", SqlDbType.Text),
new SqlParameter("@F_CustomerFrom", SqlDbType.NVarChar,200),
new SqlParameter("@F_TrackInfo", SqlDbType.NVarChar,200),
new SqlParameter("@F_TrackState", SqlDbType.NVarChar,50),
new SqlParameter("@F_ImportDegree", SqlDbType.NVarChar,50),
new SqlParameter("@F_IntentProduct", SqlDbType.Text),
new SqlParameter("@F_CreateBy", SqlDbType.Int,4),
new SqlParameter("@F_CreatedOn", SqlDbType.DateTime),
new SqlParameter("@F_ModifyBy", SqlDbType.Int,4),
new SqlParameter("@F_ModifiedOn", SqlDbType.DateTime),
new SqlParameter("@F_DeleteFlag", SqlDbType.SmallInt,2),
new SqlParameter("@F_StatusCode", SqlDbType.SmallInt,2),
new SqlParameter("@F_ServiceDept", SqlDbType.NVarChar,20),
new SqlParameter("@F_ChargeName", SqlDbType.NVarChar,20),
new SqlParameter("@F_ChargeTelephone", SqlDbType.VarChar,15),
new SqlParameter("@F_Province", SqlDbType.NVarChar,20),
new SqlParameter("@F_ProductLine", SqlDbType.NVarChar,50),
new SqlParameter("@F_ChargeDept", SqlDbType.NVarChar,20),
new SqlParameter("@F_AfterSaleName", SqlDbType.NVarChar,20),
new SqlParameter("@F_CustomerNature", SqlDbType.NVarChar,20),
new SqlParameter("@F_CustomerClass", SqlDbType.NVarChar,10),
new SqlParameter("@F_CustomerIndustry", SqlDbType.NVarChar,10),
new SqlParameter("@F_RelationShipClass", SqlDbType.NVarChar,10),
new SqlParameter("@F_CurrentVersion", SqlDbType.VarChar,100),
new SqlParameter("@F_SystemStartTime", SqlDbType.DateTime),
new SqlParameter("@F_QualityGuaranteeEndTime", SqlDbType.DateTime),
new SqlParameter("@F_AfterSaleTelephone", SqlDbType.VarChar,15),
new SqlParameter("@F_Notes", SqlDbType.NVarChar,500),
new SqlParameter("@F_SystemType", SqlDbType.NVarChar,100),
new SqlParameter("@F_City", SqlDbType.NVarChar,10),
new SqlParameter("@F_CustomerStatus", SqlDbType.NVarChar,10),
new SqlParameter("@F_DeviceCount", SqlDbType.Int,4),
new SqlParameter("@F_MaintenanceType", SqlDbType.NVarChar,30),
new SqlParameter("@F_ERPCustomerCode", SqlDbType.VarChar,100),
new SqlParameter("@F_ServiceDeptID", SqlDbType.Int,4),
new SqlParameter("@F_ProductLineID", SqlDbType.Int,4),
new SqlParameter("@F_AfterSaleNameID", SqlDbType.Int,4),
new SqlParameter("@F_CustomerNatureID", SqlDbType.Int,4),
new SqlParameter("@F_CustomerClassID", SqlDbType.Int,4),
new SqlParameter("@F_RelationShipClassID", SqlDbType.Int,4),
new SqlParameter("@F_CityID", SqlDbType.Int,4)};
parameters[0].Value = model.F_CustomerName;
parameters[1].Value = model.F_CustomerCode;
parameters[2].Value = model.F_CustomerEName;
parameters[3].Value = model.F_CustomerPym;
parameters[4].Value = model.F_Layer;
parameters[5].Value = model.F_CustomerLayer;
parameters[6].Value = model.F_CategoryId;
parameters[7].Value = model.F_TradeId;
parameters[8].Value = model.F_RegionId;
parameters[9].Value = model.F_IndustryId;
parameters[10].Value = model.F_Address;
parameters[11].Value = model.F_Url;
parameters[12].Value = model.F_Telephone;
parameters[13].Value = model.F_Mobile;
parameters[14].Value = model.F_Fax;
parameters[15].Value = model.F_Email;
parameters[16].Value = model.F_Website;
parameters[17].Value = model.F_PostCode;
parameters[18].Value = model.F_ScaleResume;
parameters[19].Value = model.F_BusinessProfile;
parameters[20].Value = model.F_BusinessLicenseID;
parameters[21].Value = model.F_TaxID;
parameters[22].Value = model.F_OpeningBank;
parameters[23].Value = model.F_BankAccount;
parameters[24].Value = model.F_LegalRepresentative;
parameters[25].Value = model.F_LegalRepresentativeCardID;
parameters[26].Value = model.F_Nature;
parameters[27].Value = model.F_Kind;
parameters[28].Value = model.F_CustomerType;
parameters[29].Value = model.F_MainProduct;
parameters[30].Value = model.F_CustomerFrom;
parameters[31].Value = model.F_TrackInfo;
parameters[32].Value = model.F_TrackState;
parameters[33].Value = model.F_ImportDegree;
parameters[34].Value = model.F_IntentProduct;
parameters[35].Value = model.F_CreateBy;
parameters[36].Value = model.F_CreatedOn;
parameters[37].Value = model.F_ModifyBy;
parameters[38].Value = model.F_ModifiedOn;
parameters[39].Value = model.F_DeleteFlag;
parameters[40].Value = model.F_StatusCode;
parameters[41].Value = model.F_ServiceDept;
parameters[42].Value = model.F_ChargeName;
parameters[43].Value = model.F_ChargeTelephone;
parameters[44].Value = model.F_Province;
parameters[45].Value = model.F_ProductLine;
parameters[46].Value = model.F_ChargeDept;
parameters[47].Value = model.F_AfterSaleName;
parameters[48].Value = model.F_CustomerNature;
parameters[49].Value = model.F_CustomerClass;
parameters[50].Value = model.F_CustomerIndustry;
parameters[51].Value = model.F_RelationShipClass;
parameters[52].Value = model.F_CurrentVersion;
parameters[53].Value = model.F_SystemStartTime;
parameters[54].Value = model.F_QualityGuaranteeEndTime;
parameters[55].Value = model.F_AfterSaleTelephone;
parameters[56].Value = model.F_Notes;
parameters[57].Value = model.F_SystemType;
parameters[58].Value = model.F_City;
parameters[59].Value = model.F_CustomerStatus;
parameters[60].Value = model.F_DeviceCount;
parameters[61].Value = model.F_MaintenanceType;
parameters[62].Value = model.F_ERPCustomerCode;
parameters[63].Value = model.F_ServiceDeptID;
parameters[64].Value = model.F_ProductLineID;
parameters[65].Value = model.F_AfterSaleNameID;
parameters[66].Value = model.F_CustomerNatureID;
parameters[67].Value = model.F_CustomerClassID;
parameters[68].Value = model.F_RelationShipClassID;
parameters[69].Value = model.F_CityID;
object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
if (obj == null)
{
return 0;
}
else
{
return Convert.ToInt32(obj);
}
}
///
/// 更新一条数据
///
public bool Update(YTSoft.BaseCallCenter.Model.T_Cus_CustomerBase model)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("update T_Cus_CustomerBase set ");
strSql.Append("F_CustomerName=@F_CustomerName,");
strSql.Append("F_CustomerCode=@F_CustomerCode,");
strSql.Append("F_CustomerEName=@F_CustomerEName,");
strSql.Append("F_CustomerPym=@F_CustomerPym,");
strSql.Append("F_Layer=@F_Layer,");
strSql.Append("F_CustomerLayer=@F_CustomerLayer,");
strSql.Append("F_CategoryId=@F_CategoryId,");
strSql.Append("F_TradeId=@F_TradeId,");
strSql.Append("F_RegionId=@F_RegionId,");
strSql.Append("F_IndustryId=@F_IndustryId,");
strSql.Append("F_Address=@F_Address,");
strSql.Append("F_Url=@F_Url,");
strSql.Append("F_Telephone=@F_Telephone,");
strSql.Append("F_Mobile=@F_Mobile,");
strSql.Append("F_Fax=@F_Fax,");
strSql.Append("F_Email=@F_Email,");
strSql.Append("F_Website=@F_Website,");
strSql.Append("F_PostCode=@F_PostCode,");
strSql.Append("F_ScaleResume=@F_ScaleResume,");
strSql.Append("F_BusinessProfile=@F_BusinessProfile,");
strSql.Append("F_BusinessLicenseID=@F_BusinessLicenseID,");
strSql.Append("F_TaxID=@F_TaxID,");
strSql.Append("F_OpeningBank=@F_OpeningBank,");
strSql.Append("F_BankAccount=@F_BankAccount,");
strSql.Append("F_LegalRepresentative=@F_LegalRepresentative,");
strSql.Append("F_LegalRepresentativeCardID=@F_LegalRepresentativeCardID,");
strSql.Append("F_Nature=@F_Nature,");
strSql.Append("F_Kind=@F_Kind,");
strSql.Append("F_CustomerType=@F_CustomerType,");
strSql.Append("F_MainProduct=@F_MainProduct,");
strSql.Append("F_CustomerFrom=@F_CustomerFrom,");
strSql.Append("F_TrackInfo=@F_TrackInfo,");
strSql.Append("F_TrackState=@F_TrackState,");
strSql.Append("F_ImportDegree=@F_ImportDegree,");
strSql.Append("F_IntentProduct=@F_IntentProduct,");
strSql.Append("F_CreateBy=@F_CreateBy,");
strSql.Append("F_CreatedOn=@F_CreatedOn,");
strSql.Append("F_ModifyBy=@F_ModifyBy,");
strSql.Append("F_ModifiedOn=@F_ModifiedOn,");
strSql.Append("F_DeleteFlag=@F_DeleteFlag,");
strSql.Append("F_StatusCode=@F_StatusCode,");
strSql.Append("F_ServiceDept=@F_ServiceDept,");
strSql.Append("F_ChargeName=@F_ChargeName,");
strSql.Append("F_ChargeTelephone=@F_ChargeTelephone,");
strSql.Append("F_Province=@F_Province,");
strSql.Append("F_ProductLine=@F_ProductLine,");
strSql.Append("F_ChargeDept=@F_ChargeDept,");
strSql.Append("F_AfterSaleName=@F_AfterSaleName,");
strSql.Append("F_CustomerNature=@F_CustomerNature,");
strSql.Append("F_CustomerClass=@F_CustomerClass,");
strSql.Append("F_CustomerIndustry=@F_CustomerIndustry,");
strSql.Append("F_RelationShipClass=@F_RelationShipClass,");
strSql.Append("F_CurrentVersion=@F_CurrentVersion,");
strSql.Append("F_SystemStartTime=@F_SystemStartTime,");
strSql.Append("F_QualityGuaranteeEndTime=@F_QualityGuaranteeEndTime,");
strSql.Append("F_AfterSaleTelephone=@F_AfterSaleTelephone,");
strSql.Append("F_Notes=@F_Notes,");
strSql.Append("F_SystemType=@F_SystemType,");
strSql.Append("F_City=@F_City,");
strSql.Append("F_CustomerStatus=@F_CustomerStatus,");
strSql.Append("F_DeviceCount=@F_DeviceCount,");
strSql.Append("F_MaintenanceType=@F_MaintenanceType,");
strSql.Append("F_ERPCustomerCode=@F_ERPCustomerCode,");
strSql.Append("F_ServiceDeptID=@F_ServiceDeptID,");
strSql.Append("F_ProductLineID=@F_ProductLineID,");
strSql.Append("F_AfterSaleNameID=@F_AfterSaleNameID,");
strSql.Append("F_CustomerNatureID=@F_CustomerNatureID,");
strSql.Append("F_CustomerClassID=@F_CustomerClassID,");
strSql.Append("F_RelationShipClassID=@F_RelationShipClassID,");
strSql.Append("F_CityID=@F_CityID");
strSql.Append(" where F_CustomerId=@F_CustomerId");
SqlParameter[] parameters = {
new SqlParameter("@F_CustomerName", SqlDbType.NVarChar,200),
new SqlParameter("@F_CustomerCode", SqlDbType.VarChar,100),
new SqlParameter("@F_CustomerEName", SqlDbType.NVarChar,800),
new SqlParameter("@F_CustomerPym", SqlDbType.NVarChar,50),
new SqlParameter("@F_Layer", SqlDbType.SmallInt,2),
new SqlParameter("@F_CustomerLayer", SqlDbType.NVarChar,50),
new SqlParameter("@F_CategoryId", SqlDbType.Int,4),
new SqlParameter("@F_TradeId", SqlDbType.Int,4),
new SqlParameter("@F_RegionId", SqlDbType.Int,4),
new SqlParameter("@F_IndustryId", SqlDbType.Int,4),
new SqlParameter("@F_Address", SqlDbType.NVarChar,300),
new SqlParameter("@F_Url", SqlDbType.NVarChar,200),
new SqlParameter("@F_Telephone", SqlDbType.NVarChar,200),
new SqlParameter("@F_Mobile", SqlDbType.NVarChar,200),
new SqlParameter("@F_Fax", SqlDbType.NVarChar,200),
new SqlParameter("@F_Email", SqlDbType.VarChar,200),
new SqlParameter("@F_Website", SqlDbType.VarChar,200),
new SqlParameter("@F_PostCode", SqlDbType.NVarChar,50),
new SqlParameter("@F_ScaleResume", SqlDbType.NVarChar,2000),
new SqlParameter("@F_BusinessProfile", SqlDbType.NVarChar,2000),
new SqlParameter("@F_BusinessLicenseID", SqlDbType.VarChar,80),
new SqlParameter("@F_TaxID", SqlDbType.VarChar,80),
new SqlParameter("@F_OpeningBank", SqlDbType.NVarChar,100),
new SqlParameter("@F_BankAccount", SqlDbType.VarChar,80),
new SqlParameter("@F_LegalRepresentative", SqlDbType.VarChar,50),
new SqlParameter("@F_LegalRepresentativeCardID", SqlDbType.VarChar,30),
new SqlParameter("@F_Nature", SqlDbType.NVarChar,80),
new SqlParameter("@F_Kind", SqlDbType.NVarChar,80),
new SqlParameter("@F_CustomerType", SqlDbType.Int,4),
new SqlParameter("@F_MainProduct", SqlDbType.Text),
new SqlParameter("@F_CustomerFrom", SqlDbType.NVarChar,200),
new SqlParameter("@F_TrackInfo", SqlDbType.NVarChar,200),
new SqlParameter("@F_TrackState", SqlDbType.NVarChar,50),
new SqlParameter("@F_ImportDegree", SqlDbType.NVarChar,50),
new SqlParameter("@F_IntentProduct", SqlDbType.Text),
new SqlParameter("@F_CreateBy", SqlDbType.Int,4),
new SqlParameter("@F_CreatedOn", SqlDbType.DateTime),
new SqlParameter("@F_ModifyBy", SqlDbType.Int,4),
new SqlParameter("@F_ModifiedOn", SqlDbType.DateTime),
new SqlParameter("@F_DeleteFlag", SqlDbType.SmallInt,2),
new SqlParameter("@F_StatusCode", SqlDbType.SmallInt,2),
new SqlParameter("@F_ServiceDept", SqlDbType.NVarChar,20),
new SqlParameter("@F_ChargeName", SqlDbType.NVarChar,20),
new SqlParameter("@F_ChargeTelephone", SqlDbType.VarChar,15),
new SqlParameter("@F_Province", SqlDbType.NVarChar,20),
new SqlParameter("@F_ProductLine", SqlDbType.NVarChar,50),
new SqlParameter("@F_ChargeDept", SqlDbType.NVarChar,20),
new SqlParameter("@F_AfterSaleName", SqlDbType.NVarChar,20),
new SqlParameter("@F_CustomerNature", SqlDbType.NVarChar,20),
new SqlParameter("@F_CustomerClass", SqlDbType.NVarChar,10),
new SqlParameter("@F_CustomerIndustry", SqlDbType.NVarChar,10),
new SqlParameter("@F_RelationShipClass", SqlDbType.NVarChar,10),
new SqlParameter("@F_CurrentVersion", SqlDbType.VarChar,100),
new SqlParameter("@F_SystemStartTime", SqlDbType.DateTime),
new SqlParameter("@F_QualityGuaranteeEndTime", SqlDbType.DateTime),
new SqlParameter("@F_AfterSaleTelephone", SqlDbType.VarChar,15),
new SqlParameter("@F_Notes", SqlDbType.NVarChar,500),
new SqlParameter("@F_SystemType", SqlDbType.NVarChar,100),
new SqlParameter("@F_City", SqlDbType.NVarChar,10),
new SqlParameter("@F_CustomerStatus", SqlDbType.NVarChar,10),
new SqlParameter("@F_DeviceCount", SqlDbType.Int,4),
new SqlParameter("@F_MaintenanceType", SqlDbType.NVarChar,30),
new SqlParameter("@F_ERPCustomerCode", SqlDbType.VarChar,100),
new SqlParameter("@F_ServiceDeptID", SqlDbType.Int,4),
new SqlParameter("@F_ProductLineID", SqlDbType.Int,4),
new SqlParameter("@F_AfterSaleNameID", SqlDbType.Int,4),
new SqlParameter("@F_CustomerNatureID", SqlDbType.Int,4),
new SqlParameter("@F_CustomerClassID", SqlDbType.Int,4),
new SqlParameter("@F_RelationShipClassID", SqlDbType.Int,4),
new SqlParameter("@F_CityID", SqlDbType.Int,4),
new SqlParameter("@F_CustomerId", SqlDbType.Int,4)};
parameters[0].Value = model.F_CustomerName;
parameters[1].Value = model.F_CustomerCode;
parameters[2].Value = model.F_CustomerEName;
parameters[3].Value = model.F_CustomerPym;
parameters[4].Value = model.F_Layer;
parameters[5].Value = model.F_CustomerLayer;
parameters[6].Value = model.F_CategoryId;
parameters[7].Value = model.F_TradeId;
parameters[8].Value = model.F_RegionId;
parameters[9].Value = model.F_IndustryId;
parameters[10].Value = model.F_Address;
parameters[11].Value = model.F_Url;
parameters[12].Value = model.F_Telephone;
parameters[13].Value = model.F_Mobile;
parameters[14].Value = model.F_Fax;
parameters[15].Value = model.F_Email;
parameters[16].Value = model.F_Website;
parameters[17].Value = model.F_PostCode;
parameters[18].Value = model.F_ScaleResume;
parameters[19].Value = model.F_BusinessProfile;
parameters[20].Value = model.F_BusinessLicenseID;
parameters[21].Value = model.F_TaxID;
parameters[22].Value = model.F_OpeningBank;
parameters[23].Value = model.F_BankAccount;
parameters[24].Value = model.F_LegalRepresentative;
parameters[25].Value = model.F_LegalRepresentativeCardID;
parameters[26].Value = model.F_Nature;
parameters[27].Value = model.F_Kind;
parameters[28].Value = model.F_CustomerType;
parameters[29].Value = model.F_MainProduct;
parameters[30].Value = model.F_CustomerFrom;
parameters[31].Value = model.F_TrackInfo;
parameters[32].Value = model.F_TrackState;
parameters[33].Value = model.F_ImportDegree;
parameters[34].Value = model.F_IntentProduct;
parameters[35].Value = model.F_CreateBy;
parameters[36].Value = model.F_CreatedOn;
parameters[37].Value = model.F_ModifyBy;
parameters[38].Value = model.F_ModifiedOn;
parameters[39].Value = model.F_DeleteFlag;
parameters[40].Value = model.F_StatusCode;
parameters[41].Value = model.F_ServiceDept;
parameters[42].Value = model.F_ChargeName;
parameters[43].Value = model.F_ChargeTelephone;
parameters[44].Value = model.F_Province;
parameters[45].Value = model.F_ProductLine;
parameters[46].Value = model.F_ChargeDept;
parameters[47].Value = model.F_AfterSaleName;
parameters[48].Value = model.F_CustomerNature;
parameters[49].Value = model.F_CustomerClass;
parameters[50].Value = model.F_CustomerIndustry;
parameters[51].Value = model.F_RelationShipClass;
parameters[52].Value = model.F_CurrentVersion;
parameters[53].Value = model.F_SystemStartTime;
parameters[54].Value = model.F_QualityGuaranteeEndTime;
parameters[55].Value = model.F_AfterSaleTelephone;
parameters[56].Value = model.F_Notes;
parameters[57].Value = model.F_SystemType;
parameters[58].Value = model.F_City;
parameters[59].Value = model.F_CustomerStatus;
parameters[60].Value = model.F_DeviceCount;
parameters[61].Value = model.F_MaintenanceType;
parameters[62].Value = model.F_ERPCustomerCode;
parameters[63].Value = model.F_ServiceDeptID;
parameters[64].Value = model.F_ProductLineID;
parameters[65].Value = model.F_AfterSaleNameID;
parameters[66].Value = model.F_CustomerNatureID;
parameters[67].Value = model.F_CustomerClassID;
parameters[68].Value = model.F_RelationShipClassID;
parameters[69].Value = model.F_CityID;
parameters[70].Value = model.F_CustomerId;
int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
if (rows > 0)
{
return true;
}
else
{
return false;
}
}
///
/// 删除一条数据
///
public bool Delete(int F_CustomerId)
{
StringBuilder strSql = new StringBuilder();
//strSql.Append("delete from T_Cus_CustomerBase ");
strSql.Append("update T_Cus_CustomerBase set F_DeleteFlag=1");
strSql.Append(" where F_CustomerId=@F_CustomerId");
SqlParameter[] parameters = {
new SqlParameter("@F_CustomerId", SqlDbType.Int,4)
};
parameters[0].Value = F_CustomerId;
int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
if (rows > 0)
{
return true;
}
else
{
return false;
}
}
///
/// 批量删除数据
///
public bool DeleteList(string F_CustomerIdlist)
{
StringBuilder strSql = new StringBuilder();
//strSql.Append("delete from T_Cus_CustomerBase ");
strSql.Append("update T_Cus_CustomerBase set F_DeleteFlag=1");
strSql.Append(" where F_CustomerId in (" + F_CustomerIdlist + ") ");
int rows = DbHelperSQL.ExecuteSql(strSql.ToString());
if (rows > 0)
{
return true;
}
else
{
return false;
}
}
///
/// 得到一个对象实体
///
public YTSoft.BaseCallCenter.Model.T_Cus_CustomerBase GetModel(int F_CustomerId)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select top 1 F_CustomerId,F_CustomerName,F_CustomerCode,F_CustomerEName,F_CustomerPym,F_Layer,F_CustomerLayer,F_CategoryId,F_TradeId,F_RegionId,F_IndustryId,F_Address,F_Url,F_Telephone,F_Mobile,F_Fax,F_Email,F_Website,F_PostCode,F_ScaleResume,F_BusinessProfile,F_BusinessLicenseID,F_TaxID,F_OpeningBank,F_BankAccount,F_LegalRepresentative,F_LegalRepresentativeCardID,F_Nature,F_Kind,F_CustomerType,F_MainProduct,F_CustomerFrom,F_TrackInfo,F_TrackState,F_ImportDegree,F_IntentProduct,F_CreateBy,F_CreatedOn,F_ModifyBy,F_ModifiedOn,F_DeleteFlag,F_StatusCode,F_ServiceDept,F_ChargeName,F_ChargeTelephone,F_Province,F_ProductLine,F_ChargeDept,F_AfterSaleName,F_CustomerNature,F_CustomerClass,F_CustomerIndustry,F_RelationShipClass,F_CurrentVersion,F_SystemStartTime,F_QualityGuaranteeEndTime,F_AfterSaleTelephone,F_Notes,F_SystemType,F_City,F_CustomerStatus,F_DeviceCount,F_MaintenanceType,F_ERPCustomerCode,F_ServiceDeptID,F_ProductLineID,F_AfterSaleNameID,F_CustomerNatureID,F_CustomerClassID,F_RelationShipClassID,F_CityID from T_Cus_CustomerBase ");
strSql.Append(" where F_CustomerId=@F_CustomerId");
SqlParameter[] parameters = {
new SqlParameter("@F_CustomerId", SqlDbType.Int,4)
};
parameters[0].Value = F_CustomerId;
YTSoft.BaseCallCenter.Model.T_Cus_CustomerBase model = new YTSoft.BaseCallCenter.Model.T_Cus_CustomerBase();
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 YTSoft.BaseCallCenter.Model.T_Cus_CustomerBase DataRowToModel(DataRow row)
{
YTSoft.BaseCallCenter.Model.T_Cus_CustomerBase model = new YTSoft.BaseCallCenter.Model.T_Cus_CustomerBase();
if (row != null)
{
if (row["F_CustomerId"] != null && row["F_CustomerId"].ToString() != "")
{
model.F_CustomerId = int.Parse(row["F_CustomerId"].ToString());
}
if (row["F_CustomerName"] != null)
{
model.F_CustomerName = row["F_CustomerName"].ToString();
}
if (row["F_CustomerCode"] != null)
{
model.F_CustomerCode = row["F_CustomerCode"].ToString();
}
if (row["F_CustomerEName"] != null)
{
model.F_CustomerEName = row["F_CustomerEName"].ToString();
}
if (row["F_CustomerPym"] != null)
{
model.F_CustomerPym = row["F_CustomerPym"].ToString();
}
if (row["F_Layer"] != null && row["F_Layer"].ToString() != "")
{
model.F_Layer = int.Parse(row["F_Layer"].ToString());
}
if (row["F_CustomerLayer"] != null)
{
model.F_CustomerLayer = row["F_CustomerLayer"].ToString();
}
if (row["F_CategoryId"] != null && row["F_CategoryId"].ToString() != "")
{
model.F_CategoryId = int.Parse(row["F_CategoryId"].ToString());
}
if (row["F_TradeId"] != null && row["F_TradeId"].ToString() != "")
{
model.F_TradeId = int.Parse(row["F_TradeId"].ToString());
}
if (row["F_RegionId"] != null && row["F_RegionId"].ToString() != "")
{
model.F_RegionId = int.Parse(row["F_RegionId"].ToString());
}
if (row["F_IndustryId"] != null && row["F_IndustryId"].ToString() != "")
{
model.F_IndustryId = int.Parse(row["F_IndustryId"].ToString());
}
if (row["F_Address"] != null)
{
model.F_Address = row["F_Address"].ToString();
}
if (row["F_Url"] != null)
{
model.F_Url = row["F_Url"].ToString();
}
if (row["F_Telephone"] != null)
{
model.F_Telephone = row["F_Telephone"].ToString();
}
if (row["F_Mobile"] != null)
{
model.F_Mobile = row["F_Mobile"].ToString();
}
if (row["F_Fax"] != null)
{
model.F_Fax = row["F_Fax"].ToString();
}
if (row["F_Email"] != null)
{
model.F_Email = row["F_Email"].ToString();
}
if (row["F_Website"] != null)
{
model.F_Website = row["F_Website"].ToString();
}
if (row["F_PostCode"] != null)
{
model.F_PostCode = row["F_PostCode"].ToString();
}
if (row["F_ScaleResume"] != null)
{
model.F_ScaleResume = row["F_ScaleResume"].ToString();
}
if (row["F_BusinessProfile"] != null)
{
model.F_BusinessProfile = row["F_BusinessProfile"].ToString();
}
if (row["F_BusinessLicenseID"] != null)
{
model.F_BusinessLicenseID = row["F_BusinessLicenseID"].ToString();
}
if (row["F_TaxID"] != null)
{
model.F_TaxID = row["F_TaxID"].ToString();
}
if (row["F_OpeningBank"] != null)
{
model.F_OpeningBank = row["F_OpeningBank"].ToString();
}
if (row["F_BankAccount"] != null)
{
model.F_BankAccount = row["F_BankAccount"].ToString();
}
if (row["F_LegalRepresentative"] != null)
{
model.F_LegalRepresentative = row["F_LegalRepresentative"].ToString();
}
if (row["F_LegalRepresentativeCardID"] != null)
{
model.F_LegalRepresentativeCardID = row["F_LegalRepresentativeCardID"].ToString();
}
if (row["F_Nature"] != null)
{
model.F_Nature = row["F_Nature"].ToString();
}
if (row["F_Kind"] != null)
{
model.F_Kind = row["F_Kind"].ToString();
}
if (row["F_CustomerType"] != null && row["F_CustomerType"].ToString() != "")
{
model.F_CustomerType = int.Parse(row["F_CustomerType"].ToString());
}
if (row["F_MainProduct"] != null)
{
model.F_MainProduct = row["F_MainProduct"].ToString();
}
if (row["F_CustomerFrom"] != null)
{
model.F_CustomerFrom = row["F_CustomerFrom"].ToString();
}
if (row["F_TrackInfo"] != null)
{
model.F_TrackInfo = row["F_TrackInfo"].ToString();
}
if (row["F_TrackState"] != null)
{
model.F_TrackState = row["F_TrackState"].ToString();
}
if (row["F_ImportDegree"] != null)
{
model.F_ImportDegree = row["F_ImportDegree"].ToString();
}
if (row["F_IntentProduct"] != null)
{
model.F_IntentProduct = row["F_IntentProduct"].ToString();
}
if (row["F_CreateBy"] != null && row["F_CreateBy"].ToString() != "")
{
model.F_CreateBy = int.Parse(row["F_CreateBy"].ToString());
}
if (row["F_CreatedOn"] != null && row["F_CreatedOn"].ToString() != "")
{
model.F_CreatedOn = DateTime.Parse(row["F_CreatedOn"].ToString());
}
if (row["F_ModifyBy"] != null && row["F_ModifyBy"].ToString() != "")
{
model.F_ModifyBy = int.Parse(row["F_ModifyBy"].ToString());
}
if (row["F_ModifiedOn"] != null && row["F_ModifiedOn"].ToString() != "")
{
model.F_ModifiedOn = DateTime.Parse(row["F_ModifiedOn"].ToString());
}
if (row["F_DeleteFlag"] != null && row["F_DeleteFlag"].ToString() != "")
{
model.F_DeleteFlag = int.Parse(row["F_DeleteFlag"].ToString());
}
if (row["F_StatusCode"] != null && row["F_StatusCode"].ToString() != "")
{
model.F_StatusCode = int.Parse(row["F_StatusCode"].ToString());
}
if (row["F_ServiceDept"] != null)
{
model.F_ServiceDept = row["F_ServiceDept"].ToString();
}
if (row["F_ChargeName"] != null)
{
model.F_ChargeName = row["F_ChargeName"].ToString();
}
if (row["F_ChargeTelephone"] != null)
{
model.F_ChargeTelephone = row["F_ChargeTelephone"].ToString();
}
if (row["F_Province"] != null)
{
model.F_Province = row["F_Province"].ToString();
}
if (row["F_ProductLine"] != null)
{
model.F_ProductLine = row["F_ProductLine"].ToString();
}
if (row["F_ChargeDept"] != null)
{
model.F_ChargeDept = row["F_ChargeDept"].ToString();
}
if (row["F_AfterSaleName"] != null)
{
model.F_AfterSaleName = row["F_AfterSaleName"].ToString();
}
if (row["F_CustomerNature"] != null)
{
model.F_CustomerNature = row["F_CustomerNature"].ToString();
}
if (row["F_CustomerClass"] != null)
{
model.F_CustomerClass = row["F_CustomerClass"].ToString();
}
if (row["F_CustomerIndustry"] != null)
{
model.F_CustomerIndustry = row["F_CustomerIndustry"].ToString();
}
if (row["F_RelationShipClass"] != null)
{
model.F_RelationShipClass = row["F_RelationShipClass"].ToString();
}
if (row["F_CurrentVersion"] != null)
{
model.F_CurrentVersion = row["F_CurrentVersion"].ToString();
}
if (row["F_SystemStartTime"] != null && row["F_SystemStartTime"].ToString() != "")
{
model.F_SystemStartTime = DateTime.Parse(row["F_SystemStartTime"].ToString());
}
if (row["F_QualityGuaranteeEndTime"] != null && row["F_QualityGuaranteeEndTime"].ToString() != "")
{
model.F_QualityGuaranteeEndTime = DateTime.Parse(row["F_QualityGuaranteeEndTime"].ToString());
}
if (row["F_AfterSaleTelephone"] != null)
{
model.F_AfterSaleTelephone = row["F_AfterSaleTelephone"].ToString();
}
if (row["F_Notes"] != null)
{
model.F_Notes = row["F_Notes"].ToString();
}
if (row["F_SystemType"] != null)
{
model.F_SystemType = row["F_SystemType"].ToString();
}
if (row["F_City"] != null)
{
model.F_City = row["F_City"].ToString();
}
if (row["F_CustomerStatus"] != null)
{
model.F_CustomerStatus = row["F_CustomerStatus"].ToString();
}
if (row["F_DeviceCount"] != null && row["F_DeviceCount"].ToString() != "")
{
model.F_DeviceCount = int.Parse(row["F_DeviceCount"].ToString());
}
if (row["F_MaintenanceType"] != null)
{
model.F_MaintenanceType = row["F_MaintenanceType"].ToString();
}
if (row["F_ERPCustomerCode"] != null)
{
model.F_ERPCustomerCode = row["F_ERPCustomerCode"].ToString();
}
if (row["F_ServiceDeptID"] != null && row["F_ServiceDeptID"].ToString() != "")
{
model.F_ServiceDeptID = int.Parse(row["F_ServiceDeptID"].ToString());
}
if (row["F_ProductLineID"] != null && row["F_ProductLineID"].ToString() != "")
{
model.F_ProductLineID = int.Parse(row["F_ProductLineID"].ToString());
}
if (row["F_AfterSaleNameID"] != null && row["F_AfterSaleNameID"].ToString() != "")
{
model.F_AfterSaleNameID = int.Parse(row["F_AfterSaleNameID"].ToString());
}
if (row["F_CustomerNatureID"] != null && row["F_CustomerNatureID"].ToString() != "")
{
model.F_CustomerNatureID = int.Parse(row["F_CustomerNatureID"].ToString());
}
if (row["F_CustomerClassID"] != null && row["F_CustomerClassID"].ToString() != "")
{
model.F_CustomerClassID = int.Parse(row["F_CustomerClassID"].ToString());
}
if (row["F_RelationShipClassID"] != null && row["F_RelationShipClassID"].ToString() != "")
{
model.F_RelationShipClassID = int.Parse(row["F_RelationShipClassID"].ToString());
}
if (row["F_CityID"] != null && row["F_CityID"].ToString() != "")
{
model.F_CityID = int.Parse(row["F_CityID"].ToString());
}
}
return model;
}
///
/// 获得数据列表
///
public DataSet GetList(string strWhere)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select F_CustomerId,F_CustomerName,F_CustomerCode,F_CustomerEName,F_CustomerPym,F_Layer,F_CustomerLayer,F_CategoryId,F_TradeId,F_RegionId,F_IndustryId,F_Address,F_Url,F_Telephone,F_Mobile,F_Fax,F_Email,F_Website,F_PostCode,F_ScaleResume,F_BusinessProfile,F_BusinessLicenseID,F_TaxID,F_OpeningBank,F_BankAccount,F_LegalRepresentative,F_LegalRepresentativeCardID,F_Nature,F_Kind,F_CustomerType,F_MainProduct,F_CustomerFrom,F_TrackInfo,F_TrackState,F_ImportDegree,F_IntentProduct,F_CreateBy,F_CreatedOn,F_ModifyBy,F_ModifiedOn,F_DeleteFlag,F_StatusCode,F_ServiceDept,F_ChargeName,F_ChargeTelephone,F_Province,F_ProductLine,F_ChargeDept,F_AfterSaleName,F_CustomerNature,F_CustomerClass,F_CustomerIndustry,F_RelationShipClass,F_CurrentVersion,F_SystemStartTime,F_QualityGuaranteeEndTime,F_AfterSaleTelephone,F_Notes,F_SystemType,F_City,F_CustomerStatus,F_DeviceCount,F_MaintenanceType,F_ERPCustomerCode,F_ServiceDeptID,F_ProductLineID,F_AfterSaleNameID,F_CustomerNatureID,F_CustomerClassID,F_RelationShipClassID,F_CityID ");
strSql.Append(" FROM T_Cus_CustomerBase ");
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_CustomerId,F_CustomerName,F_CustomerCode,F_CustomerEName,F_CustomerPym,F_Layer,F_CustomerLayer,F_CategoryId,F_TradeId,F_RegionId,F_IndustryId,F_Address,F_Url,F_Telephone,F_Mobile,F_Fax,F_Email,F_Website,F_PostCode,F_ScaleResume,F_BusinessProfile,F_BusinessLicenseID,F_TaxID,F_OpeningBank,F_BankAccount,F_LegalRepresentative,F_LegalRepresentativeCardID,F_Nature,F_Kind,F_CustomerType,F_MainProduct,F_CustomerFrom,F_TrackInfo,F_TrackState,F_ImportDegree,F_IntentProduct,F_CreateBy,F_CreatedOn,F_ModifyBy,F_ModifiedOn,F_DeleteFlag,F_StatusCode,F_ServiceDept,F_ChargeName,F_ChargeTelephone,F_Province,F_ProductLine,F_ChargeDept,F_AfterSaleName,F_CustomerNature,F_CustomerClass,F_CustomerIndustry,F_RelationShipClass,F_CurrentVersion,F_SystemStartTime,F_QualityGuaranteeEndTime,F_AfterSaleTelephone,F_Notes,F_SystemType,F_City,F_CustomerStatus,F_DeviceCount,F_MaintenanceType,F_ERPCustomerCode,F_ServiceDeptID,F_ProductLineID,F_AfterSaleNameID,F_CustomerNatureID,F_CustomerClassID,F_RelationShipClassID,F_CityID ");
strSql.Append(" FROM T_Cus_CustomerBase ");
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_Cus_CustomerBase ");
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_CustomerId desc");
}
strSql.Append(")AS Row, T.* from T_Cus_CustomerBase 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());
}
/*
///
/// 分页获取数据列表
///
public DataSet GetList(int PageSize,int PageIndex,string strWhere)
{
SqlParameter[] parameters = {
new SqlParameter("@tblName", SqlDbType.VarChar, 255),
new SqlParameter("@fldName", SqlDbType.VarChar, 255),
new SqlParameter("@PageSize", SqlDbType.Int),
new SqlParameter("@PageIndex", SqlDbType.Int),
new SqlParameter("@IsReCount", SqlDbType.Bit),
new SqlParameter("@OrderType", SqlDbType.Bit),
new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
};
parameters[0].Value = "T_Cus_CustomerBase";
parameters[1].Value = "F_CustomerId";
parameters[2].Value = PageSize;
parameters[3].Value = PageIndex;
parameters[4].Value = 0;
parameters[5].Value = 0;
parameters[6].Value = strWhere;
return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
}*/
#endregion BasicMethod
#region 获取客户信息通过电话号码
///
/// 获取客户信息通过电话号码
///
/// 电话号码
///
public YTSoft.BaseCallCenter.Model.T_Cus_CustomerBase GetCusInfoModel(string pnoneNumber)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select top 1 * from T_Cus_CustomerBase ");
strSql.Append(" where F_Telephone = '" + pnoneNumber + "' order by F_CustomerId desc ");
YTSoft.BaseCallCenter.Model.T_Cus_CustomerBase model = new YTSoft.BaseCallCenter.Model.T_Cus_CustomerBase();
DataSet ds = DbHelperSQL.Query(strSql.ToString());
if (ds.Tables[0].Rows.Count > 0)
{
return DataRowToModel(ds.Tables[0].Rows[0]);
}
else
{
return model;
}
}
///
/// 获取客户信息通过微信号/微博号
///
/// 1、微信号/2、微博号
/// 微信号/微博号
///
public YTSoft.BaseCallCenter.Model.T_Cus_CustomerBase GetCusInfoModel(int types, string pnoneNumber)
{
StringBuilder strSql = new StringBuilder();
if (types == 1)//微信
{
strSql.Append("select top 1 * from T_Cus_CustomerBase ");
strSql.Append(" where F_CustomerEName=@F_CustomerEName order by F_CustomerId desc ");
SqlParameter[] parameters = {
new SqlParameter("@F_CustomerEName", SqlDbType.NVarChar ,50)
};
parameters[0].Value = pnoneNumber;
YTSoft.BaseCallCenter.Model.T_Cus_CustomerBase model = new YTSoft.BaseCallCenter.Model.T_Cus_CustomerBase();
DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
if (ds.Tables[0].Rows.Count > 0)
{
return DataRowToModel(ds.Tables[0].Rows[0]);
}
else
{
return model;
}
}
else if (types == 2)//微博
{
strSql.Append("select top 1 * from T_Cus_CustomerBase ");
strSql.Append(" where F_PostCode=@F_PostCode order by F_CustomerId desc ");
SqlParameter[] parameters = {
new SqlParameter("@F_PostCode", SqlDbType.NVarChar ,50)
};
parameters[0].Value = pnoneNumber;
YTSoft.BaseCallCenter.Model.T_Cus_CustomerBase model = new YTSoft.BaseCallCenter.Model.T_Cus_CustomerBase();
DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
if (ds.Tables[0].Rows.Count > 0)
{
return DataRowToModel(ds.Tables[0].Rows[0]);
}
else
{
return model;
}
}
else
{
return new Model.T_Cus_CustomerBase();
}
}
#endregion ExtensionMethod
#region 编辑用户信息
///
/// 获取客户信息通过电话号码
///
/// 电话号码
///
public bool UpdateCusInfoModel(YTSoft.BaseCallCenter.Model.T_Cus_CustomerBase model)
{
StringBuilder strSql = new StringBuilder();
if (model.F_CustomerId > 0)
{
strSql.Append("update T_Cus_CustomerBase set ");
strSql.Append("F_CustomerName=@F_CustomerName,");
strSql.Append("F_CustomerPym=@F_CustomerPym,");
strSql.Append("F_CustomerEName=@F_CustomerEName,");
strSql.Append("F_PostCode=@F_PostCode,");
strSql.Append("F_CustomerLayer=@F_CustomerLayer,");
strSql.Append("F_CustomerCode=@F_CustomerCode,");
strSql.Append("F_Telephone=@F_Telephone,");
strSql.Append("F_Kind=@F_Kind,");
strSql.Append("F_CustomerNature=@F_CustomerNature,");
strSql.Append("F_ScaleResume=@F_ScaleResume,");
strSql.Append("F_CustomerClass=@F_CustomerClass,");
strSql.Append("F_ModifyBy=@F_ModifyBy,");
strSql.Append("F_ModifiedOn=getdate()");
strSql.Append(" where F_CustomerId=@F_CustomerId");
SqlParameter[] parameters = {
new SqlParameter("@F_CustomerName", model.F_CustomerName),
new SqlParameter("@F_CustomerPym", model.F_CustomerPym),
new SqlParameter("@F_CustomerEName", model.F_CustomerEName),
new SqlParameter("@F_PostCode", model.F_PostCode),
new SqlParameter("@F_CustomerLayer", model.F_CustomerLayer),
new SqlParameter("@F_CustomerCode", model.F_CustomerCode),
new SqlParameter("@F_Telephone", model.F_Telephone),
new SqlParameter("@F_Kind", model.F_Kind),
new SqlParameter("@F_CustomerNature", model.F_CustomerNature),
new SqlParameter("@F_ScaleResume", model.F_ScaleResume),
new SqlParameter("@F_CustomerClass",model.F_CustomerClass),
new SqlParameter("@F_ModifyBy",model.F_ModifyBy),
new SqlParameter("@F_CustomerId", model.F_CustomerId)};
//parameters[0].Value = model.F_CustomerName;
//parameters[1].Value = model.F_CustomerPym;
//parameters[2].Value = model.F_CustomerEName;
//parameters[3].Value = model.F_PostCode;
//parameters[4].Value = model.F_CustomerLayer;
//parameters[5].Value = model.F_CustomerCode;
//parameters[6].Value = model.F_Telephone;
//parameters[7].Value = model.F_Kind;
//parameters[8].Value = model.F_CustomerNature;
//parameters[9].Value = model.F_ScaleResume;
//parameters[10].Value = model.F_CustomerClass;
//parameters[11].Value = model.F_ModifyBy;
//parameters[12].Value = model.F_CustomerId;
int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
if (rows > 0)
{
return true;
}
else
{
return false;
}
}
else
{
strSql.Append("insert into T_Cus_CustomerBase(");
strSql.Append("F_CustomerName,F_CustomerPym,F_CustomerEName,F_PostCode,F_CustomerLayer,F_CustomerCode,F_Telephone,F_Kind,F_CustomerNature,F_ScaleResume,F_CustomerClass,F_CreateBy,F_CreatedOn,F_ModifiedOn)");
strSql.Append(" values (@F_CustomerName,@F_CustomerPym,@F_CustomerEName,@F_PostCode,@F_CustomerLayer,@F_CustomerCode,@F_Telephone,@F_Kind,@F_CustomerNature,@F_ScaleResume,@F_CustomerClass,@F_CreateBy,getdate(),getdate())");
SqlParameter[] parameters = {
new SqlParameter("@F_CustomerName", SqlDbType.NVarChar,200),
new SqlParameter("@F_CustomerPym", SqlDbType.NVarChar,200),
new SqlParameter("@F_CustomerEName", SqlDbType.NVarChar,200),
new SqlParameter("@F_PostCode", SqlDbType.NVarChar,200),
new SqlParameter("@F_CustomerLayer", SqlDbType.NVarChar,200),
new SqlParameter("@F_CustomerCode", SqlDbType.NVarChar,200),
new SqlParameter("@F_Telephone", SqlDbType.NVarChar,200),
new SqlParameter("@F_Kind", SqlDbType.Int,4),
new SqlParameter("@F_CustomerNature", SqlDbType.NVarChar,200),
new SqlParameter("@F_ScaleResume", SqlDbType.Int,4),
new SqlParameter("@F_CustomerClass", SqlDbType.NVarChar,200),
new SqlParameter("@F_CreateBy", SqlDbType.Int,4) };
parameters[0].Value = model.F_CustomerName;
parameters[1].Value = model.F_CustomerPym;
parameters[2].Value = model.F_CustomerEName;
parameters[3].Value = model.F_PostCode;
parameters[4].Value = model.F_CustomerLayer;
parameters[5].Value = model.F_CustomerCode;
parameters[6].Value = model.F_Telephone;
parameters[7].Value = model.F_Kind;
parameters[8].Value = model.F_CustomerNature;
parameters[9].Value = model.F_ScaleResume;
parameters[10].Value = model.F_CustomerClass;
parameters[11].Value = model.F_CreateBy;
int obj = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
if (obj > 0)
{
return true;
}
else
{
return false;
}
}
}
///
/// 包含工单信息的客户信息
///
/// 电话号码
///
public int EditCusInfoModel(YTSoft.BaseCallCenter.Model.T_Cus_CustomerBase model)
{
StringBuilder strSql = new StringBuilder();
if (model.F_CustomerId > 1)
{
strSql.Append("update T_Cus_CustomerBase set ");
strSql.Append("F_CustomerName=@F_CustomerName,");
strSql.Append("F_CustomerPym=@F_CustomerPym,");
strSql.Append("F_CustomerCode=@F_CustomerCode,");
strSql.Append("F_Kind=@F_Kind,");
strSql.Append("F_CustomerNature=@F_CustomerNature,");
//strSql.Append("F_ScaleResume=@F_ScaleResume,");//客户等级
//strSql.Append("F_CustomerClass=@F_CustomerClass,");
strSql.Append("F_DeviceCount=@F_DeviceCount,");
strSql.Append("F_Fax=@F_Fax,");
strSql.Append("F_AfterSaleNameID=@F_AfterSaleNameID,");
strSql.Append("F_Email=@F_Email,");
strSql.Append("F_IndustryId=@F_IndustryId,");
strSql.Append("F_Url=@F_Url,");
strSql.Append("F_ModifyBy=@F_ModifyBy,");
strSql.Append("F_Mobile=@F_Mobile,");
strSql.Append("F_ModifiedOn=getdate()");
strSql.Append(" where F_CustomerId=@F_CustomerId");
SqlParameter[] parameters = {
new SqlParameter("@F_CustomerName", SqlDbType.NVarChar,200),
new SqlParameter("@F_CustomerPym", SqlDbType.NVarChar,200),
new SqlParameter("@F_CustomerCode", SqlDbType.NVarChar,200),
new SqlParameter("@F_Kind", SqlDbType.Int,4),
new SqlParameter("@F_CustomerNature", SqlDbType.NVarChar,200),
//new SqlParameter("@F_ScaleResume", SqlDbType.Int,4),
//new SqlParameter("@F_CustomerClass", SqlDbType.NVarChar,200),
new SqlParameter("@F_DeviceCount", SqlDbType.Int,4),
new SqlParameter("@F_Fax", SqlDbType.NVarChar,200),
new SqlParameter("@F_AfterSaleNameID", SqlDbType.Int,4),
new SqlParameter("@F_Email", SqlDbType.NVarChar,200),
new SqlParameter("@F_IndustryId", SqlDbType.Int,4),
new SqlParameter("@F_Url", SqlDbType.NVarChar,200),
new SqlParameter("@F_ModifyBy", SqlDbType.Int,4),
new SqlParameter("@F_Mobile", SqlDbType.NVarChar,200),
new SqlParameter("@F_CustomerId", SqlDbType.Int,4)};
parameters[0].Value = model.F_CustomerName;
parameters[1].Value = model.F_CustomerPym;
parameters[2].Value = model.F_CustomerCode;
parameters[3].Value = model.F_Kind;
parameters[4].Value = model.F_CustomerNature;
//parameters[5].Value = model.F_ScaleResume;
//parameters[6].Value = model.F_CustomerClass;
parameters[5].Value = model.F_DeviceCount;
parameters[6].Value = model.F_Fax;
parameters[7].Value = model.F_AfterSaleNameID;
parameters[8].Value = model.F_Email;
parameters[9].Value = model.F_IndustryId;
parameters[10].Value = model.F_Url;
parameters[11].Value = model.F_ModifyBy;
parameters[12].Value = model.F_Mobile;
parameters[13].Value = model.F_CustomerId;
int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
if (rows > 0)
{
return model.F_CustomerId;
}
else
{
return 0;
}
}
else
{
strSql.Append("insert into T_Cus_CustomerBase(");
strSql.Append("F_CustomerName,F_CustomerPym,F_CustomerEName,F_PostCode,F_CustomerLayer,F_CustomerCode,F_Telephone,F_Kind,F_CustomerNature,F_ScaleResume,F_CustomerClass,F_DeviceCount,F_Fax,F_AfterSaleNameID,F_Email,F_IndustryId,F_Url,F_Mobile,F_CreateBy,F_CreatedOn,F_ModifiedOn)");
strSql.Append(" values (@F_CustomerName,@F_CustomerPym,@F_CustomerEName,@F_PostCode,@F_CustomerLayer,@F_CustomerCode,@F_Telephone,@F_Kind,@F_CustomerNature,@F_ScaleResume,@F_CustomerClass,@F_DeviceCount,@F_Fax,@F_AfterSaleNameID,@F_Email,@F_IndustryId,@F_Url,@F_Mobile,@F_CreateBy,getdate(),getdate())");
strSql.Append(";select @@IDENTITY");
SqlParameter[] parameters = {
new SqlParameter("@F_CustomerName", SqlDbType.NVarChar,200),
new SqlParameter("@F_CustomerPym", SqlDbType.NVarChar,200),
new SqlParameter("@F_CustomerEName", SqlDbType.NVarChar,200),
new SqlParameter("@F_PostCode", SqlDbType.NVarChar,200),
new SqlParameter("@F_CustomerLayer", SqlDbType.NVarChar,200),
new SqlParameter("@F_CustomerCode", SqlDbType.NVarChar,200),
new SqlParameter("@F_Telephone", SqlDbType.NVarChar,200),
new SqlParameter("@F_Kind", SqlDbType.Int,4),
new SqlParameter("@F_CustomerNature", SqlDbType.NVarChar,200),
new SqlParameter("@F_ScaleResume", SqlDbType.Int,4),
new SqlParameter("@F_CustomerClass", SqlDbType.NVarChar,200),
new SqlParameter("@F_DeviceCount", SqlDbType.Int,4),
new SqlParameter("@F_Fax", SqlDbType.NVarChar,200),
new SqlParameter("@F_AfterSaleNameID", SqlDbType.Int,4),
new SqlParameter("@F_Email", SqlDbType.NVarChar,200),
new SqlParameter("@F_IndustryId", SqlDbType.Int,4),
new SqlParameter("@F_Url", SqlDbType.NVarChar,200),
new SqlParameter("@F_Mobile", SqlDbType.NVarChar,200),
new SqlParameter("@F_CreateBy", SqlDbType.Int,4) };
parameters[0].Value = model.F_CustomerName;
parameters[1].Value = model.F_CustomerPym;
parameters[2].Value = model.F_CustomerEName;
parameters[3].Value = model.F_PostCode;
parameters[4].Value = model.F_CustomerLayer;
parameters[5].Value = model.F_CustomerCode;
parameters[6].Value = model.F_Telephone;
parameters[7].Value = model.F_Kind;
parameters[8].Value = model.F_CustomerNature;
parameters[9].Value = model.F_ScaleResume;
parameters[10].Value = model.F_CustomerClass;
parameters[11].Value = model.F_DeviceCount;
parameters[12].Value = model.F_Fax;
parameters[13].Value = model.F_AfterSaleNameID;
parameters[14].Value = model.F_Email;
parameters[15].Value = model.F_IndustryId;
parameters[16].Value = model.F_Url;
parameters[17].Value = model.F_Mobile;
parameters[18].Value = model.F_CreateBy;
object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
if (obj == null)
{
return 0;
}
else
{
return Convert.ToInt32(obj);
}
}
}
#endregion ExtensionMethod
#region 编辑用户状态
///
/// 获取客户信息通过电话号码
///
/// 电话号码
///
public bool EditCustonStatus(string fidStr, int status)
{
bool result = false;
StringBuilder strSql = new StringBuilder();
if (!string.IsNullOrEmpty(fidStr) && status > 0)
{
string statusName = "一般客户";
if (status == 1)
{
statusName = "一般客户";
#region 取消黑名单
try
{
string arrid = "";
foreach (string cid in fidStr.Split(','))
{
arrid += "'" + cid.Trim() + "',";
}
arrid += "!@#";
arrid = arrid.Replace(",!@#", "").Replace("!@#", "");
int c = DbHelperSQL.ExecuteSql("UPDATE [T_Call_Blacklist] SET [F_IsDelete] = 1 WHERE [F_CallId] in(" + arrid + ")");
}
catch
{
}
#endregion
}
else if (status == 2)
{
statusName = "特别关注";
#region 取消黑名单
try
{
string arrid = "";
foreach (string cid in fidStr.Split(','))
{
arrid += "'" + cid.Trim() + "',";
}
arrid += "!@#";
arrid = arrid.Replace(",!@#", "").Replace("!@#", "");
int c = DbHelperSQL.ExecuteSql("UPDATE [T_Call_Blacklist] SET [F_IsDelete] = 1 WHERE [F_CallId] in(" + arrid + ")");
}
catch
{
}
#endregion
}
else if (status == 3)
{
statusName = "黑名单";
#region 添加到黑名单表
DataTable dt = new DataTable();
try
{
dt = GetList(" F_CustomerId in (" + fidStr + ") ").Tables[0];
foreach (DataRow dr in dt.Rows)
{
try
{
string phone = dr["F_Telephone"].ToString();
if (phone == "" || phone == "null")
{
phone = dr["F_Mobile"].ToString();
}
if (phone != "")
{
#region 判断是否为白名单
if (GetRecordCount(string.Format(" F_CustomerClass='白名单' and (F_Telephone='{0}' or F_Mobile='{0}')", phone)) > 0)
{
//白名单不能加入黑名单 客户没有要求,先注释
//continue;
}
#endregion
Model.T_Call_Blacklist orderModel = new Model.T_Call_Blacklist();
orderModel.F_TelPhone = phone;
orderModel.F_CallId = dr["F_CustomerId"].ToString().Trim();
orderModel.F_SetTime = DateTime.Now;
orderModel.F_RemoveTime = DateTime.Now.AddYears(10);
orderModel.F_Describe = "客户id:" + dr["F_CustomerId"].ToString();
orderModel.F_InterceptNum = 0;
int count = new T_Call_Blacklist().Add(orderModel);
}
}
catch
{ }
}
}
catch
{
}
finally
{
dt.Clear();
dt.Dispose();
}
#endregion
}
else if (status == 4)
{
statusName = "白名单";
#region 取消黑名单
try
{
string arrid = "";
foreach (string cid in fidStr.Split(','))
{
arrid += "'" + cid.Trim() + "',";
}
arrid += "!@#";
arrid = arrid.Replace(",!@#", "").Replace("!@#", "");
int c = DbHelperSQL.ExecuteSql("UPDATE [T_Call_Blacklist] SET [F_IsDelete] = 1 WHERE [F_CallId] in(" + arrid + ")");
}
catch
{
}
#endregion
}
strSql.Append("update T_Cus_CustomerBase set ");
strSql.Append("F_ScaleResume=" + status + ",");
strSql.Append("F_CustomerClass='" + statusName + "'");
strSql.Append(" where F_CustomerId in (" + fidStr + ")");
return DbHelperSQL.ExecuteSql(strSql.ToString()) > 0;
}
return result;
}
#endregion
}
}