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/Areas/SoftMng/DAL/company.cs

386 lines
24 KiB
C#

3 years ago
using System;
using System.Text;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Data;
using DSWeb.SoftMng.DBUtility;
// ReSharper disable once CheckNamespace
namespace DSWeb.SoftMng.DAL
{
//company
public partial class companyDAL
{
public bool Exists(string GID)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("select count(1) from [company]");
strSql.Append(" where ");
strSql.Append(" GID = @GID ");
SqlParameter[] parameters = {
new SqlParameter("@GID", SqlDbType.VarChar,36) };
parameters[0].Value = GID;
return DbHelperSQL.Exists(strSql.ToString(),parameters);
}
/// <summary>
/// 增加一条数据
/// </summary>
public int Add(DSWeb.SoftMng.Model.company model)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("insert into [company](");
strSql.Append("GID,CODENAME,NAME,FULLNAME,ENNAME,ADDRESS,ENADDRESS,POSTCODE,OFFICEPHONE,FAX,EMAIL,WEBSITEURL,LICENSECODE,TAXCODE,LOGO,CREATEUSER,CREATETIME,MODIFIEDUSER,MODIFIEDTIME,ISDELETED,ISDISABLE,PARENTID,BILLRISES,CHEQUEPAYABLE,PRTHEADXML1,PRTHEADXML2,PRTHEADXML3,PRTHEADXML4,PRTHEADXML5,BANKSHEAD,GPSUser,GPSPassWord,ORGANIZATIONCODE,FTPURL,DBNAME,LOCALCURR,WORKFLOWMSG,openCustom,isDelegate,allowOpenMark2,TRADE_CODE,UNIT,VGMCODE");
strSql.Append(") values (");
strSql.Append("@GID,@CODENAME,@NAME,@FULLNAME,@ENNAME,@ADDRESS,@ENADDRESS,@POSTCODE,@OFFICEPHONE,@FAX,@EMAIL,@WEBSITEURL,@LICENSECODE,@TAXCODE,@LOGO,@CREATEUSER,@CREATETIME,@MODIFIEDUSER,@MODIFIEDTIME,@ISDELETED,@ISDISABLE,@PARENTID,@BILLRISES,@CHEQUEPAYABLE,@PRTHEADXML1,@PRTHEADXML2,@PRTHEADXML3,@PRTHEADXML4,@PRTHEADXML5,@BANKSHEAD,@GPSUser,@GPSPassWord,@ORGANIZATIONCODE,@FTPURL,@DBNAME,@LOCALCURR,@WORKFLOWMSG,@openCustom,@isDelegate,@allowOpenMark2,@TRADE_CODE,@UNIT,@VGMCODE");
strSql.Append(") ");
SqlParameter[] parameters = {
new SqlParameter("@GID", SqlDbType.VarChar,36) ,
new SqlParameter("@CODENAME", SqlDbType.VarChar,10) ,
new SqlParameter("@NAME", SqlDbType.VarChar,150) ,
new SqlParameter("@FULLNAME", SqlDbType.VarChar,150) ,
new SqlParameter("@ENNAME", SqlDbType.VarChar,150) ,
new SqlParameter("@ADDRESS", SqlDbType.VarChar,100) ,
new SqlParameter("@ENADDRESS", SqlDbType.VarChar,100) ,
new SqlParameter("@POSTCODE", SqlDbType.VarChar,50) ,
new SqlParameter("@OFFICEPHONE", SqlDbType.VarChar,50) ,
new SqlParameter("@FAX", SqlDbType.VarChar,50) ,
new SqlParameter("@EMAIL", SqlDbType.VarChar,100) ,
new SqlParameter("@WEBSITEURL", SqlDbType.VarChar,150) ,
new SqlParameter("@LICENSECODE", SqlDbType.VarChar,30) ,
new SqlParameter("@TAXCODE", SqlDbType.VarChar,30) ,
new SqlParameter("@LOGO", SqlDbType.Image) ,
new SqlParameter("@CREATEUSER", SqlDbType.VarChar,36) ,
new SqlParameter("@CREATETIME", SqlDbType.DateTime) ,
new SqlParameter("@MODIFIEDUSER", SqlDbType.VarChar,36) ,
new SqlParameter("@MODIFIEDTIME", SqlDbType.DateTime) ,
new SqlParameter("@ISDELETED", SqlDbType.Bit,1) ,
new SqlParameter("@ISDISABLE", SqlDbType.Bit,1) ,
new SqlParameter("@PARENTID", SqlDbType.VarChar,36) ,
new SqlParameter("@BILLRISES", SqlDbType.VarChar,60) ,
new SqlParameter("@CHEQUEPAYABLE", SqlDbType.VarChar,60) ,
new SqlParameter("@PRTHEADXML1", SqlDbType.VarChar,1024) ,
new SqlParameter("@PRTHEADXML2", SqlDbType.VarChar,1024) ,
new SqlParameter("@PRTHEADXML3", SqlDbType.VarChar,1024) ,
new SqlParameter("@PRTHEADXML4", SqlDbType.VarChar,1024) ,
new SqlParameter("@PRTHEADXML5", SqlDbType.VarChar,1024) ,
new SqlParameter("@BANKSHEAD", SqlDbType.VarChar,3) ,
new SqlParameter("@GPSUser", SqlDbType.VarChar,20) ,
new SqlParameter("@GPSPassWord", SqlDbType.VarChar,20) ,
new SqlParameter("@ORGANIZATIONCODE", SqlDbType.VarChar,50) ,
new SqlParameter("@FTPURL", SqlDbType.VarChar,200) ,
new SqlParameter("@DBNAME", SqlDbType.VarChar,60) ,
new SqlParameter("@LOCALCURR", SqlDbType.VarChar,30) ,
new SqlParameter("@WORKFLOWMSG", SqlDbType.VarChar,1) ,
new SqlParameter("@openCustom", SqlDbType.Int,4) ,
new SqlParameter("@isDelegate", SqlDbType.Int,4) ,
new SqlParameter("@allowOpenMark2", SqlDbType.Int,4) ,
new SqlParameter("@TRADE_CODE", SqlDbType.VarChar,10) ,
new SqlParameter("@UNIT", SqlDbType.VarChar,4) ,
new SqlParameter("@VGMCODE", SqlDbType.VarChar,30)
};
parameters[0].Value = model.GID??(Object)DBNull.Value;
parameters[1].Value = model.CODENAME??(Object)DBNull.Value;
parameters[2].Value = model.NAME??(Object)DBNull.Value;
parameters[3].Value = model.FULLNAME??(Object)DBNull.Value;
parameters[4].Value = model.ENNAME??(Object)DBNull.Value;
parameters[5].Value = model.ADDRESS??(Object)DBNull.Value;
parameters[6].Value = model.ENADDRESS??(Object)DBNull.Value;
parameters[7].Value = model.POSTCODE??(Object)DBNull.Value;
parameters[8].Value = model.OFFICEPHONE??(Object)DBNull.Value;
parameters[9].Value = model.FAX??(Object)DBNull.Value;
parameters[10].Value = model.EMAIL??(Object)DBNull.Value;
parameters[11].Value = model.WEBSITEURL??(Object)DBNull.Value;
parameters[12].Value = model.LICENSECODE??(Object)DBNull.Value;
parameters[13].Value = model.TAXCODE??(Object)DBNull.Value;
parameters[14].Value = model.LOGO??(Object)DBNull.Value;
parameters[15].Value = model.CREATEUSER??(Object)DBNull.Value;
parameters[16].Value = model.CREATETIME;
parameters[17].Value = model.MODIFIEDUSER??(Object)DBNull.Value;
parameters[18].Value = model.MODIFIEDTIME??(Object)DBNull.Value;
parameters[19].Value = model.ISDELETED??(Object)DBNull.Value;
parameters[20].Value = model.ISDISABLE??(Object)DBNull.Value;
parameters[21].Value = model.PARENTID??(Object)DBNull.Value;
parameters[22].Value = model.BILLRISES??(Object)DBNull.Value;
parameters[23].Value = model.CHEQUEPAYABLE??(Object)DBNull.Value;
parameters[24].Value = model.PRTHEADXML1??(Object)DBNull.Value;
parameters[25].Value = model.PRTHEADXML2??(Object)DBNull.Value;
parameters[26].Value = model.PRTHEADXML3??(Object)DBNull.Value;
parameters[27].Value = model.PRTHEADXML4??(Object)DBNull.Value;
parameters[28].Value = model.PRTHEADXML5??(Object)DBNull.Value;
parameters[29].Value = model.BANKSHEAD??(Object)DBNull.Value;
parameters[30].Value = model.GPSUser??(Object)DBNull.Value;
parameters[31].Value = model.GPSPassWord??(Object)DBNull.Value;
parameters[32].Value = model.ORGANIZATIONCODE??(Object)DBNull.Value;
parameters[33].Value = model.FTPURL??(Object)DBNull.Value;
parameters[34].Value = model.DBNAME??(Object)DBNull.Value;
parameters[35].Value = model.LOCALCURR??(Object)DBNull.Value;
parameters[36].Value = model.WORKFLOWMSG??(Object)DBNull.Value;
parameters[37].Value = model.openCustom;
parameters[38].Value = model.isDelegate;
parameters[39].Value = model.allowOpenMark2;
parameters[40].Value = model.TRADE_CODE??(Object)DBNull.Value;
parameters[41].Value = model.UNIT??(Object)DBNull.Value;
parameters[42].Value = model.VGMCODE??(Object)DBNull.Value;
return DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
}
/// <summary>
/// 更新一条数据
/// </summary>
public int Update(DSWeb.SoftMng.Model.company model)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("update [company] set ");
strSql.Append(" GID = @GID,");
strSql.Append(" CODENAME = @CODENAME,");
strSql.Append(" NAME = @NAME,");
strSql.Append(" FULLNAME = @FULLNAME,");
strSql.Append(" ENNAME = @ENNAME,");
strSql.Append(" ADDRESS = @ADDRESS,");
strSql.Append(" ENADDRESS = @ENADDRESS,");
strSql.Append(" POSTCODE = @POSTCODE,");
strSql.Append(" OFFICEPHONE = @OFFICEPHONE,");
strSql.Append(" FAX = @FAX,");
strSql.Append(" EMAIL = @EMAIL,");
strSql.Append(" WEBSITEURL = @WEBSITEURL,");
strSql.Append(" LICENSECODE = @LICENSECODE,");
strSql.Append(" TAXCODE = @TAXCODE,");
strSql.Append(" LOGO = @LOGO,");
strSql.Append(" CREATEUSER = @CREATEUSER,");
strSql.Append(" CREATETIME = @CREATETIME,");
strSql.Append(" MODIFIEDUSER = @MODIFIEDUSER,");
strSql.Append(" MODIFIEDTIME = @MODIFIEDTIME,");
strSql.Append(" ISDELETED = @ISDELETED,");
strSql.Append(" ISDISABLE = @ISDISABLE,");
strSql.Append(" PARENTID = @PARENTID,");
strSql.Append(" BILLRISES = @BILLRISES,");
strSql.Append(" CHEQUEPAYABLE = @CHEQUEPAYABLE,");
strSql.Append(" PRTHEADXML1 = @PRTHEADXML1,");
strSql.Append(" PRTHEADXML2 = @PRTHEADXML2,");
strSql.Append(" PRTHEADXML3 = @PRTHEADXML3,");
strSql.Append(" PRTHEADXML4 = @PRTHEADXML4,");
strSql.Append(" PRTHEADXML5 = @PRTHEADXML5,");
strSql.Append(" BANKSHEAD = @BANKSHEAD,");
strSql.Append(" GPSUser = @GPSUser,");
strSql.Append(" GPSPassWord = @GPSPassWord,");
strSql.Append(" ORGANIZATIONCODE = @ORGANIZATIONCODE,");
strSql.Append(" FTPURL = @FTPURL,");
strSql.Append(" DBNAME = @DBNAME,");
strSql.Append(" LOCALCURR = @LOCALCURR,");
strSql.Append(" WORKFLOWMSG = @WORKFLOWMSG,");
strSql.Append(" openCustom = @openCustom,");
strSql.Append(" isDelegate = @isDelegate,");
strSql.Append(" allowOpenMark2 = @allowOpenMark2,");
strSql.Append(" TRADE_CODE = @TRADE_CODE,");
strSql.Append(" UNIT = @UNIT,");
strSql.Append(" VGMCODE = @VGMCODE");
strSql.Append(" where GID=@GID ");
SqlParameter[] parameters = {
new SqlParameter("@GID", SqlDbType.VarChar,36) ,
new SqlParameter("@CODENAME", SqlDbType.VarChar,10) ,
new SqlParameter("@NAME", SqlDbType.VarChar,150) ,
new SqlParameter("@FULLNAME", SqlDbType.VarChar,150) ,
new SqlParameter("@ENNAME", SqlDbType.VarChar,150) ,
new SqlParameter("@ADDRESS", SqlDbType.VarChar,100) ,
new SqlParameter("@ENADDRESS", SqlDbType.VarChar,100) ,
new SqlParameter("@POSTCODE", SqlDbType.VarChar,50) ,
new SqlParameter("@OFFICEPHONE", SqlDbType.VarChar,50) ,
new SqlParameter("@FAX", SqlDbType.VarChar,50) ,
new SqlParameter("@EMAIL", SqlDbType.VarChar,100) ,
new SqlParameter("@WEBSITEURL", SqlDbType.VarChar,150) ,
new SqlParameter("@LICENSECODE", SqlDbType.VarChar,30) ,
new SqlParameter("@TAXCODE", SqlDbType.VarChar,30) ,
new SqlParameter("@LOGO", SqlDbType.Image) ,
new SqlParameter("@CREATEUSER", SqlDbType.VarChar,36) ,
new SqlParameter("@CREATETIME", SqlDbType.DateTime) ,
new SqlParameter("@MODIFIEDUSER", SqlDbType.VarChar,36) ,
new SqlParameter("@MODIFIEDTIME", SqlDbType.DateTime) ,
new SqlParameter("@ISDELETED", SqlDbType.Bit,1) ,
new SqlParameter("@ISDISABLE", SqlDbType.Bit,1) ,
new SqlParameter("@PARENTID", SqlDbType.VarChar,36) ,
new SqlParameter("@BILLRISES", SqlDbType.VarChar,60) ,
new SqlParameter("@CHEQUEPAYABLE", SqlDbType.VarChar,60) ,
new SqlParameter("@PRTHEADXML1", SqlDbType.VarChar,1024) ,
new SqlParameter("@PRTHEADXML2", SqlDbType.VarChar,1024) ,
new SqlParameter("@PRTHEADXML3", SqlDbType.VarChar,1024) ,
new SqlParameter("@PRTHEADXML4", SqlDbType.VarChar,1024) ,
new SqlParameter("@PRTHEADXML5", SqlDbType.VarChar,1024) ,
new SqlParameter("@BANKSHEAD", SqlDbType.VarChar,3) ,
new SqlParameter("@GPSUser", SqlDbType.VarChar,20) ,
new SqlParameter("@GPSPassWord", SqlDbType.VarChar,20) ,
new SqlParameter("@ORGANIZATIONCODE", SqlDbType.VarChar,50) ,
new SqlParameter("@FTPURL", SqlDbType.VarChar,200) ,
new SqlParameter("@DBNAME", SqlDbType.VarChar,60) ,
new SqlParameter("@LOCALCURR", SqlDbType.VarChar,30) ,
new SqlParameter("@WORKFLOWMSG", SqlDbType.VarChar,1) ,
new SqlParameter("@openCustom", SqlDbType.Int,4) ,
new SqlParameter("@isDelegate", SqlDbType.Int,4) ,
new SqlParameter("@allowOpenMark2", SqlDbType.Int,4) ,
new SqlParameter("@TRADE_CODE", SqlDbType.VarChar,10) ,
new SqlParameter("@UNIT", SqlDbType.VarChar,4) ,
new SqlParameter("@VGMCODE", SqlDbType.VarChar,30)
};
parameters[0].Value = model.GID??(Object)DBNull.Value;
parameters[1].Value = model.CODENAME??(Object)DBNull.Value;
parameters[2].Value = model.NAME??(Object)DBNull.Value;
parameters[3].Value = model.FULLNAME??(Object)DBNull.Value;
parameters[4].Value = model.ENNAME??(Object)DBNull.Value;
parameters[5].Value = model.ADDRESS??(Object)DBNull.Value;
parameters[6].Value = model.ENADDRESS??(Object)DBNull.Value;
parameters[7].Value = model.POSTCODE??(Object)DBNull.Value;
parameters[8].Value = model.OFFICEPHONE??(Object)DBNull.Value;
parameters[9].Value = model.FAX??(Object)DBNull.Value;
parameters[10].Value = model.EMAIL??(Object)DBNull.Value;
parameters[11].Value = model.WEBSITEURL??(Object)DBNull.Value;
parameters[12].Value = model.LICENSECODE??(Object)DBNull.Value;
parameters[13].Value = model.TAXCODE??(Object)DBNull.Value;
parameters[14].Value = model.LOGO??(Object)DBNull.Value;
parameters[15].Value = model.CREATEUSER??(Object)DBNull.Value;
parameters[16].Value = model.CREATETIME;
parameters[17].Value = model.MODIFIEDUSER??(Object)DBNull.Value;
parameters[18].Value = model.MODIFIEDTIME??(Object)DBNull.Value;
parameters[19].Value = model.ISDELETED??(Object)DBNull.Value;
parameters[20].Value = model.ISDISABLE??(Object)DBNull.Value;
parameters[21].Value = model.PARENTID??(Object)DBNull.Value;
parameters[22].Value = model.BILLRISES??(Object)DBNull.Value;
parameters[23].Value = model.CHEQUEPAYABLE??(Object)DBNull.Value;
parameters[24].Value = model.PRTHEADXML1??(Object)DBNull.Value;
parameters[25].Value = model.PRTHEADXML2??(Object)DBNull.Value;
parameters[26].Value = model.PRTHEADXML3??(Object)DBNull.Value;
parameters[27].Value = model.PRTHEADXML4??(Object)DBNull.Value;
parameters[28].Value = model.PRTHEADXML5??(Object)DBNull.Value;
parameters[29].Value = model.BANKSHEAD??(Object)DBNull.Value;
parameters[30].Value = model.GPSUser??(Object)DBNull.Value;
parameters[31].Value = model.GPSPassWord??(Object)DBNull.Value;
parameters[32].Value = model.ORGANIZATIONCODE??(Object)DBNull.Value;
parameters[33].Value = model.FTPURL??(Object)DBNull.Value;
parameters[34].Value = model.DBNAME??(Object)DBNull.Value;
parameters[35].Value = model.LOCALCURR??(Object)DBNull.Value;
parameters[36].Value = model.WORKFLOWMSG??(Object)DBNull.Value;
parameters[37].Value = model.openCustom;
parameters[38].Value = model.isDelegate;
parameters[39].Value = model.allowOpenMark2;
parameters[40].Value = model.TRADE_CODE??(Object)DBNull.Value;
parameters[41].Value = model.UNIT??(Object)DBNull.Value;
parameters[42].Value = model.VGMCODE??(Object)DBNull.Value;
return DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
}
/// <summary>
/// 删除一条数据
/// </summary>
public int Delete(string GID)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("delete from [company] ");
strSql.Append(" where GID=@GID ");
SqlParameter[] parameters = {
new SqlParameter("@GID", SqlDbType.VarChar,36) };
parameters[0].Value = GID;
return DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
}
/// <summary>
/// 按条件批量删除
/// </summary>
public int DeleteListWhere(string strWhere)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("delete from [company] ");
if(strWhere.Trim()!="")
{
strSql.Append(" where "+strWhere);
}
return DbHelperSQL.ExecuteSql(strSql.ToString());
}
/// <summary>
/// 得到一个对象实体
/// </summary>
public DataSet GetModel(string GID)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("select GID, CODENAME, NAME, FULLNAME, ENNAME, ADDRESS, ENADDRESS, POSTCODE, OFFICEPHONE, FAX, EMAIL, WEBSITEURL, LICENSECODE, TAXCODE, LOGO, CREATEUSER, CREATETIME, MODIFIEDUSER, MODIFIEDTIME, ISDELETED, ISDISABLE, PARENTID, BILLRISES, CHEQUEPAYABLE, PRTHEADXML1, PRTHEADXML2, PRTHEADXML3, PRTHEADXML4, PRTHEADXML5, BANKSHEAD, GPSUser, GPSPassWord, ORGANIZATIONCODE, FTPURL, DBNAME, LOCALCURR, WORKFLOWMSG, openCustom, isDelegate, allowOpenMark2, TRADE_CODE, UNIT, VGMCODE ");
strSql.Append(" from [company] ");
strSql.Append(" where GID=@GID ");
SqlParameter[] parameters = {
new SqlParameter("@GID", SqlDbType.VarChar,36) };
parameters[0].Value = GID;
DSWeb.SoftMng.Model.company model=new DSWeb.SoftMng.Model.company();
return DbHelperSQL.Query(strSql.ToString(),parameters);
}
/// <summary>
/// 获得数据列表
/// </summary>
public DataSet GetList(string strWhere)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("select * ");
strSql.Append(" FROM [company] ");
if(strWhere.Trim()!="")
{
strSql.Append(" where "+strWhere);
}
return DbHelperSQL.Query(strSql.ToString());
}
/// <summary>
/// 获得前几行数据
/// </summary>
public DataSet GetList(int Top,string strWhere,string filedOrder)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("select ");
if(Top>0)
{
strSql.Append(" top "+Top.ToString());
}
strSql.Append(" * ");
strSql.Append(" FROM [company] ");
if(strWhere.Trim()!="")
{
strSql.Append(" where "+strWhere);
}
strSql.Append(" order by " + filedOrder);
return DbHelperSQL.Query(strSql.ToString());
}
/// <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);
strSql.Append(")AS Row, T.* from [company] T ");
if (!string.IsNullOrEmpty(strWhere.Trim()))
{
strSql.Append(" WHERE " + strWhere);
}
strSql.Append(" ) TT");
strSql.AppendFormat(" WHERE TT.Row > {0} and TT.Row <= {1}", startIndex, endIndex);
//公共代码
return DbHelperSQL.Query(strSql.ToString());
}
/// <summary>
/// 获取记录总数
/// </summary>
public int GetRecordCount(string strWhere)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("select count(1) FROM [company] ");
if(strWhere.Trim()!="")
{
strSql.Append(" where "+strWhere);
}
return DbHelperSQL.ExcuteScalarSQL(strSql.ToString());
}
}
}