You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/EntityDA/CRMInfoClientDA.cs

1419 lines
72 KiB
C#

3 years ago
using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using DSWeb.Models;
using WebSqlHelper;
using System.Data.SqlClient;
using System.Text;
namespace DSWeb.EntityDA
{
//潜在客户信息表
public partial class CRMInfoClientDA
{
string strCrmCsDataName = System.Configuration.ConfigurationSettings.AppSettings["crmCsDataName"].ToString();
/// <summary>
/// 是否存在该条数据
/// </summary>
public bool Exists(string GID)
{
using (SqlConnection conn = new SqlConnection(SqlHelper.ConnectionStringLocalTransaction))
{
string whereInfo = string.Format("GID='{0}'", GID);
StringBuilder strSql = new StringBuilder();
strSql.Append("select GID from crm_info_client");
strSql.Append(" where " + whereInfo);
DataSet ds = SqlHelper.ExecuteDataset(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, strSql.ToString());
if (ds.Tables[0].Rows.Count != 0)
{
return true;
}
else
{
return false;
}
}
}
/// <summary>
/// 是否存在该条数据
/// </summary>
/// <param name="Code">客户代码</param>
/// <returns></returns>
public bool ExistsCode(string code)
{
using (SqlConnection conn = new SqlConnection(SqlHelper.ConnectionStringLocalTransaction))
{
string whereInfo = string.Format("CODENAME='{0}'", code);
StringBuilder strSql = new StringBuilder();
strSql.Append("select GID from crm_info_client");
strSql.Append(" where " + whereInfo);
DataSet ds = SqlHelper.ExecuteDataset(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, strSql.ToString());
if (ds.Tables[0].Rows.Count != 0)
{
return true;
}
else
{
return false;
}
}
}
/// <summary>
/// 是否存在该条数据
/// </summary>
/// <param name="Code">客户名称</param>
/// <returns></returns>
public bool ExistsName(string description)
{
string whereInfo = string.Format("DESCRIPTION='{0}'", description);
using (SqlConnection conn = new SqlConnection(SqlHelper.ConnectionStringLocalTransaction))
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select GID from crm_info_client");
strSql.Append(" where " + whereInfo);
DataSet ds = SqlHelper.ExecuteDataset(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, strSql.ToString());
if (ds.Tables[0].Rows.Count != 0)
{
return true;
}
else
{
return false;
}
}
}
/// <summary>
/// 是否存在该条数据
/// </summary>
/// <param name="Code">客户简称</param>
/// <returns></returns>
public bool ExistsShortName(string shortname)
{
using (SqlConnection conn = new SqlConnection(SqlHelper.ConnectionStringLocalTransaction))
{
string whereInfo = string.Format("SHORTNAME='{0}'", shortname);
StringBuilder strSql = new StringBuilder();
strSql.Append("select GID from crm_info_client");
strSql.Append(" where " + whereInfo);
DataSet ds = SqlHelper.ExecuteDataset(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, strSql.ToString());
if (ds.Tables[0].Rows.Count != 0)
{
return true;
}
else
{
return false;
}
}
}
/// <summary>
/// 增加一条数据
/// </summary>
public int Add(CRMInfoClientEntity model)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("insert into crm_info_client(");
strSql.Append("GID,EMAIL,WEB,TEL,FAX,CHIEF,SALE,CORPID,CODENAME,BLCONTENT,BillRises1,BillRises2,RMBBillRises,RMBBank,RMBAccount,RMBOnlineNO,USDBillRises,USDBank,USDAccount,SHORTNAME,USDOnlineNO,CustomAttributes1,CustomAttributes2,STLNAME,OPNAME,OPTIME,REMARK,USDExchangeRate,DESCRIPTION,MODIFIEDUSER,MODIFIEDTIME,ISJHCU,AREA,PRODUCT,CTNNUM,LANE,NAME,EnFullName,STATUS,ISOFFICIAL,ADDR,ISLANE1,ISLANE2,ISLANE3,ISLANE4,ISLANE5,ISLANE6,ISLANE7,ISLANE8,ISLANE9,ISLANE10,ISLANE11,ISLANE12,ISLANE13,ENFULLNAME2,ENFULLNAME3,IMAGEURL,IMAGEURL2");
strSql.Append(",DeptFrom,Saler,Trade,IsReward,RewardPersent,RewardType,RewardMonth,RewardStart,RewardEnd,WorkshopType,Category,InfoClient,PayCredit,RegMoney,SettlePeriod,CreditMoney,CustomerType,CustomerGrade");
strSql.Append(") values (");
strSql.Append("@GID,@EMAIL,@WEB,@TEL,@FAX,@CHIEF,@SALE,@CORPID,@CODENAME,@BLCONTENT,@BillRises1,@BillRises2,@RMBBillRises,@RMBBank,@RMBAccount,@RMBOnlineNO,@USDBillRises,@USDBank,@USDAccount,@SHORTNAME,@USDOnlineNO,@CustomAttributes1,@CustomAttributes2,@STLNAME,@OPNAME,getdate(),@REMARK,@USDExchangeRate,@DESCRIPTION,@MODIFIEDUSER,getdate(),@ISJHCU,@AREA,@PRODUCT,@CTNNUM,@LANE,@NAME,@EnFullName,@STATUS,@ISOFFICIAL,@ADDR,@ISLANE1,@ISLANE2,@ISLANE3,@ISLANE4,@ISLANE5,@ISLANE6,@ISLANE7,@ISLANE8,@ISLANE9,@ISLANE10,@ISLANE11,@ISLANE12,@ISLANE13,@ENFULLNAME2,@ENFULLNAME3,@IMAGEURL,@IMAGEURL2");
strSql.Append(",@DeptFrom,@Saler,@Trade,@IsReward,@RewardPersent,@RewardType,@RewardMonth,@RewardStart,@RewardEnd,@WorkshopType,@Category,@InfoClient,@PayCredit,@RegMoney,@SettlePeriod,@CreditMoney,@CustomerType,@CustomerGrade");
strSql.Append(") ");
SqlParameter[] parameters = {
new SqlParameter("@GID", SqlDbType.VarChar,100) ,
new SqlParameter("@EMAIL", SqlDbType.VarChar,50) ,
new SqlParameter("@WEB", SqlDbType.VarChar,50) ,
new SqlParameter("@TEL", SqlDbType.VarChar,50) ,
new SqlParameter("@FAX", SqlDbType.VarChar,50) ,
new SqlParameter("@CHIEF", SqlDbType.VarChar,20) ,
new SqlParameter("@SALE", SqlDbType.VarChar,20) ,
new SqlParameter("@CORPID", SqlDbType.VarChar,36) ,
new SqlParameter("@CODENAME", SqlDbType.VarChar,20) ,
new SqlParameter("@BLCONTENT", SqlDbType.VarChar,600) ,
new SqlParameter("@BillRises1", SqlDbType.VarChar,60) ,
new SqlParameter("@BillRises2", SqlDbType.VarChar,60) ,
new SqlParameter("@RMBBillRises", SqlDbType.VarChar,60) ,
new SqlParameter("@RMBBank", SqlDbType.VarChar,60) ,
new SqlParameter("@RMBAccount", SqlDbType.VarChar,30) ,
new SqlParameter("@RMBOnlineNO", SqlDbType.VarChar,20) ,
new SqlParameter("@USDBillRises", SqlDbType.VarChar,60) ,
new SqlParameter("@USDBank", SqlDbType.VarChar,60) ,
new SqlParameter("@USDAccount", SqlDbType.VarChar,30) ,
new SqlParameter("@SHORTNAME", SqlDbType.VarChar,20) ,
new SqlParameter("@USDOnlineNO", SqlDbType.VarChar,20) ,
new SqlParameter("@CustomAttributes1", SqlDbType.VarChar,12) ,
new SqlParameter("@CustomAttributes2", SqlDbType.VarChar,12) ,
new SqlParameter("@STLNAME", SqlDbType.VarChar,30) ,
new SqlParameter("@OPNAME", SqlDbType.VarChar,10) ,
//new SqlParameter("@OPTIME", SqlDbType.DateTime) ,
new SqlParameter("@REMARK", SqlDbType.VarChar,200) ,
new SqlParameter("@USDExchangeRate", SqlDbType.Decimal,9) ,
new SqlParameter("@DESCRIPTION", SqlDbType.VarChar,50) ,
new SqlParameter("@MODIFIEDUSER", SqlDbType.VarChar,36) ,
//new SqlParameter("@MODIFIEDTIME", SqlDbType.DateTime) ,
new SqlParameter("@ISJHCU", SqlDbType.Int,4) ,
new SqlParameter("@AREA", SqlDbType.VarChar,50) ,
new SqlParameter("@PRODUCT", SqlDbType.VarChar,200) ,
new SqlParameter("@CTNNUM", SqlDbType.VarChar,50) ,
new SqlParameter("@LANE", SqlDbType.VarChar,30) ,
new SqlParameter("@NAME", SqlDbType.VarChar,50) ,
new SqlParameter("@EnFullName", SqlDbType.VarChar,50) ,
new SqlParameter("@STATUS", SqlDbType.Int,4) ,
new SqlParameter("@ISOFFICIAL", SqlDbType.Bit,1) ,
new SqlParameter("@ADDR", SqlDbType.VarChar,200) ,
new SqlParameter("@ISLANE1", SqlDbType.Bit,1) ,
new SqlParameter("@ISLANE2", SqlDbType.Bit,1) ,
new SqlParameter("@ISLANE3", SqlDbType.Bit,1) ,
new SqlParameter("@ISLANE4", SqlDbType.Bit,1) ,
new SqlParameter("@ISLANE5", SqlDbType.Bit,1) ,
new SqlParameter("@ISLANE6", SqlDbType.Bit,1) ,
new SqlParameter("@ISLANE7", SqlDbType.Bit,1) ,
new SqlParameter("@ISLANE8", SqlDbType.Bit,1) ,
new SqlParameter("@ISLANE9", SqlDbType.Bit,1) ,
new SqlParameter("@ISLANE10", SqlDbType.Bit,1) ,
new SqlParameter("@ISLANE11", SqlDbType.Bit,1) ,
new SqlParameter("@ISLANE12", SqlDbType.Bit,1) ,
new SqlParameter("@ISLANE13", SqlDbType.Bit,1) ,
new SqlParameter("@ENFULLNAME2", SqlDbType.VarChar,50) ,
new SqlParameter("@ENFULLNAME3", SqlDbType.VarChar,50),
new SqlParameter("@IMAGEURL", SqlDbType.VarChar,100) ,
new SqlParameter("@IMAGEURL2", SqlDbType.VarChar,100) ,
new SqlParameter("@DeptFrom",SqlDbType.VarChar,200),
new SqlParameter("@Saler",SqlDbType.VarChar,200),
new SqlParameter("@Trade",SqlDbType.VarChar,100),
new SqlParameter("@IsReward",SqlDbType.VarChar,10),
new SqlParameter("@RewardPersent",SqlDbType.VarChar,50),
new SqlParameter("@RewardType",SqlDbType.VarChar,100),
new SqlParameter("@RewardMonth",SqlDbType.VarChar,50),
new SqlParameter("@RewardStart",SqlDbType.VarChar,20),
new SqlParameter("@RewardEnd",SqlDbType.VarChar,20),
new SqlParameter("@WorkshopType",SqlDbType.VarChar,50),
new SqlParameter("@Category",SqlDbType.VarChar,100),
new SqlParameter("@InfoClient",SqlDbType.VarChar,100),
new SqlParameter("@PayCredit",SqlDbType.VarChar,50),
new SqlParameter("@RegMoney",SqlDbType.Decimal,9),
new SqlParameter("@SettlePeriod",SqlDbType.Decimal,9),
new SqlParameter("@CreditMoney",SqlDbType.Decimal,9),
new SqlParameter("@CustomerType",SqlDbType.VarChar,50),
new SqlParameter("@CustomerGrade",SqlDbType.VarChar,50)
};
parameters[0].Value = model.GID;
parameters[1].Value = model.EMAIL;
parameters[2].Value = model.WEB;
parameters[3].Value = model.TEL;
parameters[4].Value = model.FAX;
parameters[5].Value = model.CHIEF;
parameters[6].Value = model.SALE;
parameters[7].Value = model.CORPID;
parameters[8].Value = model.CODENAME;
parameters[9].Value = model.BLCONTENT;
parameters[10].Value = model.BillRises1;
parameters[11].Value = model.BillRises2;
parameters[12].Value = model.RMBBillRises;
parameters[13].Value = model.RMBBank;
parameters[14].Value = model.RMBAccount;
parameters[15].Value = model.RMBOnlineNO;
parameters[16].Value = model.USDBillRises;
parameters[17].Value = model.USDBank;
parameters[18].Value = model.USDAccount;
parameters[19].Value = model.SHORTNAME;
parameters[20].Value = model.USDOnlineNO;
parameters[21].Value = model.CustomAttributes1;
parameters[22].Value = model.CustomAttributes2;
parameters[23].Value = model.STLNAME;
parameters[24].Value = model.OPNAME;
//parameters[25].Value = model.OPTIME;
parameters[25].Value = model.REMARK;
parameters[26].Value = model.USDExchangeRate;
parameters[27].Value = model.DESCRIPTION;
parameters[28].Value = model.MODIFIEDUSER;
//parameters[30].Value = model.MODIFIEDTIME;
parameters[29].Value = model.ISJHCU;
parameters[30].Value = model.AREA;
parameters[31].Value = model.PRODUCT;
parameters[32].Value = model.CTNNUM;
parameters[33].Value = model.LANE;
parameters[34].Value = model.NAME;
parameters[35].Value = model.EnFullName;
parameters[36].Value = model.STATUS;
parameters[37].Value = model.ISOFFICIAL;
parameters[38].Value = model.ADDR;
parameters[39].Value = model.ISLANE1;
parameters[40].Value = model.ISLANE2;
parameters[41].Value = model.ISLANE3;
parameters[42].Value = model.ISLANE4;
parameters[43].Value = model.ISLANE5;
parameters[44].Value = model.ISLANE6;
parameters[45].Value = model.ISLANE7;
parameters[46].Value = model.ISLANE8;
parameters[47].Value = model.ISLANE9;
parameters[48].Value = model.ISLANE10;
parameters[49].Value = model.ISLANE11;
parameters[50].Value = model.ISLANE12;
parameters[51].Value = model.ISLANE13;
parameters[52].Value = model.ENFULLNAME2;
parameters[53].Value = model.ENFULLNAME3;
parameters[54].Value = model.IMAGEURL;
parameters[55].Value = model.IMAGEURL2;
parameters[56].Value = model.DeptFrom;
parameters[57].Value = model.Saler;
parameters[58].Value = model.Trade;
parameters[59].Value = model.IsReward;
parameters[60].Value = model.RewardPersent;
parameters[61].Value = model.RewardType;
parameters[62].Value = model.RewardMonth;
parameters[63].Value = model.RewardStart;
parameters[64].Value = model.RewardEnd;
parameters[65].Value = model.WorkshopType;
parameters[66].Value = model.Category;
parameters[67].Value = model.InfoClient;
parameters[68].Value = model.PayCredit;
parameters[69].Value = model.RegMoney;
parameters[70].Value = model.SettlePeriod;
parameters[71].Value = model.CreditMoney;
parameters[72].Value = model.CustomerType;
parameters[73].Value = model.CustomerGrade;
//
int iResult = 0;
using (SqlConnection conn = new SqlConnection(SqlHelper.ConnectionStringLocalTransaction))
{
try
{
int existVal = SqlHelper.ExecuteNonQuery(conn, CommandType.Text, strSql.ToString(), parameters);
if (existVal > 0)
{
iResult = 1;
//
//string str0 = "insert into sys_log(NAME,LOGTYPE,LOGCONTENT,CREATEUSER) values('增加信息','增加操作','GID=" + model.GID.ToString() + "','" + model.MODIFIEDUSER.ToString() + "')";
//bool bl0 = SqlHelper.ExecuteSqlCommand(SqlHelper.ConnectionStringLocalTransaction, str0);
}
else
{
iResult = -1;//执行异常
}
}
catch (Exception e)
{
throw e;
}
}
return iResult;
}
/// <summary>
/// 更新一条数据
/// </summary>
public int Update(CRMInfoClientEntity model)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("update crm_info_client set ");
//strSql.Append(" GID = @GID , ");
strSql.Append(" EMAIL = @EMAIL , ");
strSql.Append(" WEB = @WEB , ");
strSql.Append(" TEL = @TEL , ");
strSql.Append(" FAX = @FAX , ");
strSql.Append(" CHIEF = @CHIEF , ");
//strSql.Append(" SALE = @SALE , ");
strSql.Append(" CORPID = @CORPID , ");
strSql.Append(" CODENAME = @CODENAME , ");
strSql.Append(" BLCONTENT = @BLCONTENT , ");
strSql.Append(" BillRises1 = @BillRises1 , ");
strSql.Append(" BillRises2 = @BillRises2 , ");
strSql.Append(" RMBBillRises = @RMBBillRises , ");
strSql.Append(" RMBBank = @RMBBank , ");
strSql.Append(" RMBAccount = @RMBAccount , ");
strSql.Append(" RMBOnlineNO = @RMBOnlineNO , ");
strSql.Append(" USDBillRises = @USDBillRises , ");
strSql.Append(" USDBank = @USDBank , ");
strSql.Append(" USDAccount = @USDAccount , ");
strSql.Append(" SHORTNAME = @SHORTNAME , ");
strSql.Append(" USDOnlineNO = @USDOnlineNO , ");
strSql.Append(" CustomAttributes1 = @CustomAttributes1 , ");
strSql.Append(" CustomAttributes2 = @CustomAttributes2 , ");
strSql.Append(" STLNAME = @STLNAME , ");
//strSql.Append(" OPNAME = @OPNAME , ");
//strSql.Append(" OPTIME = @OPTIME , ");
strSql.Append(" REMARK = @REMARK , ");
strSql.Append(" USDExchangeRate = @USDExchangeRate , ");
strSql.Append(" DESCRIPTION = @DESCRIPTION , ");
strSql.Append(" MODIFIEDUSER = @MODIFIEDUSER , ");
strSql.Append(" MODIFIEDTIME = getdate() , ");
strSql.Append(" ISJHCU = @ISJHCU , ");
strSql.Append(" AREA = @AREA , ");
strSql.Append(" PRODUCT = @PRODUCT , ");
strSql.Append(" CTNNUM = @CTNNUM , ");
strSql.Append(" LANE = @LANE , ");
strSql.Append(" NAME = @NAME , ");
strSql.Append(" EnFullName = @EnFullName , ");
strSql.Append(" STATUS = @STATUS , ");
strSql.Append(" ISOFFICIAL = @ISOFFICIAL , ");
strSql.Append(" ADDR = @ADDR, ");
strSql.Append(" ENFULLNAME2 = @ENFULLNAME2 , ");
strSql.Append(" ENFULLNAME3 = @ENFULLNAME3 , ");
strSql.Append(" ISLANE1 = @ISLANE1 , ");
strSql.Append(" ISLANE2 = @ISLANE2 , ");
strSql.Append(" ISLANE3 = @ISLANE3 , ");
strSql.Append(" ISLANE4 = @ISLANE4 , ");
strSql.Append(" ISLANE5 = @ISLANE5 , ");
strSql.Append(" ISLANE6 = @ISLANE6 , ");
strSql.Append(" ISLANE7 = @ISLANE7 , ");
strSql.Append(" ISLANE8 = @ISLANE8 , ");
strSql.Append(" ISLANE9 = @ISLANE9 , ");
strSql.Append(" ISLANE10 = @ISLANE10 , ");
strSql.Append(" ISLANE11 = @ISLANE11 , ");
strSql.Append(" ISLANE12 = @ISLANE12 , ");
strSql.Append(" ISLANE13 = @ISLANE13 , ");
strSql.Append(" IMAGEURL = @IMAGEURL , ");
strSql.Append(" IMAGEURL2 = @IMAGEURL2, ");
strSql.Append(" DeptFrom = @DeptFrom, ");
strSql.Append(" Saler = @Saler, ");
strSql.Append(" Trade = @Trade, ");
strSql.Append(" IsReward = @IsReward, ");
strSql.Append(" RewardPersent = @RewardPersent, ");
strSql.Append(" RewardType = @RewardType, ");
strSql.Append(" RewardMonth = @RewardMonth, ");
strSql.Append(" RewardStart = @RewardStart, ");
strSql.Append(" RewardEnd = @RewardEnd, ");
strSql.Append(" WorkshopType = @WorkshopType, ");
strSql.Append(" Category = @Category, ");
strSql.Append(" InfoClient = @InfoClient, ");
strSql.Append(" PayCredit = @PayCredit, ");
strSql.Append(" RegMoney = @RegMoney, ");
strSql.Append(" SettlePeriod = @SettlePeriod, ");
strSql.Append(" CreditMoney = @CreditMoney, ");
strSql.Append(" CustomerType = @CustomerType, ");
strSql.Append(" CustomerGrade = @CustomerGrade ");
strSql.Append(" where GID=@GID ");
SqlParameter[] parameters = {
new SqlParameter("@GID", SqlDbType.VarChar,100) ,
new SqlParameter("@EMAIL", SqlDbType.VarChar,50) ,
new SqlParameter("@WEB", SqlDbType.VarChar,50) ,
new SqlParameter("@TEL", SqlDbType.VarChar,50) ,
new SqlParameter("@FAX", SqlDbType.VarChar,50) ,
new SqlParameter("@CHIEF", SqlDbType.VarChar,20) ,
//new SqlParameter("@SALE", SqlDbType.VarChar,20) ,
new SqlParameter("@CORPID", SqlDbType.VarChar,36) ,
new SqlParameter("@CODENAME", SqlDbType.VarChar,20) ,
new SqlParameter("@BLCONTENT", SqlDbType.VarChar,600) ,
new SqlParameter("@BillRises1", SqlDbType.VarChar,60) ,
new SqlParameter("@BillRises2", SqlDbType.VarChar,60) ,
new SqlParameter("@RMBBillRises", SqlDbType.VarChar,60) ,
new SqlParameter("@RMBBank", SqlDbType.VarChar,60) ,
new SqlParameter("@RMBAccount", SqlDbType.VarChar,30) ,
new SqlParameter("@RMBOnlineNO", SqlDbType.VarChar,20) ,
new SqlParameter("@USDBillRises", SqlDbType.VarChar,60) ,
new SqlParameter("@USDBank", SqlDbType.VarChar,60) ,
new SqlParameter("@USDAccount", SqlDbType.VarChar,30) ,
new SqlParameter("@SHORTNAME", SqlDbType.VarChar,20) ,
new SqlParameter("@USDOnlineNO", SqlDbType.VarChar,20) ,
new SqlParameter("@CustomAttributes1", SqlDbType.VarChar,12) ,
new SqlParameter("@CustomAttributes2", SqlDbType.VarChar,12) ,
new SqlParameter("@STLNAME", SqlDbType.VarChar,30) ,
//new SqlParameter("@OPNAME", SqlDbType.VarChar,10) ,
//new SqlParameter("@OPTIME", SqlDbType.DateTime) ,
new SqlParameter("@REMARK", SqlDbType.VarChar,200) ,
new SqlParameter("@USDExchangeRate", SqlDbType.Decimal,9) ,
new SqlParameter("@DESCRIPTION", SqlDbType.VarChar,50) ,
new SqlParameter("@MODIFIEDUSER", SqlDbType.VarChar,36) ,
//new SqlParameter("@MODIFIEDTIME", SqlDbType.DateTime) ,
new SqlParameter("@ISJHCU", SqlDbType.Int,4) ,
new SqlParameter("@AREA", SqlDbType.VarChar,50) ,
new SqlParameter("@PRODUCT", SqlDbType.VarChar,200) ,
new SqlParameter("@CTNNUM", SqlDbType.VarChar,50) ,
new SqlParameter("@LANE", SqlDbType.VarChar,30) ,
new SqlParameter("@NAME", SqlDbType.VarChar,50) ,
new SqlParameter("@EnFullName", SqlDbType.VarChar,50) ,
new SqlParameter("@STATUS", SqlDbType.Int,4) ,
new SqlParameter("@ISOFFICIAL", SqlDbType.Bit,1) ,
new SqlParameter("@ADDR", SqlDbType.VarChar,200) ,
new SqlParameter("@ENFULLNAME2", SqlDbType.VarChar,50) ,
new SqlParameter("@ENFULLNAME3", SqlDbType.VarChar,50),
new SqlParameter("@ISLANE1", SqlDbType.Bit,1) ,
new SqlParameter("@ISLANE2", SqlDbType.Bit,1) ,
new SqlParameter("@ISLANE3", SqlDbType.Bit,1) ,
new SqlParameter("@ISLANE4", SqlDbType.Bit,1) ,
new SqlParameter("@ISLANE5", SqlDbType.Bit,1) ,
new SqlParameter("@ISLANE6", SqlDbType.Bit,1) ,
new SqlParameter("@ISLANE7", SqlDbType.Bit,1) ,
new SqlParameter("@ISLANE8", SqlDbType.Bit,1) ,
new SqlParameter("@ISLANE9", SqlDbType.Bit,1) ,
new SqlParameter("@ISLANE10", SqlDbType.Bit,1) ,
new SqlParameter("@ISLANE11", SqlDbType.Bit,1) ,
new SqlParameter("@ISLANE12", SqlDbType.Bit,1) ,
new SqlParameter("@ISLANE13", SqlDbType.Bit,1) ,
new SqlParameter("@IMAGEURL", SqlDbType.VarChar,100) ,
new SqlParameter("@IMAGEURL2", SqlDbType.VarChar,100) ,
new SqlParameter("@DeptFrom",SqlDbType.VarChar,200),
new SqlParameter("@Saler",SqlDbType.VarChar,200),
new SqlParameter("@Trade",SqlDbType.VarChar,100),
new SqlParameter("@IsReward",SqlDbType.VarChar,10),
new SqlParameter("@RewardPersent",SqlDbType.VarChar,50),
new SqlParameter("@RewardType",SqlDbType.VarChar,100),
new SqlParameter("@RewardMonth",SqlDbType.VarChar,50),
new SqlParameter("@RewardStart",SqlDbType.VarChar,20),
new SqlParameter("@RewardEnd",SqlDbType.VarChar,20),
new SqlParameter("@WorkshopType",SqlDbType.VarChar,50),
new SqlParameter("@Category",SqlDbType.VarChar,100),
new SqlParameter("@InfoClient",SqlDbType.VarChar,100),
new SqlParameter("@PayCredit",SqlDbType.VarChar,50),
new SqlParameter("@RegMoney",SqlDbType.Decimal,9),
new SqlParameter("@SettlePeriod",SqlDbType.Decimal,9),
new SqlParameter("@CreditMoney",SqlDbType.Decimal,9),
new SqlParameter("@CustomerType",SqlDbType.VarChar,50),
new SqlParameter("@CustomerGrade",SqlDbType.VarChar,50)
};
parameters[0].Value = model.GID;
parameters[1].Value = model.EMAIL;
parameters[2].Value = model.WEB;
parameters[3].Value = model.TEL;
parameters[4].Value = model.FAX;
parameters[5].Value = model.CHIEF;
//parameters[6].Value = model.SALE;
parameters[6].Value = model.CORPID;
parameters[7].Value = model.CODENAME;
parameters[8].Value = model.BLCONTENT;
parameters[9].Value = model.BillRises1;
parameters[10].Value = model.BillRises2;
parameters[11].Value = model.RMBBillRises;
parameters[12].Value = model.RMBBank;
parameters[13].Value = model.RMBAccount;
parameters[14].Value = model.RMBOnlineNO;
parameters[15].Value = model.USDBillRises;
parameters[16].Value = model.USDBank;
parameters[17].Value = model.USDAccount;
parameters[18].Value = model.SHORTNAME;
parameters[19].Value = model.USDOnlineNO;
parameters[20].Value = model.CustomAttributes1;
parameters[21].Value = model.CustomAttributes2;
parameters[22].Value = model.STLNAME;
//parameters[24].Value = model.OPNAME;
//parameters[25].Value = model.OPTIME;
parameters[23].Value = model.REMARK;
parameters[24].Value = model.USDExchangeRate;
parameters[25].Value = model.DESCRIPTION;
parameters[26].Value = model.MODIFIEDUSER;
//parameters[30].Value = model.MODIFIEDTIME;
parameters[27].Value = model.ISJHCU;
parameters[28].Value = model.AREA;
parameters[29].Value = model.PRODUCT;
parameters[30].Value = model.CTNNUM;
parameters[31].Value = model.LANE;
parameters[32].Value = model.NAME;
parameters[33].Value = model.EnFullName;
parameters[34].Value = model.STATUS;
parameters[35].Value = model.ISOFFICIAL;
parameters[36].Value = model.ADDR;
parameters[37].Value = model.ENFULLNAME2;
parameters[38].Value = model.ENFULLNAME3;
parameters[39].Value = model.ISLANE1;
parameters[40].Value = model.ISLANE2;
parameters[41].Value = model.ISLANE3;
parameters[42].Value = model.ISLANE4;
parameters[43].Value = model.ISLANE5;
parameters[44].Value = model.ISLANE6;
parameters[45].Value = model.ISLANE7;
parameters[46].Value = model.ISLANE8;
parameters[47].Value = model.ISLANE9;
parameters[48].Value = model.ISLANE10;
parameters[49].Value = model.ISLANE11;
parameters[50].Value = model.ISLANE12;
parameters[51].Value = model.ISLANE13;
parameters[52].Value = model.IMAGEURL;
parameters[53].Value = model.IMAGEURL2;
parameters[54].Value = model.DeptFrom;
parameters[55].Value = model.Saler;
parameters[56].Value = model.Trade;
parameters[57].Value = model.IsReward;
parameters[58].Value = model.RewardPersent;
parameters[59].Value = model.RewardType;
parameters[60].Value = model.RewardMonth;
parameters[61].Value = model.RewardStart;
parameters[62].Value = model.RewardEnd;
parameters[63].Value = model.WorkshopType;
parameters[64].Value = model.Category;
parameters[65].Value = model.InfoClient;
parameters[66].Value = model.PayCredit;
parameters[67].Value = model.RegMoney;
parameters[68].Value = model.SettlePeriod;
parameters[69].Value = model.CreditMoney;
parameters[70].Value = model.CustomerType;
parameters[71].Value = model.CustomerGrade;
//
int iResult = 0;
using (SqlConnection conn = new SqlConnection(SqlHelper.ConnectionStringLocalTransaction))
{
int existVal = SqlHelper.ExecuteNonQuery(conn, CommandType.Text, strSql.ToString(), parameters);
if (existVal > 0)
{
iResult = 1;
//
//string str0 = "insert into sys_log(NAME,LOGTYPE,LOGCONTENT,CREATEUSER) values('更新信息表','更新操作','GID=" + model.GID.ToString() + "','" + model.MODIFIEDUSER.ToString() + "')";
//bool bl0 = SqlHelper.ExecuteSqlCommand(SqlHelper.ConnectionStringLocalTransaction, str0);
}
else
{
iResult = -1;//执行异常
}
}
return iResult;
}
/// <summary>
/// 删除一条数据
/// </summary>
public int Delete(string GID)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("delete from crm_info_client ");
strSql.Append(" where GID=@GID ");
SqlParameter[] parameters = {
new SqlParameter("@GID", SqlDbType.VarChar,100) };
parameters[0].Value = GID;
//
int iResult = 0;
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
{
int existVal = SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, strSql.ToString(), parameters);
if (existVal > 0)
{
iResult = 1;
}
else
{
iResult = -1;//删除失败
}
}
return iResult;
}
/// <summary>
/// 批量删除数据
/// </summary>
public bool DeleteList(string GIDlist)
{
using (SqlConnection conn = new SqlConnection(SqlHelper.ConnectionStringLocalTransaction))
{
StringBuilder strSql = new StringBuilder();
strSql.Append("delete from crm_info_client ");
strSql.Append(" where GID in (" + GIDlist + ") ");
int rows = SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, strSql.ToString());
if (rows > 0)
{
return true;
}
else
{
return false;
}
}
}
/// <summary>
/// 执行数据操作,返回是否成功
/// </summary>
public bool updateList(string strSql)
{
using (SqlConnection conn = new SqlConnection(SqlHelper.ConnectionStringLocalTransaction))
{
int rows = SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, strSql);
if (rows > 0)
{
return true;
}
else
{
return false;
}
}
}
/// <summary>
/// 批量分配客户数据,用事务
/// </summary>
/// <param name="strGids">多个gid组成的字符串例如 111,222,333</param>
/// <returns></returns>
public string SetAssign(string GIDlist, string strSALE, string strShowName)
{
int iResult = 0;
T_ALL_DA T_ALL_DA = new T_ALL_DA();
string alt = T_ALL_DA.GetStrSQL("SHORTNAME", "select SHORTNAME from crm_info_client where GID='" + GIDlist + "'");
//
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
{
try
{
string strSql = "";
strSql = "update crm_info_client_Assign set MODIFIEDTIME=getdate() where CLIENTGID='" + GIDlist + "' and SALE=(select SALE from crm_info_client where GID='" + GIDlist + "') and (MODIFIEDTIME is null or MODIFIEDTIME='') ";
iResult = -2;
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, strSql.ToString(), null);
strSql = "insert into crm_info_client_Assign(GID,CLIENTGID,SHORTNAME,SALE,CREATEUSER,CREATETIME) values(newid(),'" + GIDlist + "','" + alt + "','" + strSALE + "','" + strShowName + "',getdate())";
iResult = -3;
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, strSql.ToString(), null);
strSql = "update crm_info_client set SALE='" + strSALE + "' where GID='" + GIDlist + "'";
iResult = -4;
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, strSql.ToString(), null);
//事务提交
sqlTran.Commit();
iResult = 1;//状态为1表示插入成功
alt = "";
}
catch (Exception)
{
iResult = -1;//有异常,插入失败
sqlTran.Rollback();
iResult = -2;//插入异常,事务已回滚成功
//throw e;
}
finally
{
SqlHelper.CloseConnection();
}
}
return alt;
}
/// <summary>
/// 得到一个对象实体
/// </summary>
public CRMInfoClientEntity GetModel(string GID)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select GID, EMAIL, WEB, TEL, FAX, CHIEF, SALE, CORPID, CODENAME, BLCONTENT, BillRises1, BillRises2, RMBBillRises, RMBBank, RMBAccount, RMBOnlineNO, USDBillRises, USDBank, USDAccount, SHORTNAME, USDOnlineNO, CustomAttributes1, CustomAttributes2, STLNAME, OPNAME, OPTIME, REMARK, USDExchangeRate, DESCRIPTION, MODIFIEDUSER, MODIFIEDTIME, ISJHCU, AREA, PRODUCT, CTNNUM, LANE, NAME, EnFullName, STATUS, ISOFFICIAL, ADDR,ISLANE1,ISLANE2,ISLANE3,ISLANE4,ISLANE5,ISLANE6,ISLANE7,ISLANE8,ISLANE9,ISLANE10,ISLANE11,ISLANE12,ISLANE13,ENFULLNAME2,ENFULLNAME3,IMAGEURL,IMAGEURL2 ");
strSql.Append(",DeptFrom,Saler,Trade,IsReward,RewardPersent,RewardType,RewardMonth,RewardStart,RewardEnd,WorkshopType,Category,InfoClient,PayCredit,RegMoney,SettlePeriod,CreditMoney,CustomerType,CustomerGrade");
strSql.Append(" from crm_info_client ");
strSql.Append(" where GID=@GID ");
SqlParameter[] parameters = {
new SqlParameter("@GID", SqlDbType.VarChar,100) };
parameters[0].Value = GID;
CRMInfoClientEntity model = new CRMInfoClientEntity();
DataSet ds = SqlHelper.Query(strSql.ToString(), parameters);
if (ds.Tables[0].Rows.Count > 0)
{
model.GID = ds.Tables[0].Rows[0]["GID"].ToString();
model.EMAIL = ds.Tables[0].Rows[0]["EMAIL"].ToString();
model.WEB = ds.Tables[0].Rows[0]["WEB"].ToString();
model.TEL = ds.Tables[0].Rows[0]["TEL"].ToString();
model.FAX = ds.Tables[0].Rows[0]["FAX"].ToString();
model.CHIEF = ds.Tables[0].Rows[0]["CHIEF"].ToString();
model.SALE = ds.Tables[0].Rows[0]["SALE"].ToString();
model.CORPID = ds.Tables[0].Rows[0]["CORPID"].ToString();
model.CODENAME = ds.Tables[0].Rows[0]["CODENAME"].ToString();
model.BLCONTENT = ds.Tables[0].Rows[0]["BLCONTENT"].ToString();
model.BillRises1 = ds.Tables[0].Rows[0]["BillRises1"].ToString();
model.BillRises2 = ds.Tables[0].Rows[0]["BillRises2"].ToString();
model.RMBBillRises = ds.Tables[0].Rows[0]["RMBBillRises"].ToString();
model.RMBBank = ds.Tables[0].Rows[0]["RMBBank"].ToString();
model.RMBAccount = ds.Tables[0].Rows[0]["RMBAccount"].ToString();
model.RMBOnlineNO = ds.Tables[0].Rows[0]["RMBOnlineNO"].ToString();
model.USDBillRises = ds.Tables[0].Rows[0]["USDBillRises"].ToString();
model.USDBank = ds.Tables[0].Rows[0]["USDBank"].ToString();
model.USDAccount = ds.Tables[0].Rows[0]["USDAccount"].ToString();
model.SHORTNAME = ds.Tables[0].Rows[0]["SHORTNAME"].ToString();
model.USDOnlineNO = ds.Tables[0].Rows[0]["USDOnlineNO"].ToString();
model.CustomAttributes1 = ds.Tables[0].Rows[0]["CustomAttributes1"].ToString();
model.CustomAttributes2 = ds.Tables[0].Rows[0]["CustomAttributes2"].ToString();
model.STLNAME = ds.Tables[0].Rows[0]["STLNAME"].ToString();
model.OPNAME = ds.Tables[0].Rows[0]["OPNAME"].ToString();
if (ds.Tables[0].Rows[0]["OPTIME"].ToString() != "")
{
model.OPTIME = DateTime.Parse(ds.Tables[0].Rows[0]["OPTIME"].ToString());
}
model.REMARK = ds.Tables[0].Rows[0]["REMARK"].ToString();
if (ds.Tables[0].Rows[0]["USDExchangeRate"].ToString() != "")
{
model.USDExchangeRate = decimal.Parse(ds.Tables[0].Rows[0]["USDExchangeRate"].ToString());
}
model.DESCRIPTION = ds.Tables[0].Rows[0]["DESCRIPTION"].ToString();
model.MODIFIEDUSER = ds.Tables[0].Rows[0]["MODIFIEDUSER"].ToString();
if (ds.Tables[0].Rows[0]["MODIFIEDTIME"].ToString() != "")
{
model.MODIFIEDTIME = DateTime.Parse(ds.Tables[0].Rows[0]["MODIFIEDTIME"].ToString());
}
if (ds.Tables[0].Rows[0]["ISJHCU"].ToString() != "")
{
model.ISJHCU = int.Parse(ds.Tables[0].Rows[0]["ISJHCU"].ToString());
}
model.AREA = ds.Tables[0].Rows[0]["AREA"].ToString();
model.PRODUCT = ds.Tables[0].Rows[0]["PRODUCT"].ToString();
model.CTNNUM = ds.Tables[0].Rows[0]["CTNNUM"].ToString();
model.LANE = ds.Tables[0].Rows[0]["LANE"].ToString();
model.NAME = ds.Tables[0].Rows[0]["NAME"].ToString();
model.EnFullName = ds.Tables[0].Rows[0]["EnFullName"].ToString();
if (ds.Tables[0].Rows[0]["STATUS"].ToString() != "")
{
model.STATUS = int.Parse(ds.Tables[0].Rows[0]["STATUS"].ToString());
}
if (ds.Tables[0].Rows[0]["ISOFFICIAL"].ToString() != "")
{
if ((ds.Tables[0].Rows[0]["ISOFFICIAL"].ToString() == "1") || (ds.Tables[0].Rows[0]["ISOFFICIAL"].ToString().ToLower() == "true"))
{
model.ISOFFICIAL = true;
}
else
{
model.ISOFFICIAL = false;
}
}
model.ADDR = ds.Tables[0].Rows[0]["ADDR"].ToString();
//
if (ds.Tables[0].Rows[0]["ISLANE1"].ToString() != "")
{
if ((ds.Tables[0].Rows[0]["ISLANE1"].ToString() == "1") || (ds.Tables[0].Rows[0]["ISLANE1"].ToString().ToLower() == "true"))
{
model.ISLANE1 = true;
}
else
{
model.ISLANE1 = false;
}
}
model.NAME = ds.Tables[0].Rows[0]["NAME"].ToString();
if (ds.Tables[0].Rows[0]["ISLANE2"].ToString() != "")
{
if ((ds.Tables[0].Rows[0]["ISLANE2"].ToString() == "1") || (ds.Tables[0].Rows[0]["ISLANE2"].ToString().ToLower() == "true"))
{
model.ISLANE2 = true;
}
else
{
model.ISLANE2 = false;
}
}
if (ds.Tables[0].Rows[0]["ISLANE3"].ToString() != "")
{
if ((ds.Tables[0].Rows[0]["ISLANE3"].ToString() == "1") || (ds.Tables[0].Rows[0]["ISLANE3"].ToString().ToLower() == "true"))
{
model.ISLANE3 = true;
}
else
{
model.ISLANE3 = false;
}
}
if (ds.Tables[0].Rows[0]["ISLANE4"].ToString() != "")
{
if ((ds.Tables[0].Rows[0]["ISLANE4"].ToString() == "1") || (ds.Tables[0].Rows[0]["ISLANE4"].ToString().ToLower() == "true"))
{
model.ISLANE4 = true;
}
else
{
model.ISLANE4 = false;
}
}
if (ds.Tables[0].Rows[0]["ISLANE5"].ToString() != "")
{
if ((ds.Tables[0].Rows[0]["ISLANE5"].ToString() == "1") || (ds.Tables[0].Rows[0]["ISLANE5"].ToString().ToLower() == "true"))
{
model.ISLANE5 = true;
}
else
{
model.ISLANE5 = false;
}
}
if (ds.Tables[0].Rows[0]["ISLANE6"].ToString() != "")
{
if ((ds.Tables[0].Rows[0]["ISLANE6"].ToString() == "1") || (ds.Tables[0].Rows[0]["ISLANE6"].ToString().ToLower() == "true"))
{
model.ISLANE6 = true;
}
else
{
model.ISLANE6 = false;
}
}
if (ds.Tables[0].Rows[0]["ISLANE7"].ToString() != "")
{
if ((ds.Tables[0].Rows[0]["ISLANE7"].ToString() == "1") || (ds.Tables[0].Rows[0]["ISLANE7"].ToString().ToLower() == "true"))
{
model.ISLANE7 = true;
}
else
{
model.ISLANE7 = false;
}
}
if (ds.Tables[0].Rows[0]["ISLANE8"].ToString() != "")
{
if ((ds.Tables[0].Rows[0]["ISLANE8"].ToString() == "1") || (ds.Tables[0].Rows[0]["ISLANE8"].ToString().ToLower() == "true"))
{
model.ISLANE8 = true;
}
else
{
model.ISLANE8 = false;
}
}
if (ds.Tables[0].Rows[0]["ISLANE9"].ToString() != "")
{
if ((ds.Tables[0].Rows[0]["ISLANE9"].ToString() == "1") || (ds.Tables[0].Rows[0]["ISLANE9"].ToString().ToLower() == "true"))
{
model.ISLANE9 = true;
}
else
{
model.ISLANE9 = false;
}
}
if (ds.Tables[0].Rows[0]["ISLANE10"].ToString() != "")
{
if ((ds.Tables[0].Rows[0]["ISLANE10"].ToString() == "1") || (ds.Tables[0].Rows[0]["ISLANE10"].ToString().ToLower() == "true"))
{
model.ISLANE10 = true;
}
else
{
model.ISLANE10 = false;
}
}
if (ds.Tables[0].Rows[0]["ISLANE11"].ToString() != "")
{
if ((ds.Tables[0].Rows[0]["ISLANE11"].ToString() == "1") || (ds.Tables[0].Rows[0]["ISLANE11"].ToString().ToLower() == "true"))
{
model.ISLANE11 = true;
}
else
{
model.ISLANE11 = false;
}
}
if (ds.Tables[0].Rows[0]["ISLANE12"].ToString() != "")
{
if ((ds.Tables[0].Rows[0]["ISLANE12"].ToString() == "1") || (ds.Tables[0].Rows[0]["ISLANE12"].ToString().ToLower() == "true"))
{
model.ISLANE12 = true;
}
else
{
model.ISLANE12 = false;
}
}
if (ds.Tables[0].Rows[0]["ISLANE13"].ToString() != "")
{
if ((ds.Tables[0].Rows[0]["ISLANE13"].ToString() == "1") || (ds.Tables[0].Rows[0]["ISLANE13"].ToString().ToLower() == "true"))
{
model.ISLANE13 = true;
}
else
{
model.ISLANE13 = false;
}
}
model.ENFULLNAME2 = ds.Tables[0].Rows[0]["ENFULLNAME2"].ToString();
model.ENFULLNAME3 = ds.Tables[0].Rows[0]["ENFULLNAME3"].ToString();
model.IMAGEURL = ds.Tables[0].Rows[0]["IMAGEURL"].ToString();
model.IMAGEURL2 = ds.Tables[0].Rows[0]["IMAGEURL2"].ToString();
model.DeptFrom = ds.Tables[0].Rows[0]["DeptFrom"].ToString();
model.Saler = ds.Tables[0].Rows[0]["Saler"].ToString();
model.Trade = ds.Tables[0].Rows[0]["Trade"].ToString();
model.IsReward =ds.Tables[0].Rows[0]["IsReward"].ToString();
model.RewardPersent = ds.Tables[0].Rows[0]["RewardPersent"].ToString();
model.RewardType = ds.Tables[0].Rows[0]["RewardType"].ToString();
model.RewardMonth = ds.Tables[0].Rows[0]["RewardMonth"].ToString();
model.RewardStart = ds.Tables[0].Rows[0]["RewardStart"].ToString();
model.RewardEnd = ds.Tables[0].Rows[0]["RewardEnd"].ToString();
model.WorkshopType = ds.Tables[0].Rows[0]["WorkshopType"].ToString();
model.Category = ds.Tables[0].Rows[0]["Category"].ToString();
model.InfoClient = ds.Tables[0].Rows[0]["InfoClient"].ToString();
model.PayCredit = ds.Tables[0].Rows[0]["PayCredit"].ToString();
model.RegMoney =Convert.ToDecimal( ds.Tables[0].Rows[0]["RegMoney"].ToString());
model.SettlePeriod = Convert.ToDecimal(ds.Tables[0].Rows[0]["SettlePeriod"].ToString());
model.CreditMoney = Convert.ToDecimal(ds.Tables[0].Rows[0]["CreditMoney"].ToString());
model.CustomerType = ds.Tables[0].Rows[0]["CustomerType"].ToString();
model.CustomerGrade = ds.Tables[0].Rows[0]["CustomerGrade"].ToString();
return model;
}
else
{
return null;
}
}
/// <summary>
/// 得到一个top1对象实体
/// </summary>
public CRMInfoClientEntity GetModelTop1()
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select top 1 GID, EMAIL, WEB, TEL, FAX, CHIEF, SALE, CORPID, CODENAME, BLCONTENT, BillRises1, BillRises2, RMBBillRises, RMBBank, RMBAccount, RMBOnlineNO, USDBillRises, USDBank, USDAccount, SHORTNAME, USDOnlineNO, CustomAttributes1, CustomAttributes2, STLNAME, OPNAME, OPTIME, REMARK, USDExchangeRate, DESCRIPTION, MODIFIEDUSER, MODIFIEDTIME, ISJHCU, AREA, PRODUCT, CTNNUM, LANE, NAME, EnFullName, STATUS, ISOFFICIAL, ADDR,ISLANE1,ISLANE2,ISLANE3,ISLANE4,ISLANE5,ISLANE6,ISLANE7,ISLANE8,ENFULLNAME2,ENFULLNAME3,IMAGEURL,IMAGEURL2 ");
strSql.Append(" from crm_info_client ");
CRMInfoClientEntity model = new CRMInfoClientEntity();
DataSet ds = SqlHelper.Query(strSql.ToString(), null);
if (ds.Tables[0].Rows.Count > 0)
{
model.GID = ds.Tables[0].Rows[0]["GID"].ToString();
model.EMAIL = ds.Tables[0].Rows[0]["EMAIL"].ToString();
model.WEB = ds.Tables[0].Rows[0]["WEB"].ToString();
model.TEL = ds.Tables[0].Rows[0]["TEL"].ToString();
model.FAX = ds.Tables[0].Rows[0]["FAX"].ToString();
model.CHIEF = ds.Tables[0].Rows[0]["CHIEF"].ToString();
model.SALE = ds.Tables[0].Rows[0]["SALE"].ToString();
model.CORPID = ds.Tables[0].Rows[0]["CORPID"].ToString();
model.CODENAME = ds.Tables[0].Rows[0]["CODENAME"].ToString();
model.BLCONTENT = ds.Tables[0].Rows[0]["BLCONTENT"].ToString();
model.BillRises1 = ds.Tables[0].Rows[0]["BillRises1"].ToString();
model.BillRises2 = ds.Tables[0].Rows[0]["BillRises2"].ToString();
model.RMBBillRises = ds.Tables[0].Rows[0]["RMBBillRises"].ToString();
model.RMBBank = ds.Tables[0].Rows[0]["RMBBank"].ToString();
model.RMBAccount = ds.Tables[0].Rows[0]["RMBAccount"].ToString();
model.RMBOnlineNO = ds.Tables[0].Rows[0]["RMBOnlineNO"].ToString();
model.USDBillRises = ds.Tables[0].Rows[0]["USDBillRises"].ToString();
model.USDBank = ds.Tables[0].Rows[0]["USDBank"].ToString();
model.USDAccount = ds.Tables[0].Rows[0]["USDAccount"].ToString();
model.SHORTNAME = ds.Tables[0].Rows[0]["SHORTNAME"].ToString();
model.USDOnlineNO = ds.Tables[0].Rows[0]["USDOnlineNO"].ToString();
model.CustomAttributes1 = ds.Tables[0].Rows[0]["CustomAttributes1"].ToString();
model.CustomAttributes2 = ds.Tables[0].Rows[0]["CustomAttributes2"].ToString();
model.STLNAME = ds.Tables[0].Rows[0]["STLNAME"].ToString();
model.OPNAME = ds.Tables[0].Rows[0]["OPNAME"].ToString();
if (ds.Tables[0].Rows[0]["OPTIME"].ToString() != "")
{
model.OPTIME = DateTime.Parse(ds.Tables[0].Rows[0]["OPTIME"].ToString());
}
model.REMARK = ds.Tables[0].Rows[0]["REMARK"].ToString();
if (ds.Tables[0].Rows[0]["USDExchangeRate"].ToString() != "")
{
model.USDExchangeRate = decimal.Parse(ds.Tables[0].Rows[0]["USDExchangeRate"].ToString());
}
model.DESCRIPTION = ds.Tables[0].Rows[0]["DESCRIPTION"].ToString();
model.MODIFIEDUSER = ds.Tables[0].Rows[0]["MODIFIEDUSER"].ToString();
if (ds.Tables[0].Rows[0]["MODIFIEDTIME"].ToString() != "")
{
model.MODIFIEDTIME = DateTime.Parse(ds.Tables[0].Rows[0]["MODIFIEDTIME"].ToString());
}
if (ds.Tables[0].Rows[0]["ISJHCU"].ToString() != "")
{
model.ISJHCU = int.Parse(ds.Tables[0].Rows[0]["ISJHCU"].ToString());
}
model.AREA = ds.Tables[0].Rows[0]["AREA"].ToString();
model.PRODUCT = ds.Tables[0].Rows[0]["PRODUCT"].ToString();
model.CTNNUM = ds.Tables[0].Rows[0]["CTNNUM"].ToString();
model.LANE = ds.Tables[0].Rows[0]["LANE"].ToString();
model.NAME = ds.Tables[0].Rows[0]["NAME"].ToString();
model.EnFullName = ds.Tables[0].Rows[0]["EnFullName"].ToString();
if (ds.Tables[0].Rows[0]["STATUS"].ToString() != "")
{
model.STATUS = int.Parse(ds.Tables[0].Rows[0]["STATUS"].ToString());
}
if (ds.Tables[0].Rows[0]["ISOFFICIAL"].ToString() != "")
{
if ((ds.Tables[0].Rows[0]["ISOFFICIAL"].ToString() == "1") || (ds.Tables[0].Rows[0]["ISOFFICIAL"].ToString().ToLower() == "true"))
{
model.ISOFFICIAL = true;
}
else
{
model.ISOFFICIAL = false;
}
}
model.ADDR = ds.Tables[0].Rows[0]["ADDR"].ToString();
//
if (ds.Tables[0].Rows[0]["ISLANE1"].ToString() != "")
{
if ((ds.Tables[0].Rows[0]["ISLANE1"].ToString() == "1") || (ds.Tables[0].Rows[0]["ISLANE1"].ToString().ToLower() == "true"))
{
model.ISLANE1 = true;
}
else
{
model.ISLANE1 = false;
}
}
model.NAME = ds.Tables[0].Rows[0]["NAME"].ToString();
if (ds.Tables[0].Rows[0]["ISLANE2"].ToString() != "")
{
if ((ds.Tables[0].Rows[0]["ISLANE2"].ToString() == "1") || (ds.Tables[0].Rows[0]["ISLANE2"].ToString().ToLower() == "true"))
{
model.ISLANE2 = true;
}
else
{
model.ISLANE2 = false;
}
}
if (ds.Tables[0].Rows[0]["ISLANE3"].ToString() != "")
{
if ((ds.Tables[0].Rows[0]["ISLANE3"].ToString() == "1") || (ds.Tables[0].Rows[0]["ISLANE3"].ToString().ToLower() == "true"))
{
model.ISLANE3 = true;
}
else
{
model.ISLANE3 = false;
}
}
if (ds.Tables[0].Rows[0]["ISLANE4"].ToString() != "")
{
if ((ds.Tables[0].Rows[0]["ISLANE4"].ToString() == "1") || (ds.Tables[0].Rows[0]["ISLANE4"].ToString().ToLower() == "true"))
{
model.ISLANE4 = true;
}
else
{
model.ISLANE4 = false;
}
}
if (ds.Tables[0].Rows[0]["ISLANE5"].ToString() != "")
{
if ((ds.Tables[0].Rows[0]["ISLANE5"].ToString() == "1") || (ds.Tables[0].Rows[0]["ISLANE5"].ToString().ToLower() == "true"))
{
model.ISLANE5 = true;
}
else
{
model.ISLANE5 = false;
}
}
if (ds.Tables[0].Rows[0]["ISLANE6"].ToString() != "")
{
if ((ds.Tables[0].Rows[0]["ISLANE6"].ToString() == "1") || (ds.Tables[0].Rows[0]["ISLANE6"].ToString().ToLower() == "true"))
{
model.ISLANE6 = true;
}
else
{
model.ISLANE6 = false;
}
}
if (ds.Tables[0].Rows[0]["ISLANE7"].ToString() != "")
{
if ((ds.Tables[0].Rows[0]["ISLANE7"].ToString() == "1") || (ds.Tables[0].Rows[0]["ISLANE7"].ToString().ToLower() == "true"))
{
model.ISLANE7 = true;
}
else
{
model.ISLANE7 = false;
}
}
if (ds.Tables[0].Rows[0]["ISLANE8"].ToString() != "")
{
if ((ds.Tables[0].Rows[0]["ISLANE8"].ToString() == "1") || (ds.Tables[0].Rows[0]["ISLANE8"].ToString().ToLower() == "true"))
{
model.ISLANE8 = true;
}
else
{
model.ISLANE8 = false;
}
}
model.ENFULLNAME2 = ds.Tables[0].Rows[0]["ENFULLNAME2"].ToString();
model.ENFULLNAME3 = ds.Tables[0].Rows[0]["ENFULLNAME3"].ToString();
model.IMAGEURL = ds.Tables[0].Rows[0]["IMAGEURL"].ToString();
model.IMAGEURL2 = ds.Tables[0].Rows[0]["IMAGEURL2"].ToString();
model.DeptFrom = ds.Tables[0].Rows[0]["DeptFrom"].ToString();
model.Saler = ds.Tables[0].Rows[0]["Saler"].ToString();
model.Trade = ds.Tables[0].Rows[0]["Trade"].ToString();
model.IsReward = ds.Tables[0].Rows[0]["IsReward"].ToString();
model.RewardPersent = ds.Tables[0].Rows[0]["RewardPersent"].ToString();
model.RewardType = ds.Tables[0].Rows[0]["RewardType"].ToString();
model.RewardMonth = ds.Tables[0].Rows[0]["RewardMonth"].ToString();
model.RewardStart = ds.Tables[0].Rows[0]["RewardStart"].ToString();
model.RewardEnd = ds.Tables[0].Rows[0]["RewardEnd"].ToString();
model.WorkshopType = ds.Tables[0].Rows[0]["WorkshopType"].ToString();
model.Category = ds.Tables[0].Rows[0]["Category"].ToString();
model.InfoClient = ds.Tables[0].Rows[0]["InfoClient"].ToString();
model.PayCredit = ds.Tables[0].Rows[0]["PayCredit"].ToString();
model.RegMoney = Convert.ToDecimal(ds.Tables[0].Rows[0]["RegMoney"].ToString());
model.SettlePeriod = Convert.ToDecimal(ds.Tables[0].Rows[0]["SettlePeriod"].ToString());
model.CreditMoney = Convert.ToDecimal(ds.Tables[0].Rows[0]["CreditMoney"].ToString());
model.CustomerType = ds.Tables[0].Rows[0]["CustomerType"].ToString();
model.CustomerGrade = ds.Tables[0].Rows[0]["CustomerGrade"].ToString();
return model;
}
else
{
return null;
}
}
/// <summary>
/// 获得数据列表
/// </summary>
public DataSet GetList(string strSql)
{
return SqlHelper.ExecuteDataset(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, strSql.ToString());
}
/// <summary>
/// 获得前n行数据
/// </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 crm_info_client ");
if (strWhere.Trim() != "")
{
strSql.Append(" where " + strWhere);
}
strSql.Append(" order by " + filedOrder);
return SqlHelper.ExecuteDataset(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, strSql.ToString());
}
/// <summary>
/// 获取记录总数
/// </summary>
public int GetRecordCount(string strSql)
{
object obj = SqlHelper.GetSingle(SqlHelper.ConnectionStringLocalTransaction, 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.GID desc");
}
strSql.Append(")AS Row, T.* from crm_info_client 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 SqlHelper.ExecuteDataset(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, strSql.ToString());
}
/// <summary>
/// 分页获取数据列表
/// </summary>
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 = "crm_info_client";
parameters[1].Value = "GID";
parameters[2].Value = PageSize;
parameters[3].Value = PageIndex;
parameters[4].Value = 0;
parameters[5].Value = 0;
parameters[6].Value = strWhere;
return SqlHelper.RunProcedure(SqlHelper.ConnectionStringLocalTransaction.ToString(), "UP_GetRecordByPage", parameters, "ds");
}
/// <summary>
/// 更改转正的数据
/// </summary>
public int SetIsJHCUupdate(string strGID, string strShowName)
{
int iResult = 0;
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
{
try
{
//string strSql = "Update [" + strCrmCsDataName + "].[dbo].[t_crm_client] SET "
// + " [代码]=CODENAME,[客户全称]=DESCRIPTION,[通讯地址]=ADDR,[邮箱]=EMAIL,[网站]=WEB,[电话]=TEL,[传真]=FAX,[揽货人]=CHIEF,[法人]=SALE"
// + ",[开户行USD]=USDBank,[帐号USD]=USDAccount,[开户行RMB]=RMBBank,[帐号RMB]=RMBAccount,[发票抬头]=BillRises1,[业务货量]=CTNNUM"
// + ",[出口区域]=(case ISLANE1 when 1 then '非洲,' else '' end)+(case ISLANE2 when 1 then '澳洲,' else '' end)+(case ISLANE3 when 1 then '黑海,' else '' end)+(case ISLANE4 when 1 then '欧洲,' else '' end)+(case ISLANE5 when 1 then '印巴,' else '' end)+(case ISLANE6 when 1 then '日本,' else '' end)+(case ISLANE7 when 1 then '韩国,' else '' end)+(case ISLANE8 when 1 then '中东,' else '' end)+(case ISLANE9 when 1 then '红海,' else '' end)+(case ISLANE10 when 1 then '东南亚,' else '' end)+(case ISLANE11 when 1 then '南美,' else '' end)+(case ISLANE12 when 1 then '台湾,' else '' end)+(case ISLANE13 when 1 then '美加' else '' end)"
// + ",[业务区域]=AREA,[出口箱型]=CTNNUM,[货物名称]=PRODUCT,[录入人]='" + strShowName + "',[录入日期]=getdate(),[备注]=REMARK,[美元支票抬头]=USDBillRises,[人民币支票抬头]=RMBBillRises,[税率]=USDExchangeRate,[纳税类型]= '一般纳税人' "
// + "FROM [" + strCrmCsDataName + "].[dbo].[t_crm_client] A LEFT JOIN [ShippingWeb].[dbo].[crm_info_client] B ON B.SHORTNAME=A.[客户简称] where A.[客户简称]=b.SHORTNAME and b.ISJHCU=1 and b.GID in (" + strGID + ")";
string strSql = "Update [info_client] SET "
+ " CODENAME=B.CODENAME,DESCRIPTION=B.DESCRIPTION,ADDR=B.ADDR,EMAIL=B.EMAIL,WEB=B.WEB,TEL=B.TEL,FAX=B.FAX,CHIEF=B.CHIEF,SALE=B.SALE"
+ ",USDBank=B.USDBank,USDAccount=B.USDAccount,RMBBank=B.RMBBank,RMBAccount=B.RMBAccount,BillRises1=B.BillRises1"
+ ",OPNAME='" + strShowName + "',OPTIME=getdate(),REMARK=B.REMARK,USDBillRises=B.USDBillRises,RMBBillRises=B.RMBBillRises,USDExchangeRate=B.USDExchangeRate "
+ " FROM [info_client] A LEFT JOIN [crm_info_client] B ON B.SHORTNAME=A.SHORTNAME where A.SHORTNAME=b.SHORTNAME and b.ISJHCU=1 and b.GID in (" + strGID + ")";
iResult = -2;
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, strSql.ToString(), null);
strSql = "update [crm_info_client] set ISJHCU=2 where GID in (" + strGID + ") and ISJHCU=1";
iResult = -3;
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, strSql.ToString(), null);
//事务提交
sqlTran.Commit();
iResult = 1;//状态为1表示插入成功
}
catch (Exception)
{
iResult = -1;//有异常,插入失败
sqlTran.Rollback();
iResult = -2;//插入异常,事务已回滚成功
//throw e;
}
finally
{
SqlHelper.CloseConnection();
}
}
return iResult;
}
/// <summary>
/// 插入转正的数据
/// </summary>
public int SetIsJHCU(string strGID, string strShowName)
{
int iResult = 0;
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
{
try
{
//string strSql = "INSERT INTO [" + strCrmCsDataName + "].[dbo].[t_crm_client]"
// + " ([代码],[客户简称],[客户全称],[通讯地址],[邮箱],[网站],[电话],[传真],[揽货人],[法人]"
// + ",[开户行USD],[帐号USD],[开户行RMB],[帐号RMB],[发票抬头],[业务货量]"
// + ",[出口区域]"
// + ",[业务区域],[出口箱型],[货物名称],[录入人],[录入日期],[备注]"
// + ",[美元支票抬头],[人民币支票抬头],[税率],[纳税类型])"
// + " select CODENAME,SHORTNAME,DESCRIPTION,ADDR,EMAIL,WEB,TEL,FAX,CHIEF,SALE"
// + ",USDBank,USDAccount,RMBBank,RMBAccount,BillRises1,CTNNUM"
// + ",(case ISLANE1 when 1 then '非洲,' else '' end)"
// + "+(case ISLANE2 when 1 then '澳洲,' else '' end)"
// + "+(case ISLANE3 when 1 then '黑海,' else '' end)"
// + "+(case ISLANE4 when 1 then '欧洲,' else '' end)"
// + "+(case ISLANE5 when 1 then '印巴,' else '' end)"
// + "+(case ISLANE6 when 1 then '日本,' else '' end)"
// + "+(case ISLANE7 when 1 then '韩国,' else '' end)"
// + "+(case ISLANE8 when 1 then '中东,' else '' end)"
// + "+(case ISLANE9 when 1 then '红海,' else '' end)"
// + "+(case ISLANE10 when 1 then '东南亚,' else '' end)"
// + "+(case ISLANE11 when 1 then '南美,' else '' end)"
// + "+(case ISLANE12 when 1 then '台湾,' else '' end)"
// + "+(case ISLANE13 when 1 then '美加' else '' end) as [出口区域]"
// + ",AREA,CTNNUM,PRODUCT,'" + strShowName + "',getdate() as [录入日期],REMARK"
// + ",USDBillRises,RMBBillRises,USDExchangeRate,'一般纳税人' as [纳税类型] "
// + " from [ShippingWeb].[dbo].[crm_info_client] "
// + " where GID in (" + strGID + ") and ISJHCU=1";
string strSql = "INSERT INTO info_client"
+ " (GID,CODENAME,SHORTNAME,DESCRIPTION,ADDR,EMAIL,WEB,TEL,FAX,CHIEF,SALE"
+ ",USDBank,USDAccount,RMBBank,RMBAccount,BillRises1"
+ ",OPNAME,OPTIME,REMARK"
+ ",USDBillRises,RMBBillRises,USDExchangeRate) "
+ " select NEWID(),CODENAME,SHORTNAME,DESCRIPTION,ADDR,EMAIL,WEB,TEL,FAX,CHIEF,SALE"
+ ",USDBank,USDAccount,RMBBank,RMBAccount,BillRises1"
+ ",'" + strShowName + "',getdate(),REMARK"
+ ",USDBillRises,RMBBillRises,USDExchangeRate "
+ " from [crm_info_client] "
+ " where GID in (" + strGID + ") and ISJHCU=1";
iResult = -2;
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, strSql.ToString(), null);
strSql = "update [crm_info_client] set ISJHCU=2 where GID in (" + strGID + ") and ISJHCU=1";
iResult = -3;
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, strSql.ToString(), null);
//事务提交
sqlTran.Commit();
iResult = 1;//状态为1表示插入成功
}
catch (Exception)
{
iResult = -1;//有异常,插入失败
sqlTran.Rollback();
iResult = -2;//插入异常,事务已回滚成功
//throw e;
}
finally
{
SqlHelper.CloseConnection();
}
}
return iResult;
}
/// <summary>
/// 返回 某字段
/// </summary>
/// <returns></returns>
public string GetStrSQL(string strfield, string strSQL)
{
string alt = "";
DataSet DS = SqlHelper.OpenSqlDataSet(SqlHelper.ConnectionStringLocalTransaction, strSQL);//CS数据库dongsheng连接串
if (DS != null)
{
if (DS.Tables[0].Rows.Count > 0)
{
alt = DS.Tables[0].Rows[0]["" + strfield + ""].ToString();
}
}
return alt;
}
//
}
}