自动编码生成SQL语句的问题

skysmmg skysmmg 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
public string getCode(string paramDateTime)
{
DateTime.Now.ToString("yy mm dd");
string strQuery = @" select Max(Code) from Check
where Code like '%'";

Hashtable myParam = new Hashtable();
myParam.Add("@Code", paramDateTime);
BaseDBCon myBaseDBCon = new BaseDBCon();
DataSet myDs = new DataSet();
string returnValue = string.Empty;
try
{
myBaseDBCon.Open();
myBaseDBCon.Fill(strQuery, myDs, "T", myParam);
if (myDs.Tables[0].Rows[0][0] != DBNull.Value)
{
string Code = myDs.Tables[0].Rows[0][0].ToString();

int Tmp = int.Parse(Code);

Tmp++;
int Count = Code.Length - Tmp.ToString().Length;
for (int i = 0; i < Count; i++)
{
returnValue += "0";
}
returnValue += Tmp.ToString();
}
else if (myDs.Tables[1].Rows.Count > 0)
{
returnValue = myDs.Tables[1].Rows[0][0].ToString() + "001";
}
else
{
returnValue = "001";
}
}
catch (Exception myEx)
{
throw new Exception(myEx.Message + "\r\n SQL:" + strQuery);
}
finally
{
myBaseDBCon.Close();
}
return returnValue;
}
当点击进入页面的时候 想让txtCode框自动生成编码,首先查询当天有无生成过编码,查询条件
...全文
评论 2
收藏 已收藏
分享
返回顶部
skysmmg
.NET社区 62,273 成员 668,968 内容