/// <summary> /// 添加密码到电子锁 /// </summary> /// <param name="rentNO"></param> /// <param name="pass"></param> /// <param name="startdate"></param> /// <param name="enddate"></param> /// <param name="phone"></param> /// <returns></returns> public string AddPassword(string rentNO, string pass, string startdate, string enddate, string phone) { Dictionary <string, string> ret = new Dictionary <string, string>(); string sql = "select * from Rent_Locks where rentNo='" + rentNO + "' and Status='0'"; DataTable dt = MySQLHelper.ExecuteDataset(MySQLHelper.SqlConnString, MySQLHelper.CreateCommand(sql)).Tables[0]; if (dt.Rows.Count > 0) { if (dt.Rows[0]["DeviceType"].ToString() == "1") //新锁 { NewLockManager managerNew = new NewLockManager(); string r = managerNew.GetPostInterface(dt.Rows[0]["DeviceID"].ToString(), phone, "2", pass, startdate, enddate); //设置临时密码 ret = JSONHelper.FromJson <Dictionary <string, string> >(r); } else //旧锁 { LockManager manager = new LockManager(); manager.AddPassword(dt.Rows[0]["DeviceID"].ToString(), pass, startdate, enddate); string r = manager.UpdatePassengerInfoToDevice(dt.Rows[0]["DeviceID"].ToString(), "", "", "", pass, DateTime.Parse(startdate).ToString("yyyyMMddHHmm").Substring(2, 10), DateTime.Parse(enddate).ToString("yyyyMMddHHmm").Substring(2, 10), "3"); ret = JSONHelper.FromJson <Dictionary <string, string> >(r); } } else { ret.Add("ret", "1"); ret.Add("msg", "未发现智能锁信息,无法添加密码"); } return(JSONHelper.ToJson(ret)); }
public string AddRentAttribute(RentAttribute rentAttribute) { StringBuilder strSql = new StringBuilder(); StringBuilder strSql1 = new StringBuilder(); //strSql1.Append(" Update Rent_Rent set IsAvailable=1"); //strSql1.Append(" where RentNo = '" + rentAttribute.RentNo + "'"); //Update strSql.Append("INSERT INTO Rent_RentAttribute ([RentNo],[RRAContactName],[RRAContactTel],[RRANationName],[RRAIDCard]," + "[RRentPrice],[RRAContactProvince],[RRAStartDate],[RRAEndDate],[RRARealEndDate],[RRACheckOutPerson],[RRACheckOutReason],[RRADescription],[RRACreatedBy]," + "[RRACreatedDate],[RRAModifiedBy],[RRAModifiedDate],[RRAIsActive],[RRAStatus],[AppId],[Body],[MchId],[TradeNO],[TotalFee],[PrepayID]) values ("); strSql.Append(" '" + rentAttribute.RentNo + "',"); strSql.Append(" '" + rentAttribute.RRAContactName + "',"); strSql.Append(" '" + rentAttribute.RRAContactTel + "',"); strSql.Append(" '" + rentAttribute.RRANationName + "',"); strSql.Append(" '" + rentAttribute.RRAIDCard + "',"); strSql.Append(" '" + rentAttribute.RRentPrice + "', "); strSql.Append(" '" + rentAttribute.RRAContactProvince + "' ,"); strSql.Append(" '" + rentAttribute.RRAStartDate + "','" + rentAttribute.RRAEndDate + "',null,'','',"); strSql.Append(" '" + rentAttribute.RRADescription + "',"); strSql.Append(" '" + rentAttribute.RRACreatedBy + "',"); strSql.Append(" '" + rentAttribute.RRACreatedDate.ToString("yyyy-MM-dd HH:mm:ss") + "', "); strSql.Append("'" + rentAttribute.RRACreatedBy + "','" + rentAttribute.RRACreatedDate.ToString("yyyy-MM-dd HH:mm:ss") + "', 0 ,'" + rentAttribute.Status + "','','','','',0,''"); strSql.Append(" )"); strSql.Append(" select @@identity"); List <SqlCommand> listSQL = new List <SqlCommand>(); listSQL.Add(MySQLHelper.CreateCommand(strSql.ToString())); DataSet ds = MySQLHelper.ExecuteDataset(SqlConnString, MySQLHelper.CreateCommand(strSql.ToString())); string sql = "select top 1 * from Rent_RentAttribute where RentNo = '" + rentAttribute.RentNo + "' order by RRAID desc"; DataTable dt2 = MySQLHelper.ExecuteDataset(SqlConnString, MySQLHelper.CreateCommand(sql)).Tables[0]; SMS.CommonServices service = new SMS.CommonServices(); string approveMsg = ConfigurationManager.AppSettings["ApproveMessage"].ToString(); RentInfo info = new RentInfo(rentAttribute.RentNo); service.SendMsg(info.ROwnerTel, approveMsg); CFUserInfo userInfo = new CFUserInfo(info.RIDCard, false); LockManager manager = new LockManager(); manager.SendMessageToDevice(userInfo.DeviceID, approveMsg, dt2.Rows[0]["RRAID"].ToString(), userInfo.IDCard); SysLogHelper.AddLog(rentAttribute.RRACreatedBy, "增加租赁信息ID:" + rentAttribute.RentNo, "增加-租赁信息"); return(dt2.Rows[0]["RRAID"].ToString()); }
/// <summary> /// 删除密码和IC卡 /// </summary> /// <param name="aarId"></param> /// <returns></returns> public string ClearPasswordToLock(string aarId) { Dictionary <string, string> dic = new Dictionary <string, string>(); RentAttribute a = new RentAttribute(int.Parse(aarId)); DataTable dt = MySQLHelper.ExecuteDataset(MySQLHelper.SqlConnString, MySQLHelper.CreateCommand("select * from Rent_Locks where rentno='" + a.RentNo + "'")).Tables[0]; if (dt.Rows.Count > 0) { string returnStr1 = string.Empty; if (dt.Rows[0]["DeviceType"].ToString() == "1") //新锁 { NewLockManager managerNew = new NewLockManager(); //清空临时卡 string iCCard = managerNew.delAction(a.RRAContactTel, "临时卡片", a.RRAStartDate.ToString(), a.RRAEndDate.ToString(), dt.Rows[0]["DeviceID"].ToString(), "1"); //清空临时密码 string password = managerNew.delAction(a.RRAContactTel, "临时密码", a.RRAStartDate.ToString(), a.RRAEndDate.ToString(), dt.Rows[0]["DeviceID"].ToString(), "1"); Dictionary <string, object> retIC = new Dictionary <string, object>(); retIC = JSONHelper.FromJson <Dictionary <string, object> >(iCCard); Dictionary <string, object> retPass = new Dictionary <string, object>(); retPass = JSONHelper.FromJson <Dictionary <string, object> >(password); if (retIC["ret"].ToString() == "1" || retPass["ret"].ToString() == "1") { returnStr1 = "ICCard:" + retIC["msg"].ToString() + "Pass:"******"msg"].ToString(); } } else //旧锁 { string sql = "select * from Rent_Locks_ICCards where LockID='" + dt.Rows[0]["DeviceID"].ToString() + "' and StartDate='" + a.RRAStartDate.ToString("yyyy-MM-dd HH:mm:ss") + "' and EndDate='" + a.RRAEndDate.ToString("yyyy-MM-dd HH:mm:ss") + "'"; LockManager manager = new LockManager(); DataTable dt1 = MySQLHelper.ExecuteDataset(MySQLHelper.SqlConnString, MySQLHelper.CreateCommand(sql)).Tables[0]; foreach (DataRow row in dt1.Rows) { string returnStr = manager.UpdatePassengerInfoToDevice(dt.Rows[0]["DeviceID"].ToString(), row["ICCard"].ToString(), "", "", "", a.RRAStartDate.ToString("yyyyMMddHHmm").Substring(2, 10), a.RRAEndDate.ToString("yyyyMMddHHmm").Substring(2, 10), "2"); } returnStr1 = manager.UpdatePassengerInfoToDevice(dt.Rows[0]["DeviceID"].ToString(), "", "", "", a.RRANationName, a.RRAStartDate.ToString("yyyyMMddHHmm").Substring(2, 10), a.RRAEndDate.ToString("yyyyMMddHHmm").Substring(2, 10), "4"); } dic.Add("ret", "0"); dic.Add("msg", returnStr1); } else { dic.Add("ret", "1"); dic.Add("msg", "未发现智能锁信息,无法添加密码"); } return(JSONHelper.ToJson(dic)); }
public void ConfirmRentAttribute(string id, string fee, string RRAContactProvince) { //UpdateStatus(id, ((int)RentAttributeHelper.AttributeStatus.NeedPay).ToString()); string sql1 = "update Rent_RentAttribute set rrastatus='" + ((int)RentAttributeHelper.AttributeStatus.NeedPay).ToString() + "',rrentprice='" + fee + "', RRAContactProvince='" + RRAContactProvince + "' where rraid=" + id; MySQLHelper.ExecuteNonQuery(MySQLHelper.SqlConnString, MySQLHelper.CreateCommand(sql1)); string sql = "select * from Rent_RentAttribute where rraid=" + id; DataTable dt = MySQLHelper.ExecuteDataset(MySQLHelper.SqlConnString, MySQLHelper.CreateCommand(sql)).Tables[0]; if (dt.Rows.Count > 0) { SMS.CommonServices service = new SMS.CommonServices(); string approveMsg = ConfigurationManager.AppSettings["NeedPayMessage"].ToString(); service.SendMsg(dt.Rows[0]["RRAContactTel"].ToString(), approveMsg); CFUserInfo userInfo = new CFUserInfo(dt.Rows[0]["RRAIDCard"].ToString(), false); LockManager manager = new LockManager(); manager.SendMessageToDevice(userInfo.DeviceID, approveMsg, id, userInfo.IDCard); } }