using DataEntity;
|
using DataRWDAL;
|
using DataRWDAL.Base;
|
using HxEnum;
|
using MySql.Data.MySqlClient;
|
using SqlSugar;
|
using System;
|
using System.Collections.Generic;
|
using System.Collections.ObjectModel;
|
using System.Data;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using XCommon.Log;
|
using XCommon.MySql;
|
|
namespace XImagingXhandler.XDAL
|
{
|
/// <summary>
|
/// 台面模板内板位关联操作类
|
/// </summary>
|
public class TabletopRelLatticeDB:BaseDB
|
{
|
#region 删除某台面模板内的所有板位数据
|
/// <summary>
|
/// 删除某台面模板内的所有板位数据
|
/// </summary>
|
/// <param name="tabletopid">台面模板Id</param>
|
/// <returns>1:成功;0:失败;</returns>
|
public static int DeleteTabletopRelLatticeIntodb(string tabletopid)
|
{
|
using (var db = GetInstance())
|
{
|
int sum = 0;//执行的总数
|
var query = db.Queryable<TabletopRelLattice>().Where(it => it.tabletopid.Equals(tabletopid)).ToList();
|
if(query!=null&&query.Count()>0)
|
{
|
foreach(var item in query)
|
{
|
Lattice lattice = LatticeDB.GetLatticeDataByIdFromdb(item.lattice_id.ToString());
|
lattice.lattice_state = 0;
|
int ret=DeleteLatticeFromdb(lattice);
|
if (ret == 1)
|
{
|
sum++;
|
}
|
}
|
|
if (sum == query.Count)
|
{
|
return 1;
|
}
|
}
|
|
return 0;
|
}
|
}
|
#endregion
|
|
#region 删除指定的台面模板内的板位数据
|
/// <summary>
|
/// 删除指定的台面模板内的板位数据
|
/// </summary>
|
/// <param name="lattice">板位</param>
|
/// <returns>1:成功;0:失败;</returns>
|
public static int DeleteLatticeFromdb(Lattice lattice)
|
{
|
using (var db = GetInstance())
|
{
|
return db.Updateable<Lattice>(lattice).ExecuteCommand();
|
}
|
}
|
#endregion
|
|
#region 更新指定的台面模板内的板位数据
|
/// <summary>
|
/// 更新指定的台面模板内的板位数据
|
/// </summary>
|
/// <param name="lattice">板位</param>
|
/// <returns>1:成功;0:失败;</returns>
|
public static int UpdateLatticeFromdb(Lattice lattice)
|
{
|
using (var db = GetInstance())
|
{
|
return db.Updateable<Lattice>(lattice).ExecuteCommand();
|
}
|
}
|
#endregion
|
|
#region 更新指定的台面模板与板位关系数据
|
/// <summary>
|
/// 更新指定的台面模板与板位关系数据
|
/// </summary>
|
/// <param name="tabletopRelLattice">台面与板位关系对象</param>
|
/// <returns>1:成功;0:失败;</returns>
|
public static int UpdateTabletopRelLatticeFromdb(TabletopRelLattice tabletopRelLattice)
|
{
|
using (var db = GetInstance())
|
{
|
return db.Updateable<TabletopRelLattice>(tabletopRelLattice).Where(it=>it.tabletopid.Equals(tabletopRelLattice.tabletopid)
|
&&it.lattice_id.Equals(tabletopRelLattice.lattice_id)).ExecuteCommand();
|
}
|
}
|
#endregion
|
|
#region 获取当前最大的台面板位Id
|
/// <summary>
|
/// 获取当前最大的台面板位Id
|
/// </summary>
|
/// <returns>最大板位Id</returns>
|
public static int GetMaxLattceId()
|
{
|
using (var db = GetInstance())
|
{
|
return db.Queryable<Lattice>().ToList().Count;
|
}
|
}
|
#endregion
|
|
#region 获取台面板位关系数据 通过台面Id和板位Id
|
/// <summary>
|
/// 获取台面板位关系数据 通过台面Id和板位Id
|
/// </summary>
|
/// <param name="latticeId">板位Id</param>
|
/// <param name="tabletopId">台面Id</param>
|
/// <returns>台面板位关系数据</returns>
|
public static TabletopRelLattice GetTabletopRelLatticeByTabletopIdAndLatticeId(string tabletopId,int latticeId)
|
{
|
using (var db = GetInstance())
|
{
|
return db.Queryable<TabletopRelLattice>().Single(it => it.tabletopid.Equals(tabletopId) && it.lattice_id.Equals(latticeId));
|
}
|
}
|
#endregion
|
|
#region 批量添加板位数据
|
/// <summary>
|
/// 批量添加板位数据
|
/// </summary>
|
/// <param name="lattice">板位对象</param>
|
/// <param name="startLatticeid">开始板位Id</param>
|
/// <param name="tabletopId">台面模板Id</param>
|
/// <returns></returns>
|
public static int AddLatticeIntodb(Lattice lattice,int startLatticeid,string tabletopId)
|
{
|
using (var db = GetInstance())
|
{
|
int sum = 0;//执行的总数
|
//for (int i = 0; i < lattices.Count; i++)
|
//{
|
|
lattice.lattice_id = (startLatticeid).ToString();
|
db.Insertable<Lattice>(lattice).ExecuteCommand();
|
|
int ret=db.Insertable<TabletopRelLattice>(new TabletopRelLattice() { lattice_id = (startLatticeid), tabletopid = tabletopId,
|
lattice_pixel_x = lattice.lattice_pixel_x,
|
lattice_pixel_y = lattice.lattice_pixel_y,
|
labware_id= lattice.labware_id,
|
isbaselattice = 1
|
}).ExecuteCommand();
|
sum++;
|
//}
|
|
//if(sum==lattices.Count)
|
//{
|
if(ret>0)
|
{
|
return ret;
|
}
|
//}
|
|
return 0;
|
}
|
}
|
#endregion
|
}
|
}
|