-- 作者:migold
-- 发布时间:2009/7/27 14:14:00
-- [求助]一个SQL按钮代码
关于: 删除按钮:With e.Form.Controls("MonthDate") If .Value IsNot Nothing Then Dim s5 As String = CStr(.Value) Dim s6 As String s6 = s5.SubString(0,7) Dim cmd As New SQLCommand Dim Count AS Integer cmd .CommandText = "DELETE FROM MiMonthTotal where BillDate = \'" & s6 & "\'" cmd.C Count= cmd.ExecuteNonQuery() Messagebox.Show( "总共删除月结" & Count & "行!") End If End With 执行成功
求助 插入按钮代码: 需要执行的SQL语句:insert into MiMonthTotal (mode,Stor_ID,Stor_Code,Stor_Name,Unit_ID,Unit_Code,Unit_Name,Emp_ID,Emp_Code,Emp_Name,Prod_ProdType,Prod_Back1,BillDate,BillType,Prod_Number1,Prod_Number2,Prod_Number3,DisMoney1,DisMoney2,DisMoney3,CostMoney1,CostMoney2,CostMoney3,ProfitMoney) select \'1\' AS \'mode\', f.s_ID AS \'Stor_ID\',f.u_Code AS \'Stor_Code\',f.u_Name AS \'Stor_Name\', \'0\' AS \'Unit_ID\',\'0\' AS \'Unit_Code\',\'0\' AS \'Unit_Name\', \'0\' AS \'Emp_ID\',\'0\' AS \'Emp_Code\',\'0\' AS \'Emp_Name\', e.ProdType AS \'Prod_ProdType\', \'0\' AS \'Prod_Back1\', left(b.billdate,7) AS \'BillDate\',left(d.billname,2) AS \'BillType\', sum(case when billtype2 in (\'4\',\'16\') then 0 else isnull(Prod_Number,0) end) AS \'Prod_Number1\', sum(case when billtype2 in (\'4\',\'16\') then -isnull(Prod_Number,0) else 0 end) AS \'Prod_Number2\', sum(case when billtype2 in (\'4\',\'16\') then -isnull(Prod_Number,0) else isnull(Prod_Number,0) end) AS \'Prod_Number3\', sum(case when billtype2 in (\'4\',\'16\') then 0 else isnull(DisMoney,0) end) AS \'DisMoney1\', sum(case when billtype2 in (\'4\',\'16\') then -isnull(DisMoney,0) else 0 end) AS \'DisMoney2\', sum(case when billtype2 in (\'4\',\'16\') then -isnull(DisMoney,0) else isnull(DisMoney,0) end) AS \'DisMoney3\', sum(case when billtype2 in (\'4\',\'16\') then 0 else isnull(CostMoney,0) end) AS \'CostMoney1\', sum(case when billtype2 in (\'4\',\'16\') then -isnull(CostMoney,0) else 0 end) AS \'CostMoney2\', sum(case when billtype2 in (\'4\',\'16\') then -isnull(CostMoney,0) else isnull(CostMoney,0) end) AS \'CostMoney3\', sum(case when billtype2 in (\'4\',\'16\') then -(isnull(dismoney,0)-isnull(costmoney,0)) else (isnull(dismoney,0)-isnull(costmoney,0)) end) AS \'ProfitMoney\' from ListSale A left join (select autoid,unit_id,billtype,billdate,s_Syb,emp_id from masterbill) b on a.bill_id=b.autoid left join (select s_id,u_Code,u_Name from units) c on b.unit_id=c.s_id left join (select billtype billtype2,billname from billtype) d on b.billtype=d.billtype2 left join (select s_id,u_Code,u_Name,ProdType,Back1,Back2,Back3 from product) e on a.prod_id=e.s_id left join (select s_ID,u_Code,u_Name from StorHouse) f on a.Stor_ID = f.s_ID left join (select s_ID,u_Name from commoninfo where s_class=\'14\')comib on e.Back1 = comib.s_ID left join (select s_ID,u_Name from commoninfo where s_class=\'15\')comic on e.Back2 = comic.s_ID left join (select s_ID,u_Name from commoninfo where s_class=\'16\')comid on e.Back3 = comid.s_ID left join (select s_id,u_Code,u_name from employee) k on b.emp_id = k.s_id where b.s_Syb = 0 and d.billtype2 in (\'15\',\'16\',\'1\',\'4\') and left(b.billdate,7) = \'2009-06\' GROUP BY f.s_ID,f.u_Code,f.u_Name,e.ProdType,left(b.billdate,7),left(d.billname,2)
|