/* * =========================================== * 留言模块 * =========================================== */ #region 留言模块 /// <summary> /// 获取留言列表 /// </summary> /// <returns></returns> public List <Models> GetMessageList(string page, string limit, ref long total) { List <Models> list = new List <Models>(); DataSet ds = null; OpSql.Open(); try { string sql = string.Format(@" select SQL_CALC_FOUND_ROWS * from g_message order by m_isread asc, m_id desc limit {0},{1}; select CAST(FOUND_ROWS() as SIGNED) as total; ", (int.Parse(page) - 1) * int.Parse(limit), int.Parse(limit)); ds = OpSql.Select(sql); if (ds != null && ds.Tables.Count > 0) { List <g_message> list1 = m_gml.g_message(ds.Tables[0]); for (int i = 0; i < list1.Count; i++) { Models mod = new Models(); mod.g_message = list1[i]; list.Add(mod); } total = (long)ds.Tables[1].Rows[0]["total"]; } } catch { } finally { OpSql.Close(); } return(list); }
/// <summary> /// 添加充电监控数据 /// </summary> public bool AddAMCIMData(AM_CIMData mod) { bool b = false; OpSql.Open(); try { DataSet ds = new DataSet(); object[] obj = new object[] { mod.cs_id, mod.t_id, mod.v_id, mod.cp_id, mod.cp_code, mod.cb_id, mod.cb_code, mod.am_cimd_begintime, mod.am_cimd_endtime, mod.am_cimd_kwh, mod.am_cimd_unitmoney, mod.am_cimd_money, mod.am_cimd_health, mod.am_cimd_chargenum, mod.u_id }; b = OpSql.Selectproce("Listener_IncludeCIMTCPReceive_UP0006", obj, ref ds); } catch { } finally { OpSql.Close(); } return(b); }
/// <summary> /// 获取充电站 /// </summary> /// <param name="cs_id">充电站编号</param> /// <returns></returns> public List <Models> GetChargeStation(long cs_id) { List <Models> list = new List <Models>(); OpSql.Open(); try { string sql = string.Format("select * from (" + "select * from G_ChargeStation where cs_id={0}" + ") as t1 " + "left join G_Province as gp on t1.p_id=gp.p_id " + "left join G_City as gc on t1.c_id=gc.c_id " + "left join G_District as gd on t1.d_id=gd.d_id", cs_id); DataSet ds = OpSql.Select(sql); if (ds != null && ds.Tables.Count > 0) { List <G_ChargeStation> list1 = m_gml.G_ChargeStation(ds.Tables[0]); List <G_Province> list2 = m_gml.G_Province(ds.Tables[0]); List <G_City> list3 = m_gml.G_City(ds.Tables[0]); List <G_District> list4 = m_gml.G_District(ds.Tables[0]); for (int i = 0; i < list1.Count; i++) { Models mod = new Models(); mod.G_ChargeStation = list1[i]; mod.G_Province = list2[i]; mod.G_City = list3[i]; mod.G_District = list4[i]; list.Add(mod); } } } catch { } finally { OpSql.Close(); } return(list); }
/// <summary> /// 获取信息 /// </summary> /// <returns></returns> public Models GetNews(string nt_id, string n_id) { Models detail = new Models(); DataSet ds = null; OpSql.Open(); try { string sql = string.Format(@" select * from g_news where nt_id={0} and n_id={1} ", nt_id, n_id); ds = OpSql.Select(sql); if (ds != null && ds.Tables.Count > 0) { List <g_news> list1 = m_gml.g_news(ds.Tables[0]); if (list1.Count > 0) { detail.g_news = list1[0]; } } } catch { } finally { OpSql.Close(); } return(detail); }
/// <summary> /// 管理员登录 /// </summary> /// <param name="a_uname">管理员用户名</param> /// <param name="a_pwd">管理员密码(明文)</param> /// <param name="isremember">是否记住</param> public bool Login(string a_uname, string a_pwd, bool isremember) { bool b = false; OpSql.Open(); try { string sql = string.Format("select * from G_Admin where a_uname='{0}' and a_pwd='{1}'", a_uname, OpString.DESEncryption(a_pwd)); DataSet ds = OpSql.Select(sql); if (ds != null && ds.Tables.Count > 0) { DataTable dt = ds.Tables[0]; if (dt.Rows.Count > 0) { if (CreateCookie_Login(dt.Rows[0]["a_id"].ToString(), dt.Rows[0]["a_uname"].ToString(), isremember)) { b = true; } } } } catch { } finally { OpSql.Close(); } return(b); }
/// <summary> /// 获取留言 /// </summary> /// <returns></returns> public Models GetMessage(string m_id) { Models detail = new Models(); DataSet ds = null; OpSql.Open(); try { string sql = string.Format(@" select * from g_message where m_id={0} ", m_id); ds = OpSql.Select(sql); if (ds != null && ds.Tables.Count > 0) { List <g_message> list1 = m_gml.g_message(ds.Tables[0]); if (list1.Count > 0) { detail.g_message = list1[0]; } } } catch { } finally { OpSql.Close(); } return(detail); }
/* * =========================================== * 信息模块 * =========================================== */ #region 信息模块 /// <summary> /// 获取信息列表 /// </summary> /// <returns></returns> public List <Models> GetNewsList() { List <Models> list = new List <Models>(); DataSet ds = null; OpSql.Open(); try { string sql = string.Format(@" select * from g_news order by nt_id asc, n_top desc, n_id asc "); ds = OpSql.Select(sql); if (ds != null && ds.Tables.Count > 0) { List <g_news> list1 = m_gml.g_news(ds.Tables[0]); for (int i = 0; i < list1.Count; i++) { Models mod = new Models(); mod.g_news = list1[i]; list.Add(mod); } } } catch { } finally { OpSql.Close(); } return(list); }
/// <summary> /// 获取充电桩报警数据列表 /// </summary> /// <param name="cs_id">充电站编号</param> /// <param name="cp_id">充电站编号(0为不限)</param> /// <param name="am_cimp_examine">是否处理</param> /// <returns></returns> public List <AM_CIMPolice> GetAMCIMPoliceList(long cs_id, long cp_id, bool am_cimp_examine) { List <AM_CIMPolice> list = new List <AM_CIMPolice>(); OpSql.Open(); try { string sql = ""; if (cp_id > 0) { sql = string.Format("" + "select * from AM_CIMPolice where cs_id={0} and cp_id={1} and am_cimp_examine={2}" + "", cs_id, cp_id, Convert.ToInt32(am_cimp_examine)); } else { sql = string.Format("" + "select * from AM_CIMPolice where cs_id={0} and am_cimp_examine={1}" + "", cs_id, Convert.ToInt32(am_cimp_examine)); } DataSet ds = OpSql.Select(sql); if (ds != null && ds.Tables.Count > 0) { list = m_gml.AM_CIMPolice(ds.Tables[0]); } } catch { } finally { OpSql.Close(); } return(list); }
/// <summary> /// 获取ic卡 /// </summary> /// <param name="pay_ic_id">卡号</param> /// <returns></returns> public List <Models> GetIcCardList(long pay_ic_id) { List <Models> list = new List <Models>(); OpSql.Open(); try { string sql = string.Format("select * from PAY_IdCard as a " + "left join G_User as b on a.u_id=b.u_id " + "where a.pay_ic_id={0}" , pay_ic_id); DataSet ds = OpSql.Select(sql); if (ds != null && ds.Tables.Count > 0) { List <PAY_IdCard> list1 = m_gml.PAY_IdCard(ds.Tables[0]); List <G_User> list2 = m_gml.G_User(ds.Tables[0]); for (int i = 0; i < list1.Count; i++) { Models mod = new Models(); mod.PAY_IdCard = list1[i]; mod.G_User = list2[i]; list.Add(mod); } } } catch { } finally { OpSql.Close(); } return(list); }
/// <summary> /// 添加电池 /// </summary> public bool AddChargeBattery(G_ChargeBattery mod) { bool b = false; OpSql.Open(); try { b = OpSql.Insert(new object[] { mod }); } catch { } finally { OpSql.Close(); } return(b); }
/// <summary> /// 修改充电站 /// </summary> /// <param name="mod">旧G_ChargeStation实体</param> /// <param name="mod2">新G_ChargeStation实体</param> public bool EditChargeStation(G_ChargeStation mod, G_ChargeStation mod2) { bool b = false; OpSql.Open(); try { b = OpSql.Update(new object[] { mod }, new object[] { mod2 }); } catch { } finally { OpSql.Close(); } return(b); }
/// <summary> /// 删除社区 /// </summary> /// <param name="mod">G_Community实体</param> public bool DelCommunity(G_Community mod) { bool b = false; OpSql.Open(); try { b = OpSql.Delete(new object[] { mod }); } catch { } finally { OpSql.Close(); } return(b); }
/// <summary> /// 修改充电桩报警数据 /// </summary> public bool EditAMCIMPolice(AM_CIMPolice mod, AM_CIMPolice mod2) { bool b = false; OpSql.Open(); try { b = OpSql.Update(new object[] { mod }, new object[] { mod2 }); } catch { } finally { OpSql.Close(); } return(b); }
/// <summary> /// 修改留言 /// </summary> /// <returns></returns> public bool EditMessage(g_message mod, g_message mod2) { bool b = false; OpSql.Open(); try { b = OpSql.Update(new object[] { mod }, new object[] { mod2 }); } catch { } finally { OpSql.Close(); } return(b); }
/* * =========================================== * 留言 * =========================================== */ #region 留言 /// <summary> /// 添加留言 /// </summary> /// <param name="mod">mod</param> public bool AddMessage(g_message mod) { bool b = false; OpSql.Open(); try { b = OpSql.Insert(new object[] { mod }); } catch { } finally { OpSql.Close(); } return(b); }
/// <summary> /// 删除信息类型 /// </summary> /// <returns></returns> public bool DelNewsType(g_newstype mod) { bool b = false; OpSql.Open(); try { b = OpSql.Delete(new object[] { mod }); } catch { } finally { OpSql.Close(); } return(b); }
/// <summary> /// 添加充电桩报警数据 /// </summary> public bool AddAMCIMPolice(AM_CIMPolice mod) { bool b = false; OpSql.Open(); try { b = OpSql.Insert(new object[] { mod }); } catch { } finally { OpSql.Close(); } return(b); }
/// <summary> /// 删除街道 /// </summary> /// <param name="mod">G_Street实体</param> public bool DelStreet(G_Street mod) { bool b = false; OpSql.Open(); try { b = OpSql.Delete(new object[] { mod }); } catch { } finally { OpSql.Close(); } return(b); }
/// <summary> /// 添加日志 /// </summary> /// <returns></returns> public bool AddSystemError(LOG_SystemError mod) { //记录上行内容 bool b = false; OpSql.Open(); try { b = OpSql.Insert(new object[] { mod }); } catch { } finally { OpSql.Close(); } return(b); }
/// <summary> /// 获取信息列表 /// </summary> /// <returns></returns> public List <Models> GetNewsList(string page, string limit, ref long total, string n_title, string nt_id, string n_examine) { List <Models> list = new List <Models>(); DataSet ds = null; OpSql.Open(); try { string where = ""; if (!string.IsNullOrEmpty(n_title)) { where += string.Format(" and t1.n_title like '%{0}%'", n_title); } if (!string.IsNullOrEmpty(nt_id)) { where += string.Format(" and t1.nt_id = {0}", nt_id); } if (!string.IsNullOrEmpty(n_examine)) { where += string.Format(" and t1.n_examine = {0}", n_examine); } string sql = string.Format(@" select SQL_CALC_FOUND_ROWS * from g_news as t1 left join g_newstype as t2 on t1.nt_id=t2.nt_id where 1=1{2} order by t1.nt_id asc, t1.n_top desc, t1.n_id asc limit {0},{1}; select CAST(FOUND_ROWS() as SIGNED) as total; ", (int.Parse(page) - 1) * int.Parse(limit), int.Parse(limit), where); ds = OpSql.Select(sql); if (ds != null && ds.Tables.Count > 0) { List <g_news> list1 = m_gml.g_news(ds.Tables[0]); List <g_newstype> list2 = m_gml.g_newstype(ds.Tables[0]); for (int i = 0; i < list1.Count; i++) { Models mod = new Models(); mod.g_news = list1[i]; mod.g_newstype = list2[i]; list.Add(mod); } total = (long)ds.Tables[1].Rows[0]["total"]; } } catch { } finally { OpSql.Close(); } return(list); }
/// <summary> /// 登录充电站 /// </summary> /// <param name="u_name">用户用户名</param> /// <param name="u_pwd">用户密码(密文)</param> public Dictionary <string, object> LoginChargeStation(string u_name, string u_pwd) { Dictionary <string, object> dic = new Dictionary <string, object>() { { "condition", 0 }, { "cs_id", 0 }, { "isglobal", false } }; OpSql.Open(); try { string sql = string.Format("select * from G_ChargeStation where cs_uname='{0}' and cs_pwd='{1}' and cs_examine=1", u_name, u_pwd); DataSet ds = OpSql.Select(sql); if (ds != null && ds.Tables.Count > 0) { List <G_ChargeStation> list = m_gml.G_ChargeStation(ds.Tables[0]); if (list.Count > 0) { DateTime now = DateTime.Now; if (now >= (DateTime)list[0].cs_endtime) { //账号过期 dic["condition"] = -1; } else if (!(bool)list[0].cs_examine) { //账号未激活 dic["condition"] = -2; } else { dic["cs_id"] = (long)list[0].cs_id; //登录成功 dic["condition"] = 1; dic["isglobal"] = (bool)list[0].cs_isglobal; } } } } catch { } finally { OpSql.Close(); } return(dic); }
/// <summary> /// 查询IP地址今日是否已留言 /// </summary> public bool HasMessageToday() { bool b = false; DataSet ds = null; OpSql.Open(); try { string sql = string.Format("select * from g_message where date(m_addtime)=CURDATE() and m_ip='{0}'", OpMemory.IPAddress); ds = OpSql.Select(sql); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { b = true; } } catch { } finally { OpSql.Close(); } return(b); }
/// <summary> /// 获取街道 /// </summary> /// <param name="s_id">编号</param> /// <returns></returns> public List <G_Street> GetStreet(int?s_id) { List <G_Street> list = new List <G_Street>(); DataSet ds = null; OpSql.Open(); try { string sql = string.Format("select * from G_Street where s_id={0}", s_id); ds = OpSql.Select(sql); if (ds != null && ds.Tables.Count > 0) { list = m_gml.G_Street(ds.Tables[0]); } } catch { } finally { OpSql.Close(); } return(list); }
/// <summary> /// 获取省 /// </summary> /// <param name="p_id">编号</param> /// <returns></returns> public List <G_Province> GetProvince(int?p_id) { List <G_Province> list = new List <G_Province>(); DataSet ds = null; OpSql.Open(); try { string sql = string.Format("select * from G_Province where p_id={0}", p_id); ds = OpSql.Select(sql); if (ds != null && ds.Tables.Count > 0) { list = m_gml.G_Province(ds.Tables[0]); } } catch { } finally { OpSql.Close(); } return(list); }
/// <summary> /// 获取市列表 /// </summary> /// <returns></returns> public List <G_City> GetCityList() { List <G_City> list = new List <G_City>(); DataSet ds = null; OpSql.Open(); try { string sql = string.Format("select * from G_City"); ds = OpSql.Select(sql); if (ds != null && ds.Tables.Count > 0) { list = m_gml.G_City(ds.Tables[0]); } } catch { } finally { OpSql.Close(); } return(list); }
/// <summary> /// 获取充电桩 /// </summary> /// <param name="u_uname">用户名</param> /// <returns></returns> public List <G_User> GetUser(long u_uname) { List <G_User> list = new List <G_User>(); OpSql.Open(); try { string sql = string.Format("" + "select * from G_User where u_uname={0} and u_examine = 1" + "", u_uname); DataSet ds = OpSql.Select(sql); if (ds != null && ds.Tables.Count > 0) { list = m_gml.G_User(ds.Tables[0]); } } catch { } finally { OpSql.Close(); } return(list); }
/// <summary> /// 获取充电桩 /// </summary> /// <param name="cs_id">充电站编号</param> /// <param name="cp_id">充电桩编号</param> /// <returns></returns> public List <G_ChargePile> GetChargePile(long cs_id, long cp_id) { List <G_ChargePile> list = new List <G_ChargePile>(); OpSql.Open(); try { string sql = string.Format("" + "select * from G_ChargePile where cs_id={0} and cp_id={1}" + "", cs_id, cp_id); DataSet ds = OpSql.Select(sql); if (ds != null && ds.Tables.Count > 0) { list = m_gml.G_ChargePile(ds.Tables[0]); } } catch { } finally { OpSql.Close(); } return(list); }
/// <summary> /// 获取电池 /// </summary> /// <param name="cb_code">电池编码</param> /// <returns></returns> public List <G_ChargeBattery> GetChargeBattery(string cb_code) { List <G_ChargeBattery> list = new List <G_ChargeBattery>(); OpSql.Open(); try { string sql = string.Format("" + "select * from G_ChargeBattery where cb_code='{0}'" + "", cb_code); DataSet ds = OpSql.Select(sql); if (ds != null && ds.Tables.Count > 0) { list = m_gml.G_ChargeBattery(ds.Tables[0]); } } catch { } finally { OpSql.Close(); } return(list); }
/// <summary> /// 获取充电桩列表 /// </summary> /// <param name="cs_id">充电站编号</param> /// <returns></returns> public List <Models> GetChargePileList(long cs_id) { List <Models> list = new List <Models>(); OpSql.Open(); try { string sql = string.Format("" + "if (select cs_isglobal from G_ChargeStation where cs_id={0})=1 " + "begin " + "select * from G_ChargePile as t1 " + "left join G_Type as t2 on t1.t_id=t2.t_id " + "left join G_Version as t3 on t1.v_id=t3.v_id " + "end " + "else " + "begin " + "select * from(select * from G_ChargePile where cs_id={0}) as t1 " + "left join G_Type as t2 on t1.t_id=t2.t_id " + "left join G_Version as t3 on t1.v_id=t3.v_id " + "end", cs_id); DataSet ds = OpSql.Select(sql); if (ds != null && ds.Tables.Count > 0) { List <G_ChargePile> list1 = m_gml.G_ChargePile(ds.Tables[0]); List <G_Type> list2 = m_gml.G_Type(ds.Tables[0]); List <G_Version> list3 = m_gml.G_Version(ds.Tables[0]); for (int i = 0; i < list1.Count; i++) { Models mod = new Models(); mod.G_ChargePile = list1[i]; mod.G_Type = list2[i]; mod.G_Version = list3[i]; list.Add(mod); } } } catch { } finally { OpSql.Close(); } return(list); }