Exemplo n.º 1
0
        //查询结果
        public static void ReadGBT7314(DataGridView dg, string testNo, string testSampleNo, DateTimePicker dtpFrom, DateTimePicker dtpTo, ZedGraph.ZedGraphControl zed)
        {
            BLL.Compress bllTs    = new HR_Test.BLL.Compress();
            string       strWhere = string.Empty;

            if (!string.IsNullOrEmpty(testNo))
            {
                strWhere += " and testNo like '%" + testNo + "%'";
            }

            if (!string.IsNullOrEmpty(testSampleNo))
            {
                strWhere += " and testSampleNo like '%" + testSampleNo + "%'";
            }

            double  maxValue = 0;
            DataSet dsmax    = bllTs.GetMaxFmc("isFinish=true and isEffective=false and testDate>=#" + dtpFrom.Value.Date + "# and testDate<=#" + dtpTo.Value.Date + "#" + strWhere);

            if (dsmax != null)
            {
                if (dsmax.Tables[0].Rows.Count > 0)
                {
                    if (!string.IsNullOrEmpty(dsmax.Tables[0].Rows[0]["Fmc"].ToString()))
                    {
                        maxValue = Convert.ToDouble(dsmax.Tables[0].Rows[0]["Fmc"].ToString());
                    }
                }
            }

            DataSet   ds = bllTs.GetFinishList("isFinish=true and isEffective=false and testDate>=#" + dtpFrom.Value.Date + "# and testDate<=#" + dtpTo.Value.Date + "#" + strWhere, maxValue);
            DataTable dt = ds.Tables[0];

            dg.DataSource = dt;

            DataGridViewCheckBoxColumn chkcol = new DataGridViewCheckBoxColumn();

            //DataGridViewDisableCheckBoxColumn chkcol = new DataGridViewDisableCheckBoxColumn();
            chkcol.Name = "选择";

            DataGridViewTextBoxColumn c = new DataGridViewTextBoxColumn();

            c.Visible = true;
            c.Name    = "  ";
            dg.Columns.Insert(0, c);
            dg.Columns.Insert(0, chkcol);

            dg.Columns[1].Frozen = true;
            dg.Columns[2].Frozen = true;

            //dg.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells);
            dg.Columns[0].Width = 50;
            dg.Columns[1].Width = 50;
            dg.Columns[2].Width = 100;
            if (dg.ColumnCount > 0)
            {
                foreach (DataGridViewColumn dgvc in dg.Columns)
                {
                    dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                    dgvc.SortMode     = DataGridViewColumnSortMode.NotSortable;
                    dgvc.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
                }
            }
            dg.Refresh();

            for (int i = 0; i < dg.Rows.Count; i++)
            {
                if (i > 19)
                {
                    dg.Rows[i].Cells[1].Style.BackColor          = Color.FromName(_Color_Array[i % 20]);
                    dg.Rows[i].Cells[1].Style.ForeColor          = Color.FromName(_Color_Array[i % 20]);
                    dg.Rows[i].Cells[1].Style.SelectionForeColor = Color.FromName(_Color_Array[i % 20]);
                    dg.Rows[i].Cells[1].Style.SelectionBackColor = Color.FromName(_Color_Array[i % 20]);
                    dg.Rows[i].Cells[1].Value = _Color_Array[i % 20].ToString();
                }
                else
                {
                    dg.Rows[i].Cells[1].Style.BackColor          = Color.FromName(_Color_Array[i]);
                    dg.Rows[i].Cells[1].Style.ForeColor          = Color.FromName(_Color_Array[i]);
                    dg.Rows[i].Cells[1].Style.SelectionForeColor = Color.FromName(_Color_Array[i]);
                    dg.Rows[i].Cells[1].Style.SelectionBackColor = Color.FromName(_Color_Array[i]);
                    dg.Rows[i].Cells[1].Value = _Color_Array[i].ToString();
                }
            }

            foreach (CurveItem ci in zed.GraphPane.CurveList)
            {
                ci.Clear();
                ci.Label.Text = "";
            }

            zed.AxisChange();
            zed.Refresh();
            ds.Dispose();
        }
Exemplo n.º 2
0
        public static void readFinishSample(DataGridView dg, DataGridView dgSum, string testNo, DateTimePicker dtp, ZedGraph.ZedGraphControl zed)
        {
            //try
            //{
            //dg.MultiSelect = true;
            if (dg != null)
            {
                dg.DataSource = null;
                dg.Columns.Clear();
                dg.RowHeadersVisible = false;
            }
            BLL.Compress bllTs = new HR_Test.BLL.Compress();

            if (!string.IsNullOrEmpty(testNo))
            {
                //if (testNo.Contains('-'))
                //    testNo = testNo.Substring(0, testNo.LastIndexOf("-"));
                //获取不重复的试验编号列表
                DataSet ds       = bllTs.GetNotOverlapList(" testNo='" + testNo + "' and testDate =#" + dtp.Value.Date + "#");
                DataSet dsMax    = bllTs.GetMaxFmc(" testNo='" + testNo + "' and isEffective=false and testDate =#" + dtp.Value.Date + "#");
                double  maxValue = 0;
                if (dsMax != null)
                {
                    if (!string.IsNullOrEmpty(dsMax.Tables[0].Rows[0]["Fmc"].ToString()))
                    {
                        maxValue = Convert.ToDouble(dsMax.Tables[0].Rows[0]["Fmc"].ToString());
                    }
                }


                DataTable dt = ds.Tables[0];
                int       ab = 0;
                if (dt != null)
                {
                    //矩形
                    if (dt.Rows[0]["a"].ToString() != "0")
                    {
                        ab = 1;
                    }
                    //圆柱形
                    if (dt.Rows[0]["d"].ToString() != "0")
                    {
                        ab = 2;
                    }
                }

                DataSet   ds1        = bllTs.GetNotOverlapList1(" testNo='" + testNo + "' and testDate =#" + dtp.Value.Date + "#");
                DataTable dt1        = ds1.Tables[0];
                string    methodName = dt1.Rows[0]["testMethodName"].ToString();
                if (dt1 != null)
                {
                    StringBuilder[] tst = strSql_T(methodName, maxValue);
                    if (!string.IsNullOrEmpty(tst[0].ToString()) && dg != null)
                    {
                        dg.DataSource = CreateView(tst[0].ToString(), dt1.Rows[0]["testNo"].ToString(), ab);
                    }
                    if (!string.IsNullOrEmpty(tst[1].ToString()))
                    {
                        dgSum.DataSource = CreateAverageView(tst[0], tst[1], dt1.Rows[0]["testNo"].ToString(), ab);
                    }
                }
            }
            else
            {
                DataSet   ds = bllTs.GetFinishList(" testNo='" + testNo + "' and testDate=#" + dtp.Value.Date + "#", 0);
                DataTable dt = ds.Tables[0];
                DataRow   dr = dt.NewRow();
                dt.Rows.Add(dr);
                if (dg != null)
                {
                    dg.DataSource = dt;
                }
                ds.Dispose();
            }


            //DataGridViewDisableCheckBoxColumn chkcol = new DataGridViewDisableCheckBoxColumn();
            DataGridViewCheckBoxColumn chkcol = new DataGridViewCheckBoxColumn();

            chkcol.Name         = "选择";
            chkcol.MinimumWidth = 50;
            chkcol.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;

            DataGridViewTextBoxColumn c = new DataGridViewTextBoxColumn();

            c.Name = "";
            if (dg != null)
            {
                dg.Columns.Insert(0, chkcol);
                dg.Columns.Insert(1, c);
                dg.Name = "tensile";

                //dg.Rows[0].Cells[0].Value = false;
                //dg.Rows[0].Cells[0].Selected = false;
                int rCount = dg.Rows.Count;
                for (int i = 0; i < rCount; i++)
                {
                    if (!string.IsNullOrEmpty(dg.Rows[i].Cells[2].Value.ToString()))
                    {
                        if (Convert.ToBoolean(dg.Rows[i].Cells[2].Value.ToString()) == true)
                        {
                            dg.Rows[i].DefaultCellStyle.BackColor = Color.IndianRed;
                        }
                    }
                    if (i > 19)
                    {
                        dg.Rows[i].Cells[1].Style.BackColor          = Color.FromName(_Color_Array[i % 20]);
                        dg.Rows[i].Cells[1].Style.ForeColor          = Color.FromName(_Color_Array[i % 20]);
                        dg.Rows[i].Cells[1].Style.SelectionForeColor = Color.FromName(_Color_Array[i % 20]);
                        dg.Rows[i].Cells[1].Style.SelectionBackColor = Color.FromName(_Color_Array[i % 20]);
                        dg.Rows[i].Cells[1].Value = _Color_Array[i % 20].ToString();
                    }
                    else
                    {
                        dg.Rows[i].Cells[1].Style.BackColor          = Color.FromName(_Color_Array[i]);
                        dg.Rows[i].Cells[1].Style.ForeColor          = Color.FromName(_Color_Array[i]);
                        dg.Rows[i].Cells[1].Style.SelectionBackColor = Color.FromName(_Color_Array[i]);
                        dg.Rows[i].Cells[1].Style.SelectionForeColor = Color.FromName(_Color_Array[i]);
                        dg.Rows[i].Cells[1].Value = _Color_Array[i].ToString();
                    }
                }


                foreach (DataGridViewColumn dgvc in dg.Columns)
                {
                    dgvc.SortMode = DataGridViewColumnSortMode.NotSortable;
                    dgvc.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                }
                if (dg.Columns.Count > 1)
                {
                    dg.Columns[0].Frozen = true;
                    dg.Columns[1].Frozen = true;
                    dg.Columns[1].Width  = 10;
                }
                if (dg.Columns.Count > 2)
                {
                    dg.Columns[2].Frozen = true;
                }
                dg.Refresh();
            }

            //clear all curves

            if (zed != null)
            {
                foreach (CurveItem ci in zed.GraphPane.CurveList)
                {
                    ci.Clear();
                    ci.Label.Text = "";
                }
                zed.AxisChange();
                zed.Refresh();
            }
            //}
            //catch (Exception ee) { throw ee; }
        }