tijian_tieying/web/dccdc.DAL/yanzhengDal.cs
2025-02-20 12:14:39 +08:00

43 lines
1.4 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using dccdc.Models;
using Dapper;
namespace dccdc.DAL
{
public class yanzhengDal
{
public yanzhengModel getYZ(string id)
{
//throw new NotImplementedException();
string sql = "select * from yanzheng where pno=@id";
using (var conn = CommHelper.GetSqlConnection())
{
var yzm = conn.Query<yanzhengModel>(sql, new { id = id }).FirstOrDefault();
if (yzm != null)
return yzm;
else
{
yzm = new yanzhengModel { pno = id, yzcod = Guid.NewGuid().ToString("N") };
sql = "insert into yanzheng(pno,yzcod) values(@pno,@yzcod)";
conn.Execute(sql, yzm);
return yzm;
}
}
}
public yanzhengModel yanZhen(string pno, string yzcod)
{
//throw new NotImplementedException();
string sql = "select * from yanzheng where pno=@pno and yzcod=@yzcod";
using (var conn = CommHelper.GetSqlConnection())
{
var yzm = conn.Query<yanzhengModel>(sql, new { pno = pno,yzcod=yzcod }).FirstOrDefault();
return yzm;
}
}
}
}