public string GetMeasureID() { JGDBOP dbop = new JGDBOP(); string strErr = string.Empty; string strMeasureID = string.Empty; string strQText = string.Empty; string strUText = string.Empty; string ZD = string.Empty; string I_SiteID = string.Empty; //获得当前时间 string strText = "Select Convert(varchar,getdate(),120)"; DataTable dt = dbop.GetTable(strText); string objDate = dt.Rows[0][0].ToString(); //string IP = dbop.LocalIP; //string sqlZD = "select C_SiteNo,I_SiteID from CM_MeaSiteInfo where C_SiteIP='" + IP + "'"; //DataTable dtZD = dbop.GetTable(sqlZD); //ZD = dtZD.Rows[0]["C_SiteNo"].ToString(); //I_SiteID = dtZD.Rows[0]["I_SiteID"].ToString(); if (objDate != null) { List <string> lstSQL = new List <string>(); strQText = "Select I_MeasureDocID from CM_MeasureID where C_MeaDate='" + objDate.ToString().Substring(0, 10) + "'"; dt = dbop.GetTable(strQText); if (dt.Rows.Count < 1) { strMeasureID = ZD + DateTime.Parse(objDate.ToString()).ToString("yyMMdd") + "0001"; //计量单号 } else { string objMeasureID = dt.Rows[0]["I_MeasureDocID"].ToString(); strMeasureID = ZD + DateTime.Parse(objDate.ToString()).ToString("yyMMdd") + objMeasureID.ToString().ToString().PadLeft(4, '0'); //计量单号 } if (dt.Rows.Count < 1) { string strDText = "Delete from CM_MeasureID"; dbop.getsqlcom(strDText); strUText = "Insert into CM_MeasureID(I_MeasureDocID,C_MeaDate,C_User,C_TimeStamp) Values(" + "2" + ",'" + objDate.ToString().Substring(0, 10) + "'" + ",'自动'" + ",'" + objDate.ToString() + "')"; dbop.getsqlcom(strUText); } else { strUText = "Update CM_MeasureID set I_MeasureDocID=I_MeasureDocID+1,C_User='******',C_TimeStamp='" + objDate.ToString() + "'"; dbop.getsqlcom(strUText); } } return(strMeasureID); }
private static string getdate()//获取服务器时间 { JGDBOP su = new JGDBOP(); string sqlDate = "select CONVERT(varchar(100), GETDATE(), 20) 时间"; DataTable dtDate = su.GetTable(sqlDate); string Printdate = dtDate.Rows[0]["时间"].ToString(); return(Printdate); }
public static string GetInIP(string MeasureDocID)//查询进厂IP { string inIP = "空"; #region 查询进厂IP JGDBOP su = new JGDBOP(); string sqlIP = "select top 1 AccessIP 进厂IP from CM_DoorControlMain where MeasureDocID ='" + MeasureDocID + "' "; DataTable dt = su.GetTable(sqlIP); if (dt.Rows.Count > 0) { inIP = dt.Rows[0]["进厂IP"].ToString(); } return(inIP); #endregion }
public static string ISLock(string MeasureDocID)//查询是否解锁 { #region 查询是否解锁 string LockStatus = ""; JGDBOP su = new JGDBOP(); string sqlIP = "select top 1 PrintLock 锁定状态 from CM_DoorControlMain where MeasureDocID ='" + MeasureDocID + "' order by TaskID Desc "; DataTable dt = su.GetTable(sqlIP); if (dt.Rows.Count > 0) { LockStatus = dt.Rows[0]["锁定状态"].ToString(); } return(LockStatus); #endregion }
public static int OverTimeContrl(string CarNO)//超时控制 { int cLimitTime = 30; string IPNow = GetIP(); string IPJL = ""; #region 计量表查询净重时间与当前时间的时间差 JGDBOP su = new JGDBOP(); string sql = " select top 1 datediff(MINUTE,CONVERT(datetime,C_RefenceTime),getdate()) 分钟差,C_MeasureDocID,c_RefenceTime from CM_MeasureInfo " + " where C_CarryNo='" + CarNO + "' and C_RefenceTime is not null order by C_RefenceTime desc "; DataTable dtTime = su.GetTable(sql); if (dtTime.Rows.Count > 0) { MeasureDocID = dtTime.Rows[0]["C_MeasureDocID"].ToString(); } cMinCha = dtTime.Rows[0]["分钟差"].ToString(); //净重到当前打票的时间差 int TimeDiff = Convert.ToInt32(cMinCha); string c_RefenceTime = dtTime.Rows[0]["C_RefenceTime"].ToString(); //净重时间 if (cMinCha == "") { cMinCha = "0"; } #endregion #region 查询进厂IP IPJL = GetInIP(MeasureDocID); if (IPJL == "空") { insertDoorMain(MeasureDocID, CarNO); } #endregion #region 查询设定的限制时间 sql = " select LeaveLimit from CM_LimitTimeSet" + " where GateIPB='" + IPNow + "'"; DataTable dtLimit = su.GetTable(sql); #endregion if (dtLimit.Rows.Count > 0) { #region 查询到时间限制 cLimitTime = Convert.ToInt32(dtLimit.Rows[0]["LeaveLimit"].ToString());//得到限制的时间 if (TimeDiff <= cLimitTime) { return(0); } else { string LockStatus = ISLock(MeasureDocID); if (LockStatus == "0") { return(0); } else { updateLock(MeasureDocID, CarNO, c_RefenceTime, cLimitTime);//锁定 return(1); } } #endregion } else { #region 未查询到时间限制 if (TimeDiff <= cLimitTime) { return(0); } else { string LockStatus = ISLock(MeasureDocID); if (LockStatus == "0") { return(0); } else { updateLock(MeasureDocID, CarNO, c_RefenceTime, cLimitTime);//锁定 return(1); } } #endregion } }