Example #1
0
        //查询结果
        public static void ReadGBT228(DataGridView dg, string testNo, string testSampleNo, DateTimePicker dtpFrom, DateTimePicker dtpTo, ZedGraph.ZedGraphControl zed)
        {
            BLL.TestSample bllTs    = new HR_Test.BLL.TestSample();
            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.GetMaxFm("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]["Fm"].ToString()))
                    {
                        maxValue = Convert.ToDouble(dsmax.Tables[0].Rows[0]["Fm"].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();
        }
Example #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.TestSample bllTs = new HR_Test.BLL.TestSample();
            if (!string.IsNullOrEmpty(testNo))
            {
                //if (testNo.Contains('-'))
                //    testNo = testNo.Substring(0, testNo.LastIndexOf("-"));
                //获取不重复的试验编号列表
                DataSet   ds = bllTs.GetNotOverlapList(" testNo='" + testNo + "' and testDate =#" + dtp.Value.Date + "#");
                DataTable dt = ds.Tables[0];
                int       ab = 0;
                if (dt != null)
                {
                    if (dt.Rows[0]["b0"].ToString() != "0")
                    {
                        ab = 1;
                    }
                    if (dt.Rows[0]["d0"].ToString() != "0")
                    {
                        ab = 2;
                    }
                    if (dt.Rows[0]["Do"].ToString() != "0")
                    {
                        ab = 3;
                    }
                }

                DataSet   ds1 = bllTs.GetNotOverlapList1(" testNo='" + testNo + "' and testDate =#" + dtp.Value.Date + "#");
                DataTable dt1 = ds1.Tables[0];

                DataSet dsmax    = bllTs.GetMaxFm(" testNo='" + testNo + "' and testDate =#" + dtp.Value.Date + "#");
                double  maxvalue = 0;
                if (dsmax != null)
                {
                    if (!string.IsNullOrEmpty(dsmax.Tables[0].Rows[0]["Fm"].ToString()))
                    {
                        maxvalue = Convert.ToDouble(dsmax.Tables[0].Rows[0]["Fm"].ToString());
                    }
                }
                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_T(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 chkeffective = new DataGridViewCheckBoxColumn();
            //chkeffective.Name = "是否有效";
            //chkeffective.MinimumWidth = 60;
            //chkeffective.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;

            DataGridViewCheckBoxColumn chkcol = new DataGridViewCheckBoxColumn();

            chkcol.Name         = "选择";
            chkcol.MinimumWidth = 50;
            chkcol.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            if (dg != null)
            {
                DataGridViewTextBoxColumn c = new DataGridViewTextBoxColumn();
                c.Name = "";
                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 > 3)
                {
                    dg.Columns[0].Frozen = true;
                    dg.Columns[1].Frozen = true;
                    dg.Columns[2].Frozen = true;
                }
                if (dg.Columns.Count > 2)
                {
                    dg.Columns[2].Frozen = true;
                }
                dg.Refresh();
            }
            if (zed != null)
            {
                //clear all curves
                foreach (CurveItem ci in zed.GraphPane.CurveList)
                {
                    ci.Clear();
                    ci.Label.Text = "";
                }

                zed.AxisChange();
                zed.Refresh();
            }
            //}
            //catch (Exception ee) { throw ee; }
        }