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.

60 lines
1.6 KiB

4 years ago
using System;
using System.Collections.Generic;
using System.Data.Entity.Migrations;
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 InfoController
{
public static bool SaveInfo(TA_Info model)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
db.TA_Info.AddOrUpdate(model);
db.SaveChanges();
}
return true;
}
public static bool UpdateInfo(TA_Info model)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
db.TA_Info.AddOrUpdate(p => p.ID, model);
db.SaveChanges();
}
return true;
}
public static TA_Info GetlistByBillNo(int id)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.TA_Info.SingleOrDefault(p => p.ID == id);
}
}
public static V_Info GetInfoByBillNo(int id)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
return db.V_Info.SingleOrDefault(p => p.ID == id);
}
}
public static void DeleteById(int id)
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
var info = db.TA_Info.SingleOrDefault(p => p.ID == id);
if (info != null) db.TA_Info.Remove(info);
db.SaveChanges();
}
}
}
}