Exemple #1
0
        private void HeadData()
        {
            sb = new StringBuilder();
            String sql;
            sb.Remove(0, sb.Length);
            sb.Append("SELECT RECEIVE_HEAD.ReceiveHeadId, RECEIVE_HEAD.ReceiveHeadDate,");
            sb.Append("RECEIVE_DETAIL.ShippingId, RECEIVE_DETAIL.PoId,");
            sb.Append("RECEIVE_DETAIL.ProductId, PRODUCT.ProductName,");
            sb.Append("RECEIVE_DETAIL.ReceiveDetailQuantityPack,");
            sb.Append("RECEIVE_DETAIL.ReceiveDetailQuantity,");
            sb.Append("RECEIVE_DETAIL.ReceiveDetailWeight,RECEIVE_WEIGHT.ReceiveWeight,");
            sb.Append("SHIPPER.ShipperName, SUPPLIER.SupplierName,RECEIVE_WEIGHT.ReceivePack,RECEIVE_DETAIL.AmountProduct ");
            sb.Append("FROM RECEIVE_HEAD INNER JOIN ");
            sb.Append("RECEIVE_DETAIL ON RECEIVE_HEAD.ReceiveHeadId = RECEIVE_DETAIL.ReceiveHeadId ");
            sb.Append("INNER JOIN RECEIVE_WEIGHT ON RECEIVE_HEAD.ReceiveHeadId = RECEIVE_WEIGHT.ReceiveHeadId ");
            sb.Append("INNER JOIN PRODUCT ON RECEIVE_DETAIL.ProductId = PRODUCT.ProductId AND RECEIVE_WEIGHT.ProductId = PRODUCT.ProductId ");
            sb.Append("INNER JOIN SHIPPER ON RECEIVE_HEAD.ShipperId = SHIPPER.ShipperId ");
            sb.Append("INNER JOIN SUPPLIER ON RECEIVE_DETAIL.SupplierId = SUPPLIER.SupplierId ");
            sb.Append("WHERE (RECEIVE_HEAD.ReceiveHeadId = @ReceiveId) ");
            sb.Append("ORDER BY RECEIVE_HEAD.ReceiveHeadId DESC");

            sql = sb.ToString();

            com = new SqlCommand(sql, Conn);
            com.Parameters.Add("@ReceiveId", SqlDbType.Int).Value = ReceiveId;
            //
            PoHeadDa = new SqlDataAdapter(com);
            PoHeadDa.Fill(PoHeadDataset, "Receive");

            float weight = Convert.ToSingle(PoHeadDataset.Tables["Receive"].Rows[0]["ReceiveWeight"].ToString());

            Conn.Close();

                Report.CtrReceive Crv = new Report.CtrReceive(); ;
                Crv.SetDataSource(PoHeadDataset.Tables["Receive"]);
                CrvReceive.ReportSource = Crv;
                CrvReceive.Refresh();
                CrvReceive.Show();
        }
        private void Data()
        {
            sb = new StringBuilder();
            String sql;
            sb.Remove(0, sb.Length);
            sb.Append("SELECT  RECEIVE_HEAD.ReceiveHeadId, RECEIVE_HEAD.ReceiveHeadDate, ");
            sb.Append("PRODUCT.ProductId, PRODUCT.ProductName, RECEIVE_DETAIL.ShippingId,RECEIVE_DETAIL.Invoice, ");
            sb.Append("RECEIVE_DETAIL.ReceiveDetailQuantityPack, RECEIVE_DETAIL.ReceiveDetailQuantity, ");
            sb.Append("RECEIVE_DETAIL.ReceiveDetailWeight, RECEIVE_WEIGHT.ReceiveWeight, ");
            sb.Append("RECEIVE_WEIGHT.ReceivePack, RECEIVE_DETAIL.AmountProduct, EMPLOYER.EmployerName ,");
            sb.Append("RECEIVE_HEAD.DrawId,");
            sb.Append("UNITPACK.UnitPackName,");
            sb.Append("UNITSALE.UnitSaleName, SUPPLIER.SupplierName, SHIPPER.ShipperName,RECEIVE_DETAIL.PoNumber,RECEIVE_DETAIL.Packing, ");
            sb.Append("LOCATION_PRODUCT.LocationProductName ");
            if (ReceiveTypeId == "1")
            {
                sb.Append(",RECEIVE_TYPE.ReceiveTypeName");
            }
            if (strCastalog == "KTC")
            {
                sb.Append(",");
                sb.Append("(SELECT CompanyName FROM Company WHERE (CompanyCatalog = 'KTC')) AS CompanyName,");
                sb.Append("(SELECT CompanyNameEng FROM Company AS Company WHERE (CompanyCatalog = 'KTC')) AS CompanyNameEng,");
                sb.Append("(SELECT CompanyAddress FROM Company AS Company WHERE (CompanyCatalog = 'KTC')) AS CompanyAddressEng,");
                sb.Append("(SELECT CompanyPhone FROM Company AS Company WHERE (CompanyCatalog = 'KTC')) AS CompanyPhone,");
                sb.Append("(SELECT CompanyFax FROM Company AS Company WHERE (CompanyCatalog = 'KTC')) AS CompanyFax, ");
                sb.Append("(SELECT CompanyCode FROM Company AS Company WHERE (CompanyCatalog = 'KTC')) AS CompanyCode ");

            }
            else if (strCastalog == "7CSK")
            {
                sb.Append(",");
                sb.Append("(SELECT CompanyName FROM Company WHERE (CompanyCatalog = '7CSK')) AS CompanyName,");
                sb.Append("(SELECT CompanyNameEng FROM Company AS Company WHERE (CompanyCatalog = '7CSK')) AS CompanyNameEng,");
                sb.Append("(SELECT CompanyAddress FROM Company AS Company WHERE (CompanyCatalog = '7CSK')) AS CompanyAddressEng,");
                sb.Append("(SELECT CompanyPhone FROM Company AS Company WHERE (CompanyCatalog = '7CSK')) AS CompanyPhone,");
                sb.Append("(SELECT CompanyFax FROM Company AS Company WHERE (CompanyCatalog = '7CSK')) AS CompanyFax, ");
                sb.Append("(SELECT CompanyCode FROM Company AS Company WHERE (CompanyCatalog = '7CSK')) AS CompanyCode ");

            }
            else if (strCastalog == "7CTR")
            {
                sb.Append(",");
                sb.Append("(SELECT CompanyName FROM Company WHERE (CompanyCatalog = '7CTR')) AS CompanyName,");
                sb.Append("(SELECT CompanyNameEng FROM Company AS Company WHERE (CompanyCatalog = '7CTR')) AS CompanyNameEng,");
                sb.Append("(SELECT CompanyAddress FROM Company AS Company WHERE (CompanyCatalog = '7CTR')) AS CompanyAddressEng,");
                sb.Append("(SELECT CompanyPhone FROM Company AS Company WHERE (CompanyCatalog = '7CTR')) AS CompanyPhone,");
                sb.Append("(SELECT CompanyFax FROM Company AS Company WHERE (CompanyCatalog = '7CTR')) AS CompanyFax, ");
                sb.Append("(SELECT CompanyCode FROM Company AS Company WHERE (CompanyCatalog = '7CTR')) AS CompanyCode ");

            }
            else if (strCastalog == "SHOP")
            {
                sb.Append(",");
                sb.Append("(SELECT CompanyName FROM Company WHERE (CompanyCatalog = 'SHOP')) AS CompanyName,");
                sb.Append("(SELECT CompanyNameEng FROM Company AS Company WHERE (CompanyCatalog = 'SHOP')) AS CompanyNameEng,");
                sb.Append("(SELECT CompanyAddress FROM Company AS Company WHERE (CompanyCatalog = 'SHOP')) AS CompanyAddress,");
                sb.Append("(SELECT CompanyPhone FROM Company AS Company WHERE (CompanyCatalog = 'SHOP')) AS CompanyPhone,");
                sb.Append("(SELECT CompanyFax FROM Company AS Company WHERE (CompanyCatalog = 'SHOP')) AS CompanyFax, ");
                sb.Append("(SELECT CompanyCode FROM Company AS Company WHERE (CompanyCatalog = 'SHOP')) AS CompanyCode ");

            }
            sb.Append(" FROM  RECEIVE_HEAD INNER JOIN RECEIVE_DETAIL ON  ");
            sb.Append("RECEIVE_HEAD.ReceiveHeadId = RECEIVE_DETAIL.ReceiveHeadId INNER JOIN ");
            sb.Append("PRODUCT ON RECEIVE_DETAIL.ProductId = PRODUCT.ProductId INNER JOIN ");
            sb.Append("UNITSALE ON PRODUCT.UnitSaleId = UNITSALE.UnitSaleId LEFT OUTER JOIN ");
            sb.Append("RECEIVE_WEIGHT ON PRODUCT.ProductId = RECEIVE_WEIGHT.ProductId AND  ");
            sb.Append("RECEIVE_HEAD.ReceiveHeadId = RECEIVE_WEIGHT.ReceiveHeadId LEFT OUTER JOIN ");
            sb.Append("SHIPPER ON RECEIVE_HEAD.ShipperId = SHIPPER.ShipperId LEFT OUTER JOIN ");
            sb.Append("SUPPLIER ON RECEIVE_DETAIL.SupplierId = SUPPLIER.SupplierId LEFT OUTER JOIN RECEIVE_TYPE  ");
            sb.Append("ON RECEIVE_HEAD.ReceiveTypeId = RECEIVE_TYPE.ReceiveTypeId ");
            sb.Append(" LEFT JOIN EMPLOYER ON RECEIVE_HEAD.EmployerId = EMPLOYER.EmployerId ");
            sb.Append(" LEFT JOIN LOCATION_PRODUCT ON RECEIVE_HEAD.LocationProductId = LOCATION_PRODUCT.LocationProductId ");
            sb.Append(" LEFT JOIN UNITPACK ON PRODUCT.UnitPackId = UNITPACK.UnitPackId ");

            sb.Append(" WHERE (RECEIVE_HEAD.ReceiveHeadId = @ReceiveId) ");
            sb.Append("ORDER BY RECEIVE_DETAIL.ReceiveDetailId");
            sql = sb.ToString();

            com = new SqlCommand(sql, Conn);
            com.Parameters.Add("@ReceiveId", SqlDbType.Int).Value = ReceiveId;
            //
            PoHeadDa = new SqlDataAdapter(com);
            PoHeadDa.Fill(PoHeadDataset, "Receive");

            Conn.Close();

                Report.CtrReceive Crv = new Report.CtrReceive();
                Crv.SetDataSource(PoHeadDataset.Tables["Receive"]);
                CtrReceiveSelect.ReportSource = Crv;
                CtrReceiveSelect.Refresh();
                CtrReceiveSelect.Show();
        }