本文整理汇总了C#中DAL.TestCon方法的典型用法代码示例。如果您正苦于以下问题:C# DAL.TestCon方法的具体用法?C# DAL.TestCon怎么用?C# DAL.TestCon使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DAL
的用法示例。
在下文中一共展示了DAL.TestCon方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Checkzddate
/// <summary>
/// 找到站点数据,中心数据库数据,充装检查数据
/// </summary>
/// <param name="context"></param>
public void Checkzddate(HttpContext context)
{
int zd = int.Parse(context.Request["zd"]);//站点
string kh = context.Request["kh"];//卡号
string lsh = context.Request["lsh"];//流水号
string rq = context.Request["rq"];//日期
string zdIP = "", zdName = "", km = "", cp = "";
string json = "{\"日期\":\"@日期@\",\"卡号\":@卡号@,\"卡名\":\"@卡名@\",\"车牌\":\"@车牌@\",\"站点\":\"@站点@\",\"站点ok\":@站点[email protected],\"中心ok\":@中心[email protected],\"充装ok\":@充装[email protected]}";
bool zdok = false, zxok = false, czok = false;
switch (zd)
{
case 2: zdIP = "192.168.173.3"; zdName = "南高"; break;//南高
case 3: zdIP = "192.168.172.23"; zdName = "江阳西路"; break;//江阳西路
case 4: zdIP = "192.168.171.3"; zdName = "麻柳沱"; break; //麻柳沱
case 5: zdIP = "192.168.174.3"; zdName = "华阳"; break; //华阳
default:
break;
}
string SQL = "SELECT GunNo FROM [cngms].[dbo].[PayGas] where TradeDate='" + rq + "' AND [TradeNo]=" + lsh + " AND UserCardNo=" + kh;
DAL dal = new DAL();
DataTable dt = null;
//检查站点数据
DAL Zdal = new DAL(zdIP);//用于连接站点数据库
if (Zdal.TestCon(2))//先测试连接
{
dt = Zdal.RunSqlDataTable(SQL);
if (dt != null && dt.Rows.Count == 1)
{
zdok = true;
}
}
json = json.Replace("@站点[email protected]", zdok.ToString().ToLower());
//检查中心数据库数据
SQL = "SELECT [GunNO]FROM [CSERVER].[dbo].[GAS] where StationNO=" + zd.ToString() + " AND TradeDate='" + rq +
"' AND TradeNO=" + lsh + " AND UserCardNo=" + kh;
dt = dal.RunSqlDataTable(SQL);
if (dt != null && dt.Rows.Count == 1)
{
zxok = true;
}
else
{
SQL = "SELECT [GunNO]FROM [CSERVER].[dbo].[TEMPGAS] where StationNO=" + zd.ToString() + " AND TradeDate='" + rq +
"' AND TradeNO=" + lsh + " AND UserCardNo=" + kh;
dt = dal.RunSqlDataTable(SQL);
if (dt != null && dt.Rows.Count == 1)
{
zxok = true;
dal.ExecuteRowCount = 0;
}
}
json = json.Replace("@中心[email protected]", zxok.ToString().ToLower());
//检查 充装记录数据
SQL = "SELECT [枪号] FROM [CNGQT].[dbo].[CNG_充装检查] where 站点=" + zd.ToString() + " and 日期='" + rq + "' AND 流水号=" + lsh + " AND 用户号=" + kh;
dt = dal.RunSqlDataTable(SQL);
if (dt != null && dt.Rows.Count == 1)
{
czok = true;
}
json = json.Replace("@充装[email protected]", czok.ToString().ToLower());
//取的卡 正确数据信息
SQL = "SELECT TOP 1 a.[UserCardNo],a.[CarNo],b.ICardName FROM [CSERVER].[dbo].[UserCards] a left JOIN [CSERVER].dbo.ICardType b ON a.ICardType=b.ICardType where a.UserCardNo=" + kh;
string[] temp = dal.RunSqlStrings(SQL);
if (temp != null)
{
km = temp[2].Trim();
cp = temp[1].Trim();
}
json = json.Replace("@卡名@", km);
json = json.Replace("@车牌@", cp);
json = json.Replace("@卡号@", kh);
json = json.Replace("@站点@", zdName);
json = json.Replace("@日期@", rq);
Sys.DebugMes(json);
context.Response.Write(json);
}
示例2: Check_err
/// <summary>
/// 更改错误数据
/// </summary>
/// <param name="context"></param>
public void Check_err(HttpContext context)
{
int zd = int.Parse(context.Request["zd"]);//站点
string kh = context.Request["kh"];//卡号
string lsh = context.Request["lsh"];//流水号
string rq = context.Request["rq"];//日期
string name = context.Request["name"];//操作用户
string zdIP = "", zdName = "", km = "", cp = "";
switch (zd)
{
case 2: zdIP = "192.168.173.3"; zdName = "南高"; break;//南高
case 3: zdIP = "192.168.172.23"; zdName = "江阳西路"; break;//江阳西路
case 4: zdIP = "192.168.171.3"; zdName = "麻柳沱"; break; //麻柳沱
case 5: zdIP = "192.168.174.3"; zdName = "华阳"; break; //华阳
default:
break;
}
DAL dal = new DAL();
string SQL = "SELECT TOP 1 a.[UserCardNo],a.[CarNo],b.ICardName FROM [CSERVER].[dbo].[UserCards] a left JOIN [CSERVER].dbo.ICardType b ON a.ICardType=b.ICardType where a.UserCardNo=" + kh;
string[] temp = dal.RunSqlStrings(SQL);
if (temp != null)
{
km = temp[2].Trim();//取得卡名
cp = temp[1].Trim();//取的车牌号
}
else
{
context.Response.Write("未找到对应车牌信息!");
return;
}
SQL = "UPDATE [cngms].[dbo].[PayGas] SET [CardName] = '" + km + "',[CarNo] = '" + cp + "' WHERE TradeDate='" + rq + "' AND [TradeNo]=" + lsh + " AND UserCardNo=" + kh;
//更改站点数据
DAL Zdal = new DAL(zdIP);//用于连接站点数据库
if (Zdal.TestCon(2))//先测试连接
{
Zdal.RunSql(SQL);
}
else
{
context.Response.Write("连接站点数据库错误! 更改失败!");
return;
}
//更改心数据库数据
SQL = "UPDATE [CSERVER].[dbo].[GAS] SET [CardName] ='" + km + "',[CarNO] = '" + cp + "' where StationNO=" + zd.ToString() + " AND TradeDate='" + rq +
"' AND TradeNO=" + lsh + " AND UserCardNo=" + kh;
dal.RunSql(SQL);
SQL = "UPDATE [CSERVER].[dbo].[TEMPGAS] SET [CardName] ='" + km + "',[CarNO] = '" + cp + "' where StationNO=" + zd.ToString() + " AND TradeDate='" + rq +
"' AND TradeNO=" + lsh + " AND UserCardNo=" + kh;
dal.RunSql(SQL);
//更改 充装记录数据
SQL = "UPDATE [CNGQT].[dbo].[CNG_充装检查] SET [卡名] ='" + km + "',[车牌号] ='" + cp + "',[是否完成]=0 where 站点=" + zd.ToString() + " and 日期='" + rq + "' AND 流水号=" + lsh + " AND 用户号=" + kh;
dal.RunSql(SQL);
string tt = "站点[{0}] 日期[{1}] 卡号[{2}] 流水号[{3}]";
tt = string.Format(tt, zd.ToString(), rq, kh, lsh);
Sys.addSteps(name, tt, "修改错误数据");
context.Response.Write("所有数据更改完成,请检查数据是否成功更改!");
}
示例3: switch
/// <summary>
/// 更新站点交接班记录
/// </summary>
/// <param name="zd">站点编号</param>
public void FF_更新交接班记录(int zd)
{
string zdIP = "";
string zdName = "";
Even_更新站点数据 e = new Even_更新站点数据();
switch (zd)
{
case 2: zdIP = "192.168.173.3"; zdName = "南高"; break;//南高
case 3: zdIP = "192.168.172.23"; zdName = "江阳西路"; break;//江阳西路
case 4: zdIP = "192.168.171.3"; zdName = "麻柳沱"; break; //麻柳沱
default:
break;
}
DAL Zdal = new DAL(zdIP);//用于连接站点数据库
if (Zdal.TestCon(3) == false)//先测试连接,失败就返回
{
e.ok = false;
e.mes = string.Format("连接站点={0} 失败", zdName.ToString());
Sys.addLogErrToFiles(zdIP, "连接测试失败");
}
else
{
string path = Sys.GetRunPath() + "\\CngSystem.xml";
//timeS 用于存放上次 成功获取数据的时间
string timeS = Sys.xmlRead(path, "服务器站点更新", zdName.ToString(), DateTime.Now.AddDays(-2).ToString());//如果没找到事件,返回 当前时间-2天
timeS = Convert.ToDateTime(timeS).AddMinutes(-15).ToString();// 时间点再 推后 15分钟
string SQL = "SELECT * FROM [CNGMS].[dbo].[bztj] where 更新时间>'" + timeS + "'"; //查找是否有新数据
DataTable dt = Zdal.RunSqlDataTable(SQL);
e.ok = true;
e.n = dt.Rows.Count;
if (e.n <= 0)
{//没有数据
Sys.xmlAdd(path, "服务器站点更新", zdName.ToString(), DateTime.Now.ToString());
e.mes = string.Format("连接站点={0} 未找到数据", zdName.ToString());
}
else
{//找到新数据
DAL Sdal = new DAL();
foreach (DataRow dr in dt.Rows)
{
string drtime = dr["日期"].ToString();
string drbz = dr["班组"].ToString();
//查找服务器 是否已有对应数据
SQL = "select id FROM [CNGQT].[dbo].[CW_每班统计] where [站点]={0} and [日期]='{1}' and [班组]='{2}'";
SQL = string.Format(SQL, zd.ToString(), drtime, drbz);
string id = Sdal.RunSqlGetID(SQL);
bool ok = (id != null);//找到记录为真,进行更新,未找到记录为 假 进行插入操作
SQL = zdTOserver(dr, ok, zd, id);//返回 SQL文本
Sys.DebugMes(SQL);
Sdal.RunSql(SQL);
e.zxSql = SQL;
}
}
if (e.ok)
{
Sys.xmlAdd(path, "服务器站点更新", zdName.ToString(), DateTime.Now.ToString());
e.ok = true;
e.mes = string.Format("连接站点={0} 更新数据={1}", zdName.ToString(), e.n.ToString());
}
}
if (this.SJ_更新站点数据 != null)
{//触发事件
this.SJ_更新站点数据(this, e);
}
}
示例4: test4
static void test4()
{
//测试 数据 连接
Console.WriteLine("开始连接测试");
DateTime t1 = DateTime.Now;
DAL dal = new DAL("192.168.0.11");
Console.WriteLine(dal.cnString);
bool r = dal.TestCon(3);
Console.WriteLine(r.ToString());
DateTime t2 = DateTime.Now;
Console.WriteLine((t2 - t1).TotalSeconds.ToString() + " 秒");
Console.Read();
}