注塑喷涂
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.

102 lines
3.5 KiB

1 year ago
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Reflection;
using System.Text;
using MESClassLibrary.BLL.Log;
namespace MESClassLibrary.DAL.PunchAndWeld
{
public class PunchAdressDAL
{
public DataTable SearchInfo(string deviceNo ,int i)
{
try
{
string sql = @"SELECT * from tb_PunchAddress where DeviceNo=@DeviceNo and RW=@RW order by ID";
SqlParameter[] param = null;
param = new SqlParameter[2];
param[0] = new SqlParameter("@DeviceNo", SqlDbType.VarChar);
param[0].Value = deviceNo;
param[1] = new SqlParameter("@RW", SqlDbType.Int);
param[1].Value = i;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
4 weeks ago
public DataTable SearchExtendInfo(string StationNo, int i)
{
try
{
string sql = @"SELECT * from tb_PunchAddressExtend where StationNo=@StationNo and RW=@RW order by Address";
SqlParameter[] param = null;
param = new SqlParameter[2];
param[0] = new SqlParameter("@StationNo", SqlDbType.VarChar);
param[0].Value = StationNo;
param[1] = new SqlParameter("@RW", SqlDbType.Int);
param[1].Value = i;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public int AddDeviceRecord(DataRow drData, string tableName)
{
DataRow drResult = null;
string sql = "insert into {0}({1}) values({2});select @@Identity";
string fields = "";
string values = "";
foreach (DataColumn dc in drData.Table.Columns)
{
if (dc.ColumnName.ToUpper() != "ID")
{
if (drData[dc.ColumnName] is DBNull) continue;
fields += "[" + dc.ColumnName + "]" + ",";
if ((dc.DataType.Name == "Int32" || dc.DataType.Name == "Decimal") && drData[dc.ColumnName].ToString() == "")
{
values += "'0',";
}
else if (dc.DataType.Name == "DateTime" && drData[dc.ColumnName].ToString() == "")
{
values += "getdate(),";
}
else
{
values += "'" + drData[dc.ColumnName] + "',";
}
}
}
if (fields.Length > 1) fields = fields.Substring(0, fields.Length - 1);
if (values.Length > 1) values = values.Substring(0, values.Length - 1);
object[] o = new object[3];
o[0] = tableName;
o[1] = fields;
o[2] = values;
sql = string.Format(sql, o);
return SqlHelper.ExecuteNonQuery (SqlHelper.GetConnSting(), CommandType.Text, sql);
}
1 year ago
}
}