You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
216 lines
8.0 KiB
216 lines
8.0 KiB
1 year ago
|
using CK.SCP.Models;
|
||
|
using CK.SCP.Models.ExchangeCenterTables;
|
||
|
using CK.SCP.Utils;
|
||
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Data;
|
||
|
using System.Data.Entity.Migrations;
|
||
|
using System.Data.SqlClient;
|
||
|
using System.Linq;
|
||
|
using System.Text;
|
||
|
using System.Threading.Tasks;
|
||
|
|
||
|
namespace CK.SCP.Controller
|
||
|
{
|
||
|
public class UN_EC_CONTROLLER_TRANSFER
|
||
|
{
|
||
|
public static void Get_TED_TRANSFER_MSTR_List(TED_TRANSFER_MSTR p_entity, Action<ResultObject<IQueryable<TED_TRANSFER_MSTR>>> p_action)
|
||
|
{
|
||
|
ResultObject<IQueryable<TED_TRANSFER_MSTR>> _ret = new ResultObject<IQueryable<TED_TRANSFER_MSTR>>();
|
||
|
try
|
||
|
{
|
||
|
using (var db = EntitiesFactory.CreateExchangeCenterInstance())
|
||
|
{
|
||
|
IQueryable<TED_TRANSFER_MSTR> q = db.TED_TRANSFER_MSTR;
|
||
|
if (!string.IsNullOrEmpty(p_entity.User))
|
||
|
{
|
||
|
q = q.Where(p => p.User.Contains(p_entity.User));
|
||
|
}
|
||
|
if (!string.IsNullOrEmpty(p_entity.TransferBillNum))
|
||
|
{
|
||
|
q = q.Where(p => p.TransferBillNum.Contains(p_entity.TransferBillNum));
|
||
|
}
|
||
|
if (!string.IsNullOrEmpty(p_entity.CustomerNbr))
|
||
|
{
|
||
|
q = q.Where(p => p.CustomerNbr.Contains(p_entity.CustomerNbr));
|
||
|
}
|
||
|
if (!string.IsNullOrEmpty(p_entity.Remarks))
|
||
|
{
|
||
|
q = q.Where(p => p.Remarks.Contains(p_entity.Remarks));
|
||
|
}
|
||
|
if (p_entity.UID != 0)
|
||
|
{
|
||
|
q = q.Where(p => p.UID == p_entity.UID);
|
||
|
}
|
||
|
if (!string.IsNullOrEmpty(p_entity.CreateUser))
|
||
|
{
|
||
|
q = q.Where(p => p.CreateUser.Contains(p_entity.CreateUser));
|
||
|
}
|
||
|
if (!string.IsNullOrEmpty(p_entity.Remark))
|
||
|
{
|
||
|
q = q.Where(p => p.Remark.Contains(p_entity.Remark));
|
||
|
}
|
||
|
if (!string.IsNullOrEmpty(p_entity.CommandType))
|
||
|
{
|
||
|
q = q.Where(p => p.CommandType.Contains(p_entity.CommandType));
|
||
|
}
|
||
|
if (!string.IsNullOrEmpty(p_entity.Domain))
|
||
|
{
|
||
|
q = q.Where(p => p.Domain.Contains(p_entity.Domain));
|
||
|
}
|
||
|
if (!string.IsNullOrEmpty(p_entity.Site))
|
||
|
{
|
||
|
q = q.Where(p => p.Site.Contains(p_entity.Site));
|
||
|
}
|
||
|
if (p_entity.GUID != Guid.Empty)
|
||
|
{
|
||
|
q = q.Where(p => p.GUID == p_entity.GUID);
|
||
|
}
|
||
|
if (p_entity.TaskID != Guid.Empty)
|
||
|
{
|
||
|
q = q.Where(p => p.TaskID == p_entity.TaskID);
|
||
|
}
|
||
|
if (p_entity.DataID != Guid.Empty)
|
||
|
{
|
||
|
q = q.Where(p => p.DataID == p_entity.DataID);
|
||
|
}
|
||
|
if (p_entity.ActiveDate != DateTime.MinValue)
|
||
|
{
|
||
|
q = q.Where(p => p.ActiveDate.Year == p_entity.ActiveDate.Year && p.ActiveDate.Month == p_entity.ActiveDate.Month && p.ActiveDate.Day == p_entity.ActiveDate.Day);
|
||
|
|
||
|
}
|
||
|
if (p_entity.Time != DateTime.MinValue)
|
||
|
{
|
||
|
q = q.Where(p => p.Time.Year == p_entity.Time.Year && p.Time.Month == p_entity.Time.Month && p.Time.Day == p_entity.Time.Day);
|
||
|
}
|
||
|
if (p_entity.CreateTime != DateTime.MinValue)
|
||
|
{
|
||
|
|
||
|
q = q.Where(p => p.CreateTime.Year == p_entity.CreateTime.Year && p.CreateTime.Day == p_entity.CreateTime.Day && p.CreateTime.Month == p_entity.CreateTime.Month);
|
||
|
}
|
||
|
|
||
|
_ret.Result = q;
|
||
|
_ret.State = ReturnStatus.Succeed;
|
||
|
|
||
|
p_action(_ret);
|
||
|
}
|
||
|
}
|
||
|
catch (Exception e)
|
||
|
{
|
||
|
_ret.State = ReturnStatus.Failed;
|
||
|
_ret.ErrorList.Add(e);
|
||
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(TED_TRANSFER_MSTR), "Get_TED_TRANSFER_MSTR_List", e.Message);
|
||
|
throw e;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
public static DataTable Get_TED_TRANSFER_List(string p_tableName, int p_UID)
|
||
|
{
|
||
|
DataTable dt = new DataTable(); ;
|
||
|
var dbSetting = GlobalConfig.ExchangeCenterDB;
|
||
|
try
|
||
|
{
|
||
|
|
||
|
var strConn = EntitiesFactory.GetEfConnectionString(dbSetting);
|
||
|
SqlConnection conn = new System.Data.SqlClient.SqlConnection();
|
||
|
|
||
|
conn.ConnectionString = strConn;
|
||
|
|
||
|
if (conn.State != ConnectionState.Open)
|
||
|
{
|
||
|
conn.Open();
|
||
|
}
|
||
|
SqlCommand cmd = new SqlCommand();
|
||
|
|
||
|
cmd.Connection = conn;
|
||
|
string _sql = string.Format("select * from {0} where UID='{1}'", p_tableName, p_UID);
|
||
|
|
||
|
cmd.CommandText = _sql;
|
||
|
|
||
|
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
|
||
|
|
||
|
adapter.Fill(dt);
|
||
|
|
||
|
}
|
||
|
catch (SqlException ex)
|
||
|
{
|
||
|
throw new Exception($"系统无法连接到数据库:{dbSetting},请检查配置的服务器,数据库,用户名和密码等信息是否正确。{Environment.NewLine}{ex}");
|
||
|
}
|
||
|
return dt;
|
||
|
}
|
||
|
|
||
|
public static ResultObject<bool> Save_TED_TRANSFER_MSTR(List<TED_TRANSFER_MSTR> p_entitys)
|
||
|
{
|
||
|
ResultObject<bool> _ret = new ResultObject<bool>();
|
||
|
try
|
||
|
{
|
||
|
using (var db = EntitiesFactory.CreateExchangeCenterInstance())
|
||
|
{
|
||
|
foreach (var itm in p_entitys)
|
||
|
{
|
||
|
db.TED_TRANSFER_MSTR.AddOrUpdate(itm);
|
||
|
}
|
||
|
if (db.SaveChanges() != -1)
|
||
|
{
|
||
|
_ret.State = ReturnStatus.Succeed;
|
||
|
_ret.Result = true;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
_ret.State = ReturnStatus.Failed;
|
||
|
_ret.Result = false;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
catch (Exception e)
|
||
|
{
|
||
|
_ret.State = ReturnStatus.Failed;
|
||
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(TED_TRANSFER_MSTR), "Save_TED_TRANSFER_MSTR", e.Message);
|
||
|
_ret.Result = false;
|
||
|
_ret.ErrorList.Add(e);
|
||
|
throw e;
|
||
|
}
|
||
|
return _ret;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
public ResultObject<bool> Del_TED_TRANSFER_MSTR(List<TED_TRANSFER_MSTR> p_entitys)
|
||
|
{
|
||
|
ResultObject<bool> _ret = new ResultObject<bool>();
|
||
|
try
|
||
|
{
|
||
|
using (var db = EntitiesFactory.CreateExchangeCenterInstance())
|
||
|
{
|
||
|
foreach (var itm in p_entitys)
|
||
|
{
|
||
|
db.TED_TRANSFER_MSTR.Remove(itm);
|
||
|
}
|
||
|
if (db.SaveChanges() != -1)
|
||
|
{
|
||
|
_ret.State = ReturnStatus.Succeed;
|
||
|
_ret.Result = true;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
_ret.State = ReturnStatus.Failed;
|
||
|
_ret.Result = false;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
catch (Exception e)
|
||
|
{
|
||
|
_ret.State = ReturnStatus.Failed;
|
||
|
_ret.Result = false;
|
||
|
_ret.ErrorList.Add(e);
|
||
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(TED_TRANSFER_MSTR), "Del_TED_TRANSFER_MSTR", e.Message); throw e;
|
||
|
}
|
||
|
return _ret;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
}
|