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.
 
 
 
 
 

115 lines
3.5 KiB

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;
using CK.SCP.Models;
using CK.SCP.Models.Enums;
using CK.SCP.Models.ScpEntity;
namespace CK.SCP.Controller
{
public class POController
{
public static List<V_POAll> Getlist()
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.V_POAll.ToList();
}
}
public static bool UpdatePOState(TF_PO model)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
db.TF_PO.AddOrUpdate(p => p.UID, model);
EntitiesFactory.SaveDb(db);
}
return true;
}
public static TF_PO GetlistByID(int uid)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.TF_PO.SingleOrDefault(p => p.UID == uid);
}
}
public static TF_PO GetlistByBillNum(string billnum)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.TF_PO.SingleOrDefault(p => p.BillNum == billnum);
}
}
public static V_POAll GetPOAlllistByBillNum(string billnum)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.V_POAll.SingleOrDefault(p => p.BillNum == billnum);
}
}
public static void UpdateOrderByUID(int state, int uid)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
TF_PO model = new TF_PO();
model.State = state;
model.UID = uid;
db.SaveChanges();
}
}
public static void UpdatePOOBybillno(TF_PO model)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
model.State = (int)PlanState.Confirm;
db.TF_PO.AddOrUpdate(p => p.UID, model);
db.SaveChanges();
}
}
public static List<V_POAll> GetlistByBillNum(V_POAll model)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.V_POAll.Where(p => p.BillNum == model.BillNum).ToList();
}
}
public static TF_PO GetASNlist(string billnum, string vendid)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.TF_PO.SingleOrDefault(p => p.BillNum == billnum && p.VendId == vendid);
}
}
public static TF_PO GetPOModel(int id)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.TF_PO.SingleOrDefault(p => p.UID == id);
}
}
public static List<TF_PO> GetASNlist()
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.TF_PO.ToList();
}
}
public static void DeletePO(TF_PO model)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
db.TF_PO.Remove(model);
db.SaveChanges();
}
}
}
}