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.

295 lines
14 KiB
C#

10 months ago
using System;
using System.Data;
using System.Configuration;
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 DSWeb.DataAccess;
using DSWeb.Models;
using System.Data.SqlClient;
using System.Collections.Generic;
namespace DSWeb.EntityDA
{
public class CrmProxyMailDA
{
private const string PARM_MODULE_GID = "@GID";
private const string PARM_MODULE_PORTDISCHARGE = "@PORTDISCHARGE";//卸货港
private const string PARM_MODULE_CARRIE = "@CARRIE"; //船公司
private const string PARM_MODULE_ETD = "@ETD";//开航日
private const string PARM_MODULE_TT = "@TT";//航程
private const string SQL_SELECT_INFO = "select GID,TITLE,CONTENTS,CREATEUSER,CREATETIME,MODIFIEDUSER,MODIFIEDTIME,ISDELETE,DELETETIME,DELETEUSER,ISISSUE,BEGINTIME,ENDTIME,CORPID from crm_proxy_mail where GID=@GID";
private const string SQL_DELETE_INFO = "DELETE FROM crm_proxy_mail WHERE GID=@GID";
private string SQL_INSERT_INFO = "insert into crm_proxy_mail(GID,TITLE,CONTENTS,CREATEUSER,CREATETIME,MODIFIEDUSER,MODIFIEDTIME,ISDELETE,DELETETIME,DELETEUSER,ISISSUE,CORPID) values(@GID,@TITLE,@CONTENTS,@CREATEUSER,getdate(),@MODIFIEDUSER,getdate(),0,getdate(),@DELETEUSER,0,@CORPID)";
private string SQL_UPDATE_INFO = "update crm_proxy_mail set TITLE=@TITLE,CONTENTS=@CONTENTS,MODIFIEDUSER=@MODIFIEDUSER,MODIFIEDTIME=getdate() where GID=@GID";
public CrmProxyMailDA()
{
}
/// <summary>
/// 返回 某字段
/// </summary>
/// <returns></returns>
public string GetStrSQL(string strfield, string strSQL)
{
string alt = "";
DataSet DS = SqlHelper.OpenSqlDataSet(SqlHelper.ConnectionStringLocalTransaction, strSQL);
if (DS != null)
{
if (DS.Tables[0].Rows.Count > 0)
{
alt = DS.Tables[0].Rows[0]["" + strfield + ""].ToString();
}
}
return alt;
}
#region 根据GID获取信息
/// <summary>
/// 根据GID获取信息
/// </summary>
/// <param name="strRoleGID"></param>
/// <returns></returns>
public CrmProxyMailEntity GetID(string strGID)
{
//初始化返回变量
CrmProxyMailEntity CrmProxyMailEntity = null;
//初始化参数并赋值
SqlParameter parm = new SqlParameter(PARM_MODULE_GID, SqlDbType.VarChar, 100);
parm.Value = strGID;
using (SqlDataReader sqlRead = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_SELECT_INFO, parm))
{
try
{
CrmProxyMailEntity = new CrmProxyMailEntity();
//读取字段值
while (sqlRead.Read())
{
if (!sqlRead.IsDBNull(0)) { CrmProxyMailEntity.GID = sqlRead.GetString(0); }// 惟一编号
if (!sqlRead.IsDBNull(1)) { CrmProxyMailEntity.TITLE = sqlRead.GetString(1); }// 标题
if (!sqlRead.IsDBNull(2)) { CrmProxyMailEntity.CONTENTS = sqlRead.GetString(2); }// 内容
if (!sqlRead.IsDBNull(3)) { CrmProxyMailEntity.CREATEUSER = sqlRead.GetString(3); }// 创建人
if (!sqlRead.IsDBNull(4)) { CrmProxyMailEntity.CREATETIME = sqlRead.GetDateTime(4); }// 创建时间
if (!sqlRead.IsDBNull(5)) { CrmProxyMailEntity.MODIFIEDUSER = sqlRead.GetString(5); }// 最后一次更新操作人
if (!sqlRead.IsDBNull(6)) { CrmProxyMailEntity.MODIFIEDTIME = sqlRead.GetDateTime(6); }// 最后一次更新操作时间
if (!sqlRead.IsDBNull(7)) { CrmProxyMailEntity.ISDELETE = sqlRead.GetBoolean(7); }// 是否删除
if (!sqlRead.IsDBNull(8)) { CrmProxyMailEntity.DELETETIME = sqlRead.GetDateTime(8); }// 删除时间
if (!sqlRead.IsDBNull(9)) { CrmProxyMailEntity.DELETEUSER = sqlRead.GetString(9); }// 删除操作人
if (!sqlRead.IsDBNull(10)) { CrmProxyMailEntity.ISISSUE = sqlRead.GetBoolean(10); }// 是否发布
if (!sqlRead.IsDBNull(11)) { CrmProxyMailEntity.BEGINTIME = sqlRead.GetDateTime(11); }//
if (!sqlRead.IsDBNull(12)) { CrmProxyMailEntity.ENDTIME = sqlRead.GetDateTime(12); }//
if (!sqlRead.IsDBNull(13)) { CrmProxyMailEntity.CORPID = sqlRead.GetString(13); }//
}
}
catch (Exception exceError)
{
//抛出异常
throw exceError;
}
}
return CrmProxyMailEntity;
}
#endregion
/// <summary>
/// 插入信息
/// </summary>
/// <param name="infoEntity">实体类</param>
/// <param name="osduEntity">url实体类</param>
/// <returns>值为1插入数据正常,-1操作异常</returns>
public int InserInfo(CrmProxyMailEntity infoEntity)
{
int iResult = 0;
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
{
try
{
#region 插入信息
//获取参数
SqlParameter[] parms = new SqlParameter[]
{
new SqlParameter("@GID",SqlDbType.VarChar,36),//惟一编号
new SqlParameter("@TITLE",SqlDbType.VarChar,100),//标题
new SqlParameter("@CONTENTS",SqlDbType.VarChar,1024),//内容
new SqlParameter("@CREATEUSER",SqlDbType.VarChar,36),//创建人
new SqlParameter("@MODIFIEDUSER",SqlDbType.VarChar,36),//最后一次更新操作人
new SqlParameter("@DELETEUSER",SqlDbType.VarChar,36),//删除操作人
new SqlParameter("@CORPID",SqlDbType.VarChar,36),//
};
parms[0].Value = infoEntity.GID;//惟一编号
parms[1].Value = infoEntity.TITLE;//标题
parms[2].Value = infoEntity.CONTENTS;//内容
parms[3].Value = infoEntity.CREATEUSER;//创建人
parms[4].Value = infoEntity.MODIFIEDUSER;//最后一次更新操作人
parms[5].Value = infoEntity.DELETEUSER;//删除操作人
parms[6].Value = infoEntity.CORPID;//
iResult = -3;//插入信息
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, SQL_INSERT_INFO, parms);
#endregion
//事务提交
sqlTran.Commit();
iResult = 1;//状态为1表示插入成功
}
catch (Exception execError)
{
iResult = -1;//有异常,插入失败
sqlTran.Rollback();
iResult = -2;//插入异常,事务已回滚成功
throw execError;
}
finally
{
SqlHelper.CloseConnection();
}
}
return iResult;
}
/// <summary>
/// 更新信息
/// </summary>
/// <param name="infoEntity">实体类</param>
/// <param name="osduEntity">url实体类</param>
/// <returns></returns>
public int UpdateInfo(CrmProxyMailEntity infoEntity)
{
int iResult = 0;
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
{
try
{
#region 更新信息
//获取参数
SqlParameter[] parms = new SqlParameter[]
{
new SqlParameter("@GID",SqlDbType.VarChar,36),//惟一编号
new SqlParameter("@TITLE",SqlDbType.VarChar,100),//标题
new SqlParameter("@CONTENTS",SqlDbType.VarChar,1024),//内容
new SqlParameter("@MODIFIEDUSER",SqlDbType.VarChar,36),//最后一次更新操作人
};
parms[0].Value = infoEntity.GID;//惟一编号
parms[1].Value = infoEntity.TITLE;//标题
parms[2].Value = infoEntity.CONTENTS;//内容
parms[3].Value = infoEntity.MODIFIEDUSER;//最后一次更新操作人
iResult = -3;//更新信息
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, SQL_UPDATE_INFO, parms);
#endregion
//事务提交
sqlTran.Commit();
iResult = 1;//状态为1表示插入成功
}
catch (Exception execError)
{
iResult = -1;//有异常,插入失败
sqlTran.Rollback();
iResult = -2;//插入异常,事务已回滚成功
throw execError;
}
finally
{
SqlHelper.CloseConnection();
}
}
return iResult;
}
#region 生成更新语句参数
/// <summary>
/// 更新信息
/// </summary>
/// <param name="CrmProxyMailEntity">实体类</param>
/// <returns>值为1更新数据正常,-1操作异常</returns>
public int UpdateInfoCNTRTOTAL(string strSql, string strUserID)
{
int iResult = 0;
//
using (SqlConnection conn = new SqlConnection(SqlHelper.ConnectionStringLocalTransaction))
{
int existVal = SqlHelper.ExecuteNonQuery(conn, CommandType.Text, strSql, null);
if (existVal > 0)
{
iResult = 1;
//
//strSql = strSql.Trim().Replace("'", "''");
//string str0 = "insert into sys_log(NAME,LOGTYPE,LOGCONTENT,CREATEUSER) values('更新所有crm_proxy_mail海运业务预订舱表集装箱字段','更新操作','" + strSql + "','" + strUserID + "')";
//bool bl0 = SqlHelper.ExecuteSqlCommand(SqlHelper.ConnectionStringLocalTransaction, str0);
}
else
{
iResult = -1;//执行异常
}
}
return iResult;
}
#endregion
#region 删除公告管理信息表
/// <summary>
/// 删除公告管理信息表
/// </summary>
/// <param name="strSel">公告管理信息表GID</param>
/// <param name="strUserID">删除人ID</param>
/// <returns>值1表示删除成功 值-1表示有异常删除失败 值-2表示插入异常,事务已回滚成功</returns>
public String GetCrmProxyMailDel(string strSel, string strUserID)
{
string alt = "";
string str = "update crm_proxy_mail set ISDELETE=1,DELETETIME=getdate(),DELETEUSER='"+strUserID+"' where 1=0 " + strSel;
bool bl = SqlHelper.ExecuteSqlCommand(SqlHelper.ConnectionStringLocalTransaction, str);
if (bl == false)
{
alt = "公告管理信息表crm_proxy_mail删除操作出错";
return alt;
}
else
{
//T_ALL_DA T_ALL_DA = new T_ALL_DA();
//strSel = strSel.Trim().Replace("gid", "LINKGID");
//string sSQL = "select * from crm_proxy_mailurl where 1=0 " + strSel;
//DataSet ds = T_ALL_DA.GetAllSQL(sSQL);
//if (ds != null)
//{
// FTPDA FTPDA = new FTPDA();
// FTPDA.ErrorMsg = "";
// FTPDA.Uri = new Uri("ftp://223.7.22.167/");
// if (FTPDA.ErrorMsg.ToString().Trim() != "")
// {
// alt = FTPDA.ErrorMsg.ToString().Trim();
// }
// FTPDA.DirectoryPath = "//PriceCarrier//FTPFiles//";
// FTPDA.UserName = "hmw028167";
// FTPDA.Password = "hmw123456";
// string funame = "";
// //
// for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
// {
// funame = ds.Tables[0].Rows[i]["AFFIXNAME"].ToString().Trim();
// FTPDA.DeleteFile(funame);
// if (FTPDA.ErrorMsg.ToString().Trim() != "")
// {
// alt = FTPDA.ErrorMsg.ToString().Trim();
// }
// }
//}
//
//str = str.Trim().Replace("'", "''");
//string str0 = "insert into sys_log(NAME,LOGTYPE,LOGCONTENT,CREATEUSER) values('删除公告管理信息表crm_proxy_mail','删除操作','" + str + "','" + strUserID + "')";
//bool bl0 = SqlHelper.ExecuteSqlCommand(SqlHelper.ConnectionStringLocalTransaction, str0);
}
return alt;
}
#endregion
//
}
}