public bool deleteUserInfo(ServerInfo info, Protocol pro) { this.info = info; string sqlStorePath = null; try { sqlStorePath = this.info.confMap.value(strConfKey.SqlStorePath); } catch (Exception) { sqlStorePath = DefaultConf.defaultSqlStorePath; } Fetch_Sql_From_Xml fetch = new Fetch_Sql_From_Xml(sqlStorePath); Sql_Struct sql = fetch.readSqlById("delete_user"); SqlHandle handle = new SqlHandle(info.dbInfo); if (handle.connect()) { //与之相关的g_ins,gouts也应该删除 sql.addParam("user", pro.param[0]); bool b = handle.execute(sql.getSql()); handle.close(); return b; } return false; }
public List<List<string>> fetchAuthorityLists(ServerInfo info, Protocol pro) { this.info = info; string sqlStorePath = null; try { sqlStorePath = this.info.confMap.value(strConfKey.SqlStorePath); } catch (Exception) { sqlStorePath = DefaultConf.defaultSqlStorePath; } Fetch_Sql_From_Xml fetch = new Fetch_Sql_From_Xml(sqlStorePath); Sql_Struct sql1 = fetch.readSqlById(getAllAuthories); SqlHandle handle = new SqlHandle(info.dbInfo); if (handle.connect()) { List<List<string>> data1 = handle.query(sql1.getSql()); handle.close(); return data1; } return null; }
public bool Delete_Depot_Info(ServerInfo info, Protocol pro) { this.info = info; Fetch_Sql_From_Xml fetch = getFetchObject(info); Sql_Struct sql1 = fetch.readSqlById("delete_inlog_by_hid"); Sql_Struct sql2 = fetch.readSqlById("delete_outlog_by_hid"); Sql_Struct sql3 = fetch.readSqlById("delete_depot_by_hid"); //还有跟之相关的gconts中的记录也应删除 SqlHandle handle = new SqlHandle(info.dbInfo); if (handle.connect()) { bool flag=false; sql1.addParam("h_id", pro.param[0]); sql2.addParam("h_id", pro.param[0]); sql3.addParam("h_id", pro.param[0]); if (handle.execute(sql1.getSql()) && handle.execute(sql2.getSql()) && handle.execute(sql3.getSql())) { flag = true; } handle.close(); return flag; } return true; }
public List<List<List<string>>> Get_IN_Need_Info(ServerInfo info,Protocol pro) { this.info = info; Fetch_Sql_From_Xml fetch = getFetchObject(info); Sql_Struct sql1 = fetch.readSqlById("get_goods_info_No_price"); Sql_Struct sql2 = fetch.readSqlById("get_depot_list"); Sql_Struct sql3 = fetch.readSqlById("get_all_store"); Sql_Struct sql4 = fetch.readSqlById("get_all_style"); SqlHandle handle = new SqlHandle(info.dbInfo); if (handle.connect()) { List<List<string>> data1 = handle.query(sql1.getSql()); List<List<string>> data2 = handle.query(sql2.getSql()); List<List<string>> data3 = handle.query(sql3.getSql()); List<List<string>> data4 = handle.query(sql4.getSql()); if (data1 != null && data2 != null && sql3 != null && sql4 != null) { List<List<List<string>>> mutilData = new List<List<List<string>>>(); mutilData.Add(data1); mutilData.Add(data2); mutilData.Add(data3); mutilData.Add(data4); handle.close(); return mutilData; } else { handle.close(); return null; } } return null; }
public bool Add_Goods_Info(ServerInfo info, Protocol pro) { this.info = info; Fetch_Sql_From_Xml fetch = getFetchObject(info); Sql_Struct sql1 = fetch.readSqlById("get_sid_by_sname"); Sql_Struct sql2 = fetch.readSqlById("add_goods_info"); SqlHandle handle = new SqlHandle(info.dbInfo); if (handle.connect()) { bool result = false; sql1.addParam("s_name", pro.param[3]); List<List<string>> data = handle.query(sql1.getSql()); if(data!=null) { sql2.addParam("g_name", pro.param[0]); sql2.addParam("g_addr", pro.param[1]); sql2.addParam("g_price", pro.param[2]); sql2.addParam("s_id", data[0][0]); if (handle.execute(sql2.getSql())) result = true; } handle.close(); return result; } return false; }
public List<List<string>> login(ServerInfo info, Protocol pro) { //fetch sql this.info = info; string sqlStorePath=null; try{ sqlStorePath=this.info.confMap.value(strConfKey.SqlStorePath); }catch(Exception){ sqlStorePath = DefaultConf.defaultSqlStorePath; } Fetch_Sql_From_Xml fetch = new Fetch_Sql_From_Xml(sqlStorePath); Sql_Struct sql = fetch.readSqlById(sqlName); if(sql.addParam(param1,pro.param[0]) && sql.addParam(param2,pro.param[1])) Log.WriteLog(LogLevel.MSG,pro.param[0]+" is trying to login"); //excute sql SqlHandle handle = new SqlHandle(info.dbInfo); if (handle.connect()) { List<List<string>> data=handle.query(sql.getSql()); handle.close(); return data; } return null; }
public List<List<string>> Get_All_Depot_Info(ServerInfo info,Protocol pro) { this.info = info; Fetch_Sql_From_Xml fetch = getFetchObject(info); Sql_Struct sql = fetch.readSqlById("get_all_depot"); SqlHandle handle = new SqlHandle(info.dbInfo); if (handle.connect()) { List<List<string>> data = handle.query(sql.getSql()); handle.close(); return data; } return null; }
public bool Add_Style(ServerInfo info, Protocol pro) { this.info = info; Fetch_Sql_From_Xml fetch = getFetchObject(info); Sql_Struct sql = fetch.readSqlById("add_style"); SqlHandle handle = new SqlHandle(info.dbInfo); if (handle.connect()) { sql.addParam("s_name", pro.param[0]); bool b = handle.execute(sql.getSql()); handle.close(); return b; } return false; }
public bool Add_Depot_Info(ServerInfo info, Protocol pro) { this.info = info; Fetch_Sql_From_Xml fetch = getFetchObject(info); Sql_Struct sql1 = fetch.readSqlById("add_depot"); SqlHandle handle = new SqlHandle(info.dbInfo); if (handle.connect()) { bool result = false; sql1.addParam("h_name", pro.param[0]); if (handle.execute(sql1.getSql())) { result = true; } handle.close(); return result; } return false; }
public bool Update_Style(ServerInfo info, Protocol pro) { this.info = info; Fetch_Sql_From_Xml fetch = getFetchObject(info); Sql_Struct sql = fetch.readSqlById("update_stylename_by_styleId"); SqlHandle handle = new SqlHandle(info.dbInfo); if(handle.connect()){ sql.addParam("s_name", pro.param[1]); sql.addParam("s_id", pro.param[0]); if (handle.execute(sql.getSql())) { handle.close(); return true; } handle.close(); return false; } return false; }
public bool Delete_Goods_Info(ServerInfo info, Protocol pro) { this.info = info; Fetch_Sql_From_Xml fetch = getFetchObject(info); Sql_Struct sql = fetch.readSqlById("delete_goods_info_by_name"); //与之相关的gins,gouts,gcounts也应该删除 SqlHandle handle = new SqlHandle(info.dbInfo); if (handle.connect()) { bool flag=false; sql.addParam("g_name", pro.param[0]); if (handle.execute(sql.getSql())) { flag = true; } handle.close(); return flag; } return true; }
public bool Delete_Style(ServerInfo info, Protocol pro) { this.info = info; Fetch_Sql_From_Xml fetch = getFetchObject(info); //与之相关的gins,gouts, Sql_Struct sql1 = fetch.readSqlById("delete_info_by_styleId"); Sql_Struct sql2 = fetch.readSqlById("delete_style_by_sid"); SqlHandle handle = new SqlHandle(info.dbInfo); if (handle.connect()) { sql1.addParam("sid", pro.param[0]); sql2.addParam("sid", pro.param[0]); if (handle.execute(sql1.getSql())) if (handle.execute(sql2.getSql())) { handle.close(); return true; } handle.close(); return false; } return false; }
public bool Update_Depot_Info(ServerInfo info, Protocol pro) { this.info = info; Fetch_Sql_From_Xml fetch = getFetchObject(info); Sql_Struct sql1 = fetch.readSqlById("update_depot_by_hid"); SqlHandle handle = new SqlHandle(info.dbInfo); if (handle.connect()) { bool flag = false; sql1.addParam("h_name", pro.param[1]); sql1.addParam("h_id", pro.param[0]); if (handle.execute(sql1.getSql())) { handle.close(); flag = true; } return flag; } return false; }
public List<List<List<string>>> getModifyingUserInfo(ServerInfo info, Protocol pro) { this.info = info; string sqlStorePath = null; try { sqlStorePath = this.info.confMap.value(strConfKey.SqlStorePath); }catch(Exception){ sqlStorePath = DefaultConf.defaultSqlStorePath; } Fetch_Sql_From_Xml fetch = new Fetch_Sql_From_Xml(sqlStorePath); Sql_Struct sql = fetch.readSqlById(getModifyingUserInfoSqlName); Sql_Struct sql2 = fetch.readSqlById(getAllAuthories); SqlHandle handle = new SqlHandle(info.dbInfo); if(handle.connect()){ sql.addParam("user",pro.param[0]); List<List<string>> data1=handle.query(sql.getSql()); List<List<string>> data2=handle.query(sql2.getSql()); List<List<List<string>>> mutilDatas=new List<List<List<string>>>(); handle.close(); mutilDatas.Add(data1); mutilDatas.Add(data2); return mutilDatas; } return null; }
public bool Update_Goods_Info(ServerInfo info, Protocol pro) { this.info = info; Fetch_Sql_From_Xml fetch = getFetchObject(info); Sql_Struct sql1 = fetch.readSqlById("get_sid_by_sname"); Sql_Struct sql2 = fetch.readSqlById("update_goods_info_by_name"); SqlHandle handle = new SqlHandle(info.dbInfo); if (handle.connect()) { sql1.addParam("s_name", pro.param[3]); List<List<string>> names = handle.query(sql1.getSql()); if (names != null) { sql2.addParam("g_addr",pro.param[1]); sql2.addParam("g_price", pro.param[2]); sql2.addParam("s_id", names[0][0]); sql2.addParam("g_name", pro.param[0]); if (handle.execute(sql2.getSql())) { return true; } } } return false; }
public bool In_Goods(ServerInfo info, Protocol pro) { this.info = info; string uname=info.session.getName(pro.Session); string gname=pro.param[0]; string hname=pro.param[1]; string idate=pro.param[3]; string inum=pro.param[2]; Fetch_Sql_From_Xml fetch = getFetchObject(info); SqlHandle handle = new SqlHandle(info.dbInfo); if (handle.connect()) { bool flag = false; //首先判断一下,是否存在相应的记录 //如果存在,则更新,如果不存在,则添加 //同时添加log 到g_ins Sql_Struct sql = fetch.readSqlById("get_store_id_by_hname_gname"); sql.addParam("gname",gname); sql.addParam("hname",hname); List<List<string>> data = handle.query(sql.getSql()); if (data != null && data.Count > 0) { sql = fetch.readSqlById("update_store_counts_by_id"); sql.addParam("cnum",inum); sql.addParam("cid",data[0][0]); if (handle.execute(sql.getSql())) flag = true; } else if (data != null && data.Count == 0) { sql = fetch.readSqlById("add_store_counts"); Sql_Struct sqlHid = fetch.readSqlById("get_hid_by_hname"); sqlHid.addParam("hname", hname); Sql_Struct sqlGid = fetch.readSqlById("get_gid_by_gname"); sqlGid.addParam("gname", gname); List<List<string>> hidList = handle.query(sqlHid.getSql()); List<List<string>> gidList = handle.query(sqlGid.getSql()); if (hidList != null && gidList != null) { sql.addParam("gid",gidList[0][0]); sql.addParam("hid",hidList[0][0]); sql.addParam("cnum",inum); if (handle.execute(sql.getSql())) flag = true; } } else { flag = false; } handle.close(); if(flag) if (!this.Add_In_Logs(info, pro, "add_in_log")) flag = false; return flag; } return false; }
public bool Register_User_Info(ServerInfo info, Protocol pro) { this.info = info; string sqlStorePath = null; try { sqlStorePath = this.info.confMap.value(strConfKey.SqlStorePath); } catch (Exception) { sqlStorePath = DefaultConf.defaultSqlStorePath; } Fetch_Sql_From_Xml fetch = new Fetch_Sql_From_Xml(sqlStorePath); Sql_Struct sql = fetch.readSqlById("get_loa_id_by_name"); Sql_Struct sql2 = fetch.readSqlById("register_user"); SqlHandle handle = new SqlHandle(info.dbInfo); if (handle.connect()) { sql.addParam("loaName",pro.param[2]); List<List<string>> result = handle.query(sql.getSql()); if (result == null || result.Count==0) return false; sql2.addParam("user", pro.param[0]); sql2.addParam("passwd", pro.param[1]); sql2.addParam("loa", result[0][0]); bool b = handle.execute(sql2.getSql()); handle.close(); return b; } return false; }
public bool updateUserInfo(ServerInfo info, Protocol pro) { this.info = info; string sqlStorePath = null; try { sqlStorePath = this.info.confMap.value(strConfKey.SqlStorePath); } catch (Exception) { sqlStorePath = DefaultConf.defaultSqlStorePath; } Fetch_Sql_From_Xml fetch = new Fetch_Sql_From_Xml(sqlStorePath); Sql_Struct sql = fetch.readSqlById("get_loa_id_by_name"); Sql_Struct sql2 = fetch.readSqlById("get_user_id_by_name"); Sql_Struct sql3 = fetch.readSqlById("update_user_info"); SqlHandle handle = new SqlHandle(info.dbInfo); if (handle.connect()) { sql.addParam("loaName", pro.param[2]); sql2.addParam("user", pro.param[0]); List<List<string>> data1 = handle.query(sql.getSql()); List<List<string>> data2 = handle.query(sql2.getSql()); if (data1 != null && data2 != null) { sql3.addParam("passwd", pro.param[1]); sql3.addParam("loa", data1[0][0]); sql3.addParam("id", data2[0][0]); bool b= handle.execute(sql3.getSql()); handle.close(); return b; } else { return false; } } return false; }
private List<List<string>> Fetch_Log(ServerInfo info, Protocol pro, string sqlName) { Fetch_Sql_From_Xml fetch = getFetchObject(info); SqlHandle handle = new SqlHandle(info.dbInfo); List<List<string>> data = null; if (handle.connect()) { Sql_Struct sql = fetch.readSqlById(sqlName); data= handle.query(sql.getSql()); handle.close(); } return data; }
private bool Add_In_Logs(ServerInfo info,Protocol pro,string add_where) { string uname = info.session.getName(pro.Session); string gname = pro.param[0]; string hname = pro.param[1]; string idate = pro.param[3]; string inum = pro.param[2]; Fetch_Sql_From_Xml fetch = getFetchObject(info); Sql_Struct sqlUID = fetch.readSqlById("get_uid_by_uname"); sqlUID.addParam("uname", uname); Sql_Struct sqlGID = fetch.readSqlById("get_gid_by_gname"); sqlGID.addParam("gname", gname); Sql_Struct sqlHID = fetch.readSqlById("get_hid_by_hname"); sqlHID.addParam("hname", hname); SqlHandle handle = new SqlHandle(info.dbInfo); bool flag = false; if (handle.connect()) { List<List<string>> uid = handle.query(sqlUID.getSql()); List<List<string>> gid = handle.query(sqlGID.getSql()); List<List<string>> hid = handle.query(sqlHID.getSql()); if (uid != null && gid != null && hid != null) { Sql_Struct in_log = fetch.readSqlById(add_where); in_log.addParam("uid",uid[0][0]); in_log.addParam("hid",hid[0][0]); in_log.addParam("gid",gid[0][0]); in_log.addParam("idate", idate); in_log.addParam("inum", inum); if (handle.execute(in_log.getSql())) { flag = true; } } handle.close(); } return flag; }
public bool Out_Goods(ServerInfo info, Protocol pro) { this.info = info; string uname = info.session.getName(pro.Session); string gname = pro.param[0]; string hname = pro.param[1]; string idate = pro.param[3]; string inum = pro.param[2]; Fetch_Sql_From_Xml fetch = getFetchObject(info); SqlHandle handle = new SqlHandle(info.dbInfo); bool flag = true; if (handle.connect()) { Sql_Struct sql = fetch.readSqlById("get_store_id_by_hname_gname"); sql.addParam("gname", gname); sql.addParam("hname", hname); List<List<string>> data = handle.query(sql.getSql()); if (data != null && data.Count > 0) { sql = fetch.readSqlById("fetch_store_counts_by_id"); sql.addParam("cnum", inum); sql.addParam("cid", data[0][0]); if (handle.execute(sql.getSql())) flag = true; } } handle.close(); if (flag) if (!this.Add_In_Logs(info, pro, "add_out_log")) flag = false; return flag; }
public List<List<string>> getAllUserInfo(ServerInfo info, Protocol pro) { //fetch sql this.info = info; string sqlStorePath = null; try { sqlStorePath = this.info.confMap.value(strConfKey.SqlStorePath); } catch (Exception) { sqlStorePath = DefaultConf.defaultSqlStorePath; } Fetch_Sql_From_Xml fetch = new Fetch_Sql_From_Xml(sqlStorePath); Sql_Struct sql = fetch.readSqlById(sqlName); //excute sql SqlHandle handle = new SqlHandle(info.dbInfo); if (handle.connect()) { List<List<string>> data = handle.query(sql.getSql()); handle.close(); return data; } return null; }