Ejemplo n.º 1
0
            public override StandardValuesCollection GetStandardValues(
                ITypeDescriptorContext context)
            {
                string name  = context.PropertyDescriptor.Name;
                string field = null;

                if (name == "User")
                {
                    field = "RUser";
                }
                else if (name == "TypeSize")
                {
                    field = "TypeSize";
                }
                else if (name == "Client")
                {
                    field = "Client";
                }
                else if (name == "SG")
                {
                    field = "SolidGroup";
                }
                else if (name == "Result")
                {
                    field = "Result";
                }
                List <string> L  = new List <string>();
                SelectionPars sp = context.Instance as SelectionPars;

                L.Add(null);
                Select S = new Select(string.Format("SELECT DISTINCT {0} FROM Tubes where DT >= @DT0 and DT <= @DT1 order by {0}", field));

                S.AddParam("@DT0", System.Data.SqlDbType.DateTime, sp.DT0);
                S.AddParam("@DT1", System.Data.SqlDbType.DateTime, sp.DT1);
                while (S.Read())
                {
                    L.Add(Convert.ToString(S[0]));
                }
                S.Dispose();
                return(new StandardValuesCollection(L));
            }
Ejemplo n.º 2
0
        public static bool Exec(SelectionPars _selection, ReportViewer _reportViewer)
        {
            _selection.NonZero();
            string SQL = "select * from Tubes where DT >= @DT0 and DT <= @DT1";

            SQL += _selection.Conditions();
            SQL += " order by DT, ID";

            Select S = new Select(SQL);

            S.AddParam("@DT0", System.Data.SqlDbType.DateTime, _selection.DT0);
            S.AddParam("@DT1", System.Data.SqlDbType.DateTime, _selection.DT1);

            List <Row> L  = new List <Row>();
            RowPars    rp = new RowPars();

            while (S.Read())
            {
                Row r = new Row();
                r.oIdTube        = S["Id"];
                r.oDateTime_     = S["DT"];
                r.oTypeSize      = S["TypeSize"];
                r.oResult        = S["Result"];
                r.oSolidGroup    = S["SolidGroup"];
                r.oNumOfZones    = S["Zones"];
                r.oDefectoscoper = S["RUser"];
                r.oClient        = S["Client"];
                r.oLength        = S["Length"];
                r.oMinThick      = S["MinThickness"];

                rp.allLength += r.Length;
                if (r.Result != "Брак")
                {
                    rp.okTubes++;
                    rp.okLength += r.Length;
                }


                L.Add(r);
            }
            S.Dispose();
            rp.DT0      = _selection.DT0;
            rp.DT1      = _selection.DT1;
            rp.allTubes = L.Count;
            List <ReportParameter> param = new List <ReportParameter>();

            param.Add(new ReportParameter("from", rp.DT0.ToString()));
            param.Add(new ReportParameter("to", rp.DT1.ToString()));
            param.Add(new ReportParameter("orderTime", _selection.Unit + "      Дата: " + rp.DTReport.ToString("d MMMM yyyy г")));
            param.Add(new ReportParameter("allTubes", rp.allTubes.ToString()));
            param.Add(new ReportParameter("okTubes", rp.okTubes.ToString()));
            param.Add(new ReportParameter("allZones", rp.allLength.ToString()));
            param.Add(new ReportParameter("okZones", rp.okLength.ToString()));

            //SQL = "select SolidGroup, count(SolidGroup) sm from TubesStat where DateTime >= @DT0 and DateTime <= @DT1";
            //SQL += Conditions(_selection);
            //SQL += " group by SolidGroup order by sm desc";
            //S = new SelectP(SQL);
            //S.AddParam("@DT0", System.Data.SqlDbType.DateTime, _selection.DT0);
            //S.AddParam("@DT1", System.Data.SqlDbType.DateTime, _selection.DT1);
            //string sSG = " ";
            //while (S.Read())
            //{
            //    string s = S["SolidGroup"].ToString();
            //    if(s.Length==0)
            //        s="' '";
            //    sSG += s + "(" + S["sm"].ToString() + ") ";
            //}
            //S.Dispose();

            //param.Add(new ReportParameter("SG", sSG));

            _reportViewer.LocalReport.DataSources.Clear();
            _reportViewer.LocalReport.ReportPath = "ReportTubes.rdlc";
            _reportViewer.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", L));
            _reportViewer.LocalReport.SetParameters(param);
            PageSettings ps = new PageSettings();

            ps.Margins.Left   = 10;
            ps.Margins.Right  = 0;
            ps.Margins.Top    = 0;
            ps.Margins.Bottom = 0;
            //ps.Landscape = true;
            _reportViewer.SetPageSettings(ps);
            _reportViewer.LocalReport.Refresh();
            _reportViewer.RefreshReport();
            return(true);
        }