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.
191 lines
8.4 KiB
C#
191 lines
8.4 KiB
C#
using System;
|
|
using System.Data;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using DSWeb.MvcShipping.Models.SysInvInterFaceSet;
|
|
using Microsoft.Practices.EnterpriseLibrary.Data;
|
|
using DSWeb.Areas.CommMng.Models;
|
|
using HcUtility.Comm;
|
|
using DSWeb.MvcShipping.DAL.MsSysParamSet;
|
|
|
|
namespace DSWeb.MvcShipping.DAL.MsSysInvInterFaceSet
|
|
{
|
|
public class MsSysInvInterFaceSetDAL
|
|
{
|
|
#region Inquery DataList
|
|
|
|
static public List<SysInvInterFaceSet> GetDataList(string strCondition, string companyid, string sort = null)
|
|
{
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT GID,INVOICELINE,INVITERFACE,[CREATEUSER]");
|
|
strSql.Append(",[CREATETIME],[MODIFIEDUSER],[MODIFIEDTIME],[COMPANYID],NUONUOAPPKEY,NUONUOAPPSECRET,extensionNumber");
|
|
strSql.Append(",(select ShowName from [user] where GID=sys_inv_interfaceset.CREATEUSER) as CREATEUSERREF");
|
|
strSql.Append(",CORPID,(select Name from [company] where GID=sys_inv_interfaceset.CORPID) as COMPANYNAME");
|
|
strSql.Append(" from sys_inv_interfaceset where 1=1 ");
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" and " + strCondition);
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(companyid))
|
|
{
|
|
strSql.Append($" and CORPID='{companyid}'");
|
|
}
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
{
|
|
strSql.Append(" order by " + sortstring);
|
|
}
|
|
else
|
|
{
|
|
strSql.Append(" order by INVOICELINE");
|
|
|
|
}
|
|
return SetData(strSql);
|
|
}
|
|
|
|
static public SysInvInterFaceSet GetData(string condition, string companyid)
|
|
{
|
|
SysInvInterFaceSet data = null;
|
|
var list = GetDataList(condition, companyid);
|
|
if (list.Count > 0)
|
|
data = list[0];
|
|
|
|
if (data == null)
|
|
{
|
|
data = new SysInvInterFaceSet();
|
|
}
|
|
|
|
return data;
|
|
}
|
|
|
|
|
|
private static List<SysInvInterFaceSet> SetData(StringBuilder strSql)
|
|
{
|
|
var headList = new List<SysInvInterFaceSet>();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
SysInvInterFaceSet data = new SysInvInterFaceSet();
|
|
#region Set DB data to Object
|
|
data.GID = Convert.ToString(reader["GID"]);
|
|
data.INVOICELINE = Convert.ToString(reader["INVOICELINE"]);
|
|
data.INVITERFACE = Convert.ToString(reader["INVITERFACE"]);
|
|
data.CREATEUSER = Convert.ToString(reader["CREATEUSER"]);
|
|
data.CREATEUSERREF = Convert.ToString(reader["CREATEUSERREF"]);
|
|
if (reader["CREATETIME"] != DBNull.Value)
|
|
data.CREATETIME = Convert.ToDateTime(reader["CREATETIME"]).ToString("yyyy-MM-dd HH:mm:ss");
|
|
data.COMPANYID = Convert.ToString(reader["COMPANYID"]);
|
|
data.NUONUOAPPKEY = Convert.ToString(reader["NUONUOAPPKEY"]);
|
|
data.NUONUOAPPSECRET = Convert.ToString(reader["NUONUOAPPSECRET"]);
|
|
data.CORPID = Convert.ToString(reader["CORPID"]);
|
|
data.extensionNumber = Convert.ToString(reader["extensionNumber"]);
|
|
|
|
data.COMPANYNAME = Convert.ToString(reader["COMPANYNAME"]);
|
|
#endregion
|
|
headList.Add(data);
|
|
}
|
|
reader.Close();
|
|
}
|
|
return headList;
|
|
}
|
|
#endregion
|
|
|
|
public static DBResult SaveDetail(List<SysInvInterFaceSet> bodyList, string companyid, string userid, string LOCALCURR)
|
|
{
|
|
var result = new DBResult();
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
|
|
var cmdInsert =
|
|
db.GetSqlStringCommand(
|
|
@"insert into sys_inv_interfaceset (GID,INVOICELINE,INVITERFACE,COMPANYID,CREATEUSER,CREATETIME,NUONUOAPPKEY,NUONUOAPPSECRET,CORPID,extensionNumber)
|
|
values (@GID,@INVOICELINE,@INVITERFACE,@COMPANYID,@CREATEUSER,@CREATETIME,@NUONUOAPPKEY,@NUONUOAPPSECRET,@CORPID,@extensionNumber) ");
|
|
|
|
var cmdUpdate =
|
|
db.GetSqlStringCommand(
|
|
@"update sys_inv_interfaceset set INVOICELINE=@INVOICELINE,INVITERFACE=@INVITERFACE,MODIFIEDUSER=@MODIFIEDUSER,MODIFIEDTIME=@MODIFIEDTIME,NUONUOAPPKEY=@NUONUOAPPKEY,NUONUOAPPSECRET=@NUONUOAPPSECRET,CORPID=@CORPID,extensionNumber=@extensionNumber where GID=@GID ");
|
|
|
|
if (bodyList != null)
|
|
{
|
|
foreach (var enumValue in bodyList)
|
|
{
|
|
|
|
|
|
|
|
if (enumValue.GID == "*" || enumValue.GID == "")
|
|
{
|
|
cmdInsert.Parameters.Clear();
|
|
db.AddInParameter(cmdInsert, "@GID", DbType.String, Guid.NewGuid().ToString());
|
|
db.AddInParameter(cmdInsert, "@INVOICELINE", DbType.String, enumValue.INVOICELINE);
|
|
db.AddInParameter(cmdInsert, "@INVITERFACE", DbType.String, enumValue.INVITERFACE);
|
|
db.AddInParameter(cmdInsert, "@CREATETIME", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
db.AddInParameter(cmdInsert, "@CREATEUSER", DbType.String, userid);
|
|
db.AddInParameter(cmdInsert, "@COMPANYID", DbType.String, companyid);
|
|
db.AddInParameter(cmdInsert, "@NUONUOAPPKEY", DbType.String, enumValue.NUONUOAPPKEY);
|
|
db.AddInParameter(cmdInsert, "@NUONUOAPPSECRET", DbType.String, enumValue.NUONUOAPPSECRET);
|
|
db.AddInParameter(cmdInsert, "@CORPID", DbType.String, enumValue.CORPID);
|
|
db.AddInParameter(cmdInsert, "@extensionNumber", DbType.String, enumValue.extensionNumber);
|
|
db.ExecuteNonQuery(cmdInsert, tran);
|
|
}
|
|
else
|
|
{
|
|
|
|
cmdUpdate.Parameters.Clear();
|
|
|
|
db.AddInParameter(cmdUpdate, "@INVOICELINE", DbType.String, enumValue.INVOICELINE);
|
|
db.AddInParameter(cmdUpdate, "@INVITERFACE", DbType.String, enumValue.INVITERFACE);
|
|
db.AddInParameter(cmdUpdate, "@MODIFIEDTIME", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
db.AddInParameter(cmdUpdate, "@MODIFIEDUSER", DbType.String, userid);
|
|
db.AddInParameter(cmdUpdate, "@NUONUOAPPKEY", DbType.String, enumValue.NUONUOAPPKEY);
|
|
db.AddInParameter(cmdUpdate, "@NUONUOAPPSECRET", DbType.String, enumValue.NUONUOAPPSECRET);
|
|
db.AddInParameter(cmdUpdate, "@CORPID", DbType.String, enumValue.CORPID);
|
|
db.AddInParameter(cmdUpdate, "@extensionNumber", DbType.String, enumValue.extensionNumber);
|
|
db.AddInParameter(cmdUpdate, "@GID", DbType.String, enumValue.GID);
|
|
db.ExecuteNonQuery(cmdUpdate, tran);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
tran.Commit();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "保存出现错误<" + e.Message + ">,请重试或联系系统管理员";
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
result.Success = true;
|
|
result.Message = "保存成功" + result.Message;
|
|
|
|
return result;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|