Пример #1
0
 /// <summary>
 /// 检测指定的lotid是否存在
 /// </summary>
 /// <param name="lotId">样板lot卡号</param>
 /// <param name="tran">在指定事务中执行查询</param>
 /// <returns></returns>
 internal static bool IsExistSampleLotId(string strLotId, SqlTransaction tran)
 {
     //检测样板lot卡id号是否存在于sample所开的样板lot卡记录中
     using (var da = new t_sample_lot_cardTableAdapter())
     {
         if (tran != null)
         {
             //当前数据库连接
             da.Connection = tran.Connection;
             //设置事务
             da.Transaction = tran;
         }
         //获取数据
         using (var tab = da.GetDataByLotId(strLotId))
         {
             //lotid号存在提示错误
             if (tab.Rows.Count > 0)
             {
                 //报告失败
                 throw new Exception("待保存的样板lot卡号 " + strLotId + " 已经存在于样板lot卡记录中!");
             }
         }
     }
     //检测样板lot卡id号是否存在于样板wip记录中
     using (var da = new t_dept_lot_card_balanceTableAdapter())
     {
         if (tran != null)
         {
             //当前数据库连接
             da.Connection = tran.Connection;
             //设置事务
             da.Transaction = tran;
         }
         //获取数据
         using (var tab = da.GetFirstRowByLotId(strLotId))
         {
             //lotid号存在提示错误
             if (tab.Rows.Count > 0)
             {
                 //报告失败
                 throw new Exception("待保存的样板lot卡号 " + strLotId + " 已经存在于样板wip记录中!");
             }
         }
     }
     //返回不存在
     return false;
 }