public int EditTb_agent_relation(Taobao_agent_relation r) { using (var helper = new SqlHelper()) { int result = new Internaltaobao_agent_relation(helper).EditTb_agent_relation(r); return(result); } }
internal int EditpartTb_agent_relation(Taobao_agent_relation r) { if (r.serialnum == 0) { string sql = @"INSERT INTO [EtownDB].[dbo].[taobao_agent_relation] ([tb_id] ,[tb_seller_wangwang] ,[tb_shop_name] ,[tb_shop_url] ,[tb_shop_state] ,[agentid]) VALUES (@tb_id ,@tb_seller_wangwang ,@tb_shop_name ,@tb_shop_url ,@tb_shop_state ,@agentid);select @@identity;"; var cmd = sqlHelper.PrepareTextSqlCommand(sql); cmd.AddParam("@tb_id", r.tb_id); cmd.AddParam("@tb_seller_wangwang", r.tb_seller_wangwang); cmd.AddParam("@tb_shop_name", r.tb_shop_name); cmd.AddParam("@tb_shop_url", r.tb_shop_url); cmd.AddParam("@tb_shop_state", r.tb_shop_state); cmd.AddParam("@agentid", r.agentid); object o = cmd.ExecuteScalar(); return(int.Parse(o.ToString())); } else { string sql = @"UPDATE [EtownDB].[dbo].[taobao_agent_relation] SET [tb_id] = @tb_id ,[tb_seller_wangwang] = @tb_seller_wangwang ,[tb_shop_name] = @tb_shop_name ,[tb_shop_url] = @tb_shop_url ,[tb_shop_state] = @tb_shop_state ,[agentid] = @agentid WHERE serialnum=@serialnum"; var cmd = sqlHelper.PrepareTextSqlCommand(sql); cmd.AddParam("@serialnum", r.serialnum); cmd.AddParam("@tb_id", r.tb_id); cmd.AddParam("@tb_seller_wangwang", r.tb_seller_wangwang); cmd.AddParam("@tb_shop_name", r.tb_shop_name); cmd.AddParam("@tb_shop_url", r.tb_shop_url); cmd.AddParam("@tb_shop_state", r.tb_shop_state); cmd.AddParam("@agentid", r.agentid); cmd.ExecuteNonQuery(); return(r.serialnum); } }
internal Taobao_agent_relation GetTb_agent_relation(int agentid, int serialnum) { string sql = @"SELECT [serialnum] ,[tb_id] ,[tb_seller_wangwangid] ,[tb_seller_wangwang] ,[tb_shop_name] ,[tb_shop_url] ,[tb_shop_state] ,agentid FROM [taobao_agent_relation] where agentid=@agentid and serialnum=@serialnum"; var cmd = sqlHelper.PrepareTextSqlCommand(sql); cmd.AddParam("@agentid", agentid); cmd.AddParam("@serialnum", serialnum); using (var reader = cmd.ExecuteReader()) { Taobao_agent_relation r = null; if (reader.Read()) { r = new Taobao_agent_relation { serialnum = reader.GetValue <int>("serialnum"), tb_id = reader.GetValue <string>("tb_id"), tb_seller_wangwangid = reader.GetValue <string>("tb_seller_wangwangid"), tb_seller_wangwang = reader.GetValue <string>("tb_seller_wangwang"), tb_shop_name = reader.GetValue <string>("tb_shop_name"), tb_shop_url = reader.GetValue <string>("tb_shop_url"), tb_shop_state = reader.GetValue <int>("tb_shop_state"), agentid = reader.GetValue <int>("agentid") }; } return(r); } }