示例#1
0
        public static Protocol Add_Style(ServerInfo sinfo,Protocol pro)
        {
            if (pro.Session != null && sinfo.session.Find(pro.Session))
            {
                StyleHandle uh = new StyleHandle();
                Protocol returnPro = new Protocol();
                if (uh.Add_Style(sinfo, pro))
                {
                    returnPro.protoType = ProtoType.SUCCESS;
                    Log.WriteLog(LogLevel.MSG, sinfo.session.getName(pro.Session) + " is trying to add a style");
                }
                else
                {
                    returnPro.protoType = ProtoType.STYLE_EXISTS;
                }
                return returnPro;

            }
            else
            {
                Protocol returnPro = new Protocol();
                pro.protoType = ProtoType.OUT_OF_TIME;
                return returnPro;
            }
        }
示例#2
0
        /***********************************
         * 删除某用户
         * *********************************/
        public static Protocol Delete_User_Info(Protocol pro)
        {
            if (pro.Session != null && GlobalInfo.session.Find(pro.Session))
            {
                UserHandle uh = new UserHandle();
                Protocol returnPro = new Protocol();

                if (uh.deleteUserInfo(GlobalInfo, pro))
                {

                    returnPro.protoType = ProtoType.SUCCESS;
                    Log.WriteLog(LogLevel.MSG, GlobalInfo.session.getName(pro.Session) + " is trying to delete user");

                }
                else
                {
                    returnPro.protoType = ProtoType.ERROR;
                }
                return returnPro;

            }
            else
            {
                Protocol returnPro = new Protocol();
                pro.protoType = ProtoType.OUT_OF_TIME;
                return returnPro;
            }
        }
示例#3
0
 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;
 }
示例#4
0
        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;
        }
示例#5
0
        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;
        }
示例#6
0
 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;
 }
示例#7
0
        public static Protocol Style_Handle(ServerInfo sinfo, Protocol pro)
        {
            if (pro.Session != null && sinfo.session.Find(pro.Session))
            {

                Protocol returnPro = null;
                if (pro.protoType == ProtoType.ADD_GOODS)
                {
                    returnPro = Add_Goods(sinfo, pro);
                } else if (pro.protoType == ProtoType.GET_ALL_GOODS_INFO)
                {
                    returnPro = Get_All_Goods_Info(sinfo, pro);
                }
                else if (pro.protoType == ProtoType.DELETE_GOODS_INFO)
                {
                    returnPro = Delete_Goods_Info(sinfo, pro);
                }
                else if (pro.protoType == ProtoType.UPDATE_GOODS_INFO)
                {
                    returnPro = Update_Goods_Info(sinfo, pro);
                }

                return returnPro;

            }
            else
            {
                Protocol returnPro = new Protocol();
                pro.protoType = ProtoType.OUT_OF_TIME;
                return returnPro;
            }
        }
示例#8
0
        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;
        }
示例#9
0
        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;
        }
示例#10
0
 public Protocol Fetch_Out_Goods(string session)
 {
     sendPro = new Protocol();
     sendPro.Session = session;
     sendPro.protoType = ProtoType.FETCH_OUT_GOODS;
     if (this.talk())
         return reseivePro;
     else
         return null;
 }
示例#11
0
        private static Protocol Style_Handle(ServerInfo sinfo, Protocol pro)
        {
            if (pro.Session != null && sinfo.session.Find(pro.Session))
            {
                StyleHandle uh = new StyleHandle();
                Protocol returnPro = new Protocol();
                if (pro.protoType == ProtoType.GET_ALL_STYLE)
                {
                    List<List<string>> data = uh.Get_All_Style(sinfo,pro);
                    if (data!=null)
                    {
                        returnPro.protoType = ProtoType.SUCCESS;
                        returnPro.data = data;
                    }
                    else
                    {
                        returnPro.protoType = ProtoType.ERROR;
                    }
                }
                else if (pro.protoType == ProtoType.DELETE_STYLE)
                {
                    if (uh.Delete_Style(sinfo, pro))
                    {
                        Log.WriteLog(LogLevel.MSG, sinfo.session.getName(pro.Session) + " is trying to delete a style");
                        returnPro.protoType = ProtoType.SUCCESS;
                    }
                    else
                    {
                        returnPro.protoType = ProtoType.ERROR;
                    }
                }
                else if (pro.protoType == ProtoType.UPDATE_STYLE)
                {
                    if (uh.Update_Style(sinfo, pro))
                    {
                        Log.WriteLog(LogLevel.MSG, sinfo.session.getName(pro.Session) + " is trying to update a style");
                        returnPro.protoType = ProtoType.SUCCESS;
                    }
                    else
                    {
                        returnPro.protoType = ProtoType.ERROR;
                    }
                }
                return returnPro;

            }
            else
            {
                Protocol returnPro = new Protocol();
                pro.protoType = ProtoType.OUT_OF_TIME;
                return returnPro;
            }
        }
示例#12
0
 public Protocol Delete_Depot(string session, string hid)
 {
     sendPro = new Protocol();
     sendPro.Session = session;
     sendPro.protoType = ProtoType.DELETE_DEPOT;
     sendPro.param = new List<string>();
     sendPro.param.Add(hid);
     if (this.talk())
         return reseivePro;
     else
         return null;
 }
示例#13
0
 private static Protocol Delete_Depot(ServerInfo sinfo, Protocol pro)
 {
     DepotHandle uh = new DepotHandle();
     Protocol returnPro = new Protocol();
     if (uh.Delete_Depot_Info(sinfo,pro))
     {
         returnPro.protoType = ProtoType.SUCCESS;
     }
     else
     {
         returnPro.protoType = ProtoType.ERROR;
     }
     return returnPro;
 }
示例#14
0
 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;
 }
示例#15
0
 private static Protocol Get_All_Depot(ServerInfo sinfo, Protocol pro)
 {
     DepotHandle uh = new DepotHandle();
     Protocol returnPro = new Protocol();
     returnPro.data = uh.Get_All_Depot_Info(sinfo, pro);
     if (returnPro.data!=null)
     {
         returnPro.protoType = ProtoType.SUCCESS;
     }
     else
     {
         returnPro.protoType = ProtoType.ERROR;
     }
     return returnPro;
 }
示例#16
0
 private static Protocol Fetch_Out_Goods(ServerInfo sinfo, Protocol pro)
 {
     In_OutHandle uh = new In_OutHandle();
     Protocol returnPro = new Protocol();
     returnPro.data=uh.Fetch_Out_Log(sinfo,pro);
     if (returnPro.data!=null)
     {
         returnPro.protoType = ProtoType.SUCCESS;
     }
     else
     {
         returnPro.protoType = ProtoType.ERROR;
     }
     return returnPro;
 }
示例#17
0
 private static Protocol Add_Goods(ServerInfo sinfo, Protocol pro)
 {
     GoodsHandle uh = new GoodsHandle();
     Protocol returnPro = new Protocol();
     if (uh.Add_Goods_Info(sinfo, pro))
     {
         Log.WriteLog(LogLevel.MSG, sinfo.session.getName(pro.Session) + " is trying to add a goods info");
         returnPro.protoType = ProtoType.SUCCESS;
     }
     else
     {
         returnPro.protoType = ProtoType.GOODS_EXISTS;
     }
     return returnPro;
 }
示例#18
0
 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;
 }
示例#19
0
 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;
 }
示例#20
0
        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;
        }
示例#21
0
        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;
        }
示例#22
0
 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;
 }
示例#23
0
        public static Protocol Style_Handle(ServerInfo sinfo, Protocol pro)
        {
            if (pro.Session != null && sinfo.session.Find(pro.Session))
            {

                Protocol returnPro = null;
                if (pro.protoType == ProtoType.GET_IN_NEEDED_INFO)
                {
                    returnPro = Get_In_Needed_Info(sinfo, pro);
                }
                else if (pro.protoType == ProtoType.IN_GOODS)
                {
                    returnPro = In_Goods(sinfo, pro);
                }
                else if (pro.protoType == ProtoType.OUT_GOODS)
                {
                    returnPro = Out_Goods(sinfo, pro);
                }
                else if (pro.protoType == ProtoType.FETCH_IN_GOODS)
                {
                    returnPro = Fetch_In_Goods(sinfo, pro);
                }
                else if (pro.protoType == ProtoType.FETCH_OUT_GOODS)
                {
                    returnPro = Fetch_Out_Goods(sinfo, pro);
                }
                return returnPro;

            }
            else
            {
                Protocol returnPro = new Protocol();
                pro.protoType = ProtoType.OUT_OF_TIME;
                return returnPro;
            }
        }
示例#24
0
 private static Protocol Get_In_Needed_Info(ServerInfo sinfo, Protocol pro)
 {
     In_OutHandle uh = new In_OutHandle();
     Protocol returnPro = new Protocol();
     returnPro.mutilData = uh.Get_IN_Need_Info(sinfo,pro);
     if (returnPro.mutilData!=null)
     {
         returnPro.protoType = ProtoType.SUCCESS;
     }
     else
     {
         returnPro.protoType = ProtoType.ERROR;
     }
     return returnPro;
 }
示例#25
0
        private static Protocol Out_Goods(ServerInfo sinfo, Protocol pro)
        {
            In_OutHandle uh = new In_OutHandle();
            Protocol returnPro = new Protocol();
            if (uh.Out_Goods(sinfo, pro))
            {

                returnPro.protoType = ProtoType.SUCCESS;
            }
            else
            {
                returnPro.protoType = ProtoType.ERROR;
            }
            return returnPro;
        }
示例#26
0
 public List<List<string>> Fetch_Out_Log(ServerInfo info, Protocol pro)
 {
     return Fetch_Log(info, pro, "fetch_out_log");
 }
示例#27
0
        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;
        }
示例#28
0
        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;
        }
示例#29
0
        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;
        }
示例#30
0
        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;
        }