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.
193 lines
6.5 KiB
193 lines
6.5 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using Warehouse.Models.mesModel;
|
|
using Warehouse.Models;
|
|
using System.Data.Entity.Validation;
|
|
|
|
namespace Warehouse.DAL.LCL
|
|
{
|
|
public class LCLDal
|
|
{
|
|
|
|
public pack_pallets QueryPallet(string Pallet)
|
|
{
|
|
using (var mescontext = new mesModel())
|
|
{
|
|
var res = mescontext.pack_pallets.Where(a => a.pallet_nbr == Pallet).FirstOrDefault<pack_pallets>();
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public config_products QueryProduct(string ProductCode)
|
|
{
|
|
using (var mescontext = new mesModel())
|
|
{
|
|
var res = mescontext.config_products.Where(a => a.product_code == ProductCode).FirstOrDefault<config_products>();
|
|
return res;
|
|
}
|
|
}
|
|
|
|
//pallet isLCL
|
|
public tcontainerpallet QueryContainerBindPallet(string pallet)
|
|
{
|
|
using (var whcontext = new whModel())
|
|
{
|
|
//var res = whcontext.tcontainerpallets.Count(a => a.palletno == pallet);
|
|
//if (res > 0)
|
|
//{
|
|
// return true;
|
|
//}
|
|
//else
|
|
//{
|
|
// return false;
|
|
//}
|
|
//return whcontext.tcontainerpallets.Join(whcontext.tcontainers, a => a.ContainerNo, g => g.ContainerNo, (a, g) => new { a.ContainerNo,a.palletno,g.bartype,g.cellqty,g.color,g.Count,g.finalgrade,g.igrade,g.powergrade,g.modulespec });
|
|
return whcontext.tcontainerpallets.Where(a => a.palletno == pallet).FirstOrDefault();
|
|
}
|
|
}
|
|
|
|
public List<dynamic> QueryStockInfoByPallet(string pallet)
|
|
{
|
|
using (var context = new whModel())
|
|
{
|
|
string sql = @"select a.palletno,a.storagelocationid ,createtime,b.locationname from wh.tstockinlog a left join wh.tstoragelocation b on a.storagelocationid = b.id
|
|
where a.id = (select max(id) from tstockinlog where palletno = '"+pallet+"' )";
|
|
//context.Database.SqlQuery<dynamic>(" call prGetPalletOfContainer('" + container + "') ").ToList();
|
|
var res = context.DynamicListFromSql(sql, null);
|
|
if (res != null)
|
|
{
|
|
return res.ToList();
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
|
|
public List<dynamic> QueryPalletStockInfoByConatiner(string container)
|
|
{
|
|
using (var context = new whModel())
|
|
{
|
|
//context.Database.SqlQuery<dynamic>(" call prGetPalletOfContainer('" + container + "') ").ToList();
|
|
var res = context.DynamicListFromSql("call prGetPalletOfContainer('" + container + "')", null);
|
|
if (res.Count() != 0)
|
|
{
|
|
return res.ToList();
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
//return null;
|
|
}
|
|
|
|
public List<dynamic> QueryPalletAndProduct(string pallets)
|
|
{
|
|
using (var context = new mesModel())
|
|
{
|
|
//var res = context.Database.SqlQuery<string>(" EXEC [dbo].[prGetPalletAndPriduct] @pallets = N'"+pallets+"'");
|
|
//return res.ToList();
|
|
var res = context.DynamicListFromSql("EXEC[dbo].[prGetPalletAndProduct] @pallets = N'" + pallets + "'", null);
|
|
if (res.Count()!= 0)
|
|
{
|
|
return res.ToList();
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
public List<tcontainerpallet> QueryAllPalletOfConatiner(string container)
|
|
{
|
|
using (var whcontext = new whModel())
|
|
{
|
|
var res = whcontext.tcontainerpallets.Where(a => a.ContainerNo == container);
|
|
if (res != null)
|
|
{
|
|
return res.ToList();
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
|
|
public bool UpdateContainerStatus(string container, string status)
|
|
{
|
|
using (var whcontext = new whModel())
|
|
{
|
|
var containerres = whcontext.tcontainers.Where(a => a.ContainerNo == container).FirstOrDefault();
|
|
containerres.State = "complete";
|
|
var res = whcontext.tcontainerpallets.Where(a => a.ContainerNo == container);
|
|
foreach (var item in res)
|
|
{
|
|
item.status = "complete";
|
|
}
|
|
var saveres = whcontext.SaveChanges();
|
|
if (saveres > 0) { return true; }
|
|
else { return false; }
|
|
}
|
|
}
|
|
|
|
public tcontainer QueryContainer(string container)
|
|
{
|
|
using (var whcontext = new whModel())
|
|
{
|
|
return whcontext.tcontainers.Where(a => a.ContainerNo == container).FirstOrDefault();
|
|
}
|
|
}
|
|
|
|
|
|
public bool CreateContainer(tcontainer container)
|
|
{
|
|
try
|
|
{
|
|
using (var whcontext = new whModel())
|
|
{
|
|
//var res = whcontext.tcontainerpallets.Count(a => a.palletno == pallet);
|
|
whcontext.tcontainers.Add(container);
|
|
var res = whcontext.SaveChanges();
|
|
if (res > 0)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
catch (DbEntityValidationException dbEx)
|
|
{
|
|
var a = dbEx.EntityValidationErrors;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public bool CreateContainerBindPallet(tcontainerpallet containpallet)
|
|
{
|
|
using (var whcontext = new whModel())
|
|
{
|
|
//var res = whcontext.tcontainerpallets.Count(a => a.palletno == pallet);
|
|
whcontext.tcontainerpallets.Add(containpallet);
|
|
var res = whcontext.SaveChanges();
|
|
if (res > 0)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|