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.

187 lines
7.1 KiB

4 years ago
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CK.SCP.Models;
using CK.SCP.Models.ScpEntity;
namespace CK.SCP.Controller
{
public class SCP_TB_VENDER_CONTROLLER
{
public static List<TA_VENDER> GetlistByName(TA_VENDER model)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.TA_VENDER.Where(p => p.VendName == model.VendName).ToList();
}
}
public static List<TA_VENDER> Getlist()
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.TA_VENDER.ToList();
}
}
public static List<TA_VENDER> Getlist(List<string> lsVenderID )
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
var query = db.TA_VENDER.Where(p => lsVenderID.Contains(p.VendId));
return query.ToList();
}
1 year ago
}
4 years ago
public static List<TA_VENDER> Getlist(string p_site)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.TA_VENDER.Where(p => p.Site==p_site ).ToList();
}
}
1 year ago
4 years ago
public static List<TA_VENDER> GetVenderList(List<string> p_list)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
var query = db.TA_VENDER.Where(p =>p_list.Contains(p.Site));
return query.ToList();
}
}
public static List<TA_VENDER> Getlist(List<string> lsVenderID,List<string> p_list)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
var query = db.TA_VENDER.Where(p => lsVenderID.Contains(p.VendId)&& p_list.Contains(p.Site));
return query.ToList();
}
}
4 years ago
public static TA_VENDER GetVender(string p_VenderID,string p_Site)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.TA_VENDER.Where(p => p.VendId==p_VenderID && p.Site==p_Site).FirstOrDefault();
}
}
1 year ago
public static TB_ASN Save_ASN_Asn(string ls)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.TB_ASN.Where(p => p.AsnBillNum == ls).FirstOrDefault();
}
}
4 years ago
public static List<TA_VENDER> GetVendNameList(List<string> p_list, string p_site)
{
List<TA_VENDER> _ls = new List<TA_VENDER>();
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
IQueryable<TA_VENDER> query = db.TA_VENDER;
if (p_list.Count > 0)
{
query = query.Where(p => p_list.Contains(p.VendId));
}
if (!string.IsNullOrEmpty(p_site))
{
query = query.Where(p => p.Site == p_site);
}
_ls=query.ToList();
}
return _ls;
}
//public static ResultObject<bool> Save_TA_VENDER(List<TA_VENDER> p_entitys)
//{
// ResultObject<bool> _ret = new ResultObject<bool>();
// try
// {
// using (ScpEntities db = EntitiesFactory.CreateScpInstance())
// {
// foreach (var itm in p_entitys)
// {
// var _entity = db.TA_VENDER.Where(p => p.UID == itm.UID).FirstOrDefault();
// _entity.Quota = itm.Quota;
// db.TA_VENDER.AddOrUpdate(p => p.UID, _entity);
// }
// if (_ret.MessageList.Count > 0)
// {
// _ret.State = ReturnStatus.Failed;
4 years ago
// }
// else
// {
// if (db.SaveChanges() != -1)
// {
// _ret.State = ReturnStatus.Succeed;
// _ret.Result = true;
// }
// else
// {
// _ret.State = ReturnStatus.Failed;
// _ret.Result = false;
// }
// }
// }
// }
// catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常
// {
// var sb = new StringBuilder();
// foreach (var error in dbEx.EntityValidationErrors.ToList())
// {
// error.ValidationErrors.ToList().ForEach(i =>
// {
// sb.AppendFormat("表:{0},字段:{1},信息:{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage);
// });
// }
// _ret.State = ReturnStatus.Failed;
// _ret.Result = false;
// _ret.ErrorList.Add(dbEx);
// LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TB_VENDER_CONTROLLER), "Save_TA_VENDER", sb.ToString());
// throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString());
// }
// catch (OptimisticConcurrencyException ex)//并发冲突异常
// {
// _ret.State = ReturnStatus.Failed;
// _ret.Result = false;
// _ret.ErrorList.Add(ex);
// LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TB_VENDER_CONTROLLER), "Save_TA_VENDER", ex.ToString());
// throw new ScpException(ResultCode.Exception, "9999", ex.ToString());
// }
// catch (ScpException ex)
// {
// _ret.State = ReturnStatus.Failed;
// _ret.Result = false;
// _ret.ErrorList.Add(ex);
// LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TB_VENDER_CONTROLLER), "Save_TA_VENDER", ex.ToString());
// if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException))
// {
// var inner = (UpdateException)ex.InnerException;
// throw new ScpException(ResultCode.Exception, "0000", ex.ToString());
// }
// else
// {
// if (ex.InnerException != null) throw ex.InnerException;
// }
// }
// catch (Exception e)
// {
// _ret.State = ReturnStatus.Failed;
// LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TB_VENDER_CONTROLLER), "Save_TA_VENDER", e.Message);
// _ret.Result = false;
// _ret.ErrorList.Add(e);
// throw e;
// }
// return _ret;
//}
4 years ago
}
}