Exemplo n.º 1
0
        private void GetGrid()
        {
            try
            {
                Rep = new RepBaseGrid();
                if (File.Exists(sPrintLayOutMod))
                {
                    Rep.LoadLayout(sPrintLayOutMod);
                }
                else
                {
                    MessageBox.Show("加载报表模板失败,请与管理员联系");
                    return;
                }
                Rep.dsPrint.Tables.Clear();

                SqlConnection conn = new SqlConnection(sConnString);
                conn.Open();
                SqlTransaction tran = conn.BeginTransaction();

                string sSQL = @"
select * from v_scdd  
WHERE 1=1   AND  1=1   And mocode = N'aaaaaa'
";
                sSQL = sSQL.Replace("aaaaaa", s单据号);

                DataTable dtHead = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0];
                dtHead.TableName = "dtHead";
                Rep.dsPrint.Tables.Add(dtHead.Copy());

                printControl1.PrintingSystem = Rep.PrintingSystem;
                Rep.CreateDocument();
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.Message);
            }
        }
Exemplo n.º 2
0
        private void GetGrid()
        {
            try
            {
                Rep = new RepBaseGrid();
                if (File.Exists(sPrintLayOutMod))
                {
                    Rep.LoadLayout(sPrintLayOutMod);
                }
                else
                {
                    MessageBox.Show("加载报表模板失败,请与管理员联系");
                    return;
                }
                Rep.dsPrint.Tables.Clear();

                SqlConnection conn = new SqlConnection(sConnString);
                conn.Open();
                SqlTransaction tran = conn.BeginTransaction();

                string sSQL = @"
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#a'))
	drop table #a

SELECT rds32.autoid,rd32.cMaker 
	,rd32.cCode,CONVERT(varchar(100),rd32.dDate,23) as dDate,wh.cWhName
	,rs.cRdName,cus.cCusAbbName,rd32.cMemo
	,rds32.cInvCode,inv.cInvName,inv.cInvStd
	,rds32.cFree1 as 长度,cUnit.cComUnitName 
	,cast(rds32.iNum as decimal(16,2)) as iNum,cast(rds32.iQuantity as decimal(16,2)) as iQuantity
	,rds32.cDefine22 as 公差,rds32.cBatchProperty6 as 炉号
	,rds32.cBatch
	,a.iMPoIds
	,cast(null as varchar(50)) as 材料批号
    ,a.,cmocode 
into #a
FROM dbo.rdrecord32 rd32 
	INNER JOIN dbo.rdrecords32 rds32 ON rd32.ID = rds32.ID
    INNER JOIN dbo.Warehouse wh ON rd32.cWhCode = wh.cWhCode
    inner join Inventory Inv on Inv.cInvCode = rds32.cInvCode
	inner join Rd_Style rs on rs.cRdCode = rd32.cRdCode 
	inner join Customer cus on cus.cCusCode = rd32.cCusCode
	inner join ComputationUnit cUnit on cUnit.cComunitCode = Inv.cComunitCode 
	left join 
	(
		select cBatch,max(iMPoIds) as  iMPoIds,cInvCode ,cmocode 
		from rdrecords10 
		group by cBatch,cInvCode,cmocode 
	)a on a.cBatch = rds32.cBatch and rds32.cInvCode = a.cInvCode
WHERE rd32.cCode = 'aaaaaa'


update a set 材料批号 = rds11.cBatch
from #a a  inner join rdrecords11 rds11 on a.iMPoIds = rds11.iMPoIds 

insert into #a(autoid,cCode,cRdName,cCusAbbName,cComUnitName,cInvCode,iNum,iQuantity,cmocode)
select 99999999999,'','','','','合计',sum(iNum),sum(iQuantity),'' from #a

select * from #a
order by autoid
";
                sSQL = sSQL.Replace("aaaaaa", s单据号);

                DataTable dtHead = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0];
                dtHead.TableName = "dtHead";
                Rep.dsPrint.Tables.Add(dtHead.Copy());

                printControl1.PrintingSystem = Rep.PrintingSystem;
                Rep.CreateDocument();
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.Message);
            }
        }