Exemple #1
0
        private void DGV_ToleranceInit()
        {
            // 构建一个包含textbox的datagridview的行
            //dgvRow.Cells.Add(textboxcell);
            //dgvRow.Cells.Add(textboxcell);
            //dgvRow.Cells.Add(textboxcell);
            //dgvRow.Cells.Add(textboxcell);
            //textboxcell.Value = "0.3";
            //dgvRow.Cells.Add(textboxcell);
            //dgvRow.Cells.Add(comboxcell);
            //dgvRow.Cells.Add(buttoncell);
            //dgv_ToleranceSetting.Rows.Add(dgvRow);
            try
            {
                if (PersistentData.CallHistory_Date == "")
                {
                    dgv_ToleranceSetting.EditMode = DataGridViewEditMode.EditOnEnter;

                    // 获得最近时间的公差带数据
                    // 获得标准公差; 暂时模拟; 拟修改为 在PersisData加载时就调用数据库函数, 读取最近一次保存的标准公差信息,将其赋值给 B515_Standard_Tolerance
                    ZessiTolDatReadFromDB_Buffer zessiTolDatRdFromDBBuffer = new ZessiTolDatReadFromDB_Buffer();
                    zessiTolDatRdFromDBBuffer.CarType = ""; zessiTolDatRdFromDBBuffer.DataTime = "";
                    zessiTolDatRdFromDBBuffer.AllMeasurePoint_ToleranceInfo_str = new string[zessiFileParseOperate.MeasurePoint * 3 * 2];
                    zessiTolDatRdFromDBBuffer.AllMeasurePoint_ToleranceInfo     = new double[zessiFileParseOperate.MeasurePoint * 3 * 2];

                    DBOperate_Obj.Query_ToleranceStandard_RecentDat(ref zessiTolDatRdFromDBBuffer); // 获得DB中最新的公差信息
                    //for (int rows_idx = 0; rows_idx < zessiFileParseOperate.MeasurePoint * 3; rows_idx++) // rows的数量会比实际数量多1个
                    //{
                    //    Form_AdvancedFunc.B515_Standard_Tolerance[2 * rows_idx] = zessiTolDatRdFromDBBuffer.AllMeasurePoint_ToleranceInfo[2 * rows_idx]; //Convert.ToDouble(0.3);
                    //    Form_AdvancedFunc.B515_Standard_Tolerance[2 * rows_idx + 1] = zessiTolDatRdFromDBBuffer.AllMeasurePoint_ToleranceInfo[2 * rows_idx + 1];//Convert.ToDouble(-0.3);
                    //}



                    for (int idx_Tolerance = 0; idx_Tolerance < 75; idx_Tolerance++)
                    {
                        int cur_line_idx = dgv_ToleranceSetting.Rows.Add();
                        //dgv_ToleranceSetting.Rows.Add();

                        dgv_ToleranceSetting.Rows[idx_Tolerance].Cells[0].Value = idx_Tolerance + 1;
                        //dgv_ToleranceSetting.Rows[idx_Tolerance].Cells[1].Value = "PTA1-1 Datum Z TO ABC";

                        ////读已经调用的数据
                        //dt = DBOperate_Obj.Query_ToleranceStandard_SingleDay(PersistentData.CallHistory_Date);
                        //// 更新dgv中的数据
                        //if (dt.Rows.Count > 0 && dt.Rows.Count == 1)
                        //{
                        //    for (int idx_Tolerance0 = 0; idx_Tolerance0 < (dt.Columns.Count - 2) / 2; idx_Tolerance0++)//75
                        //    {
                        //        dgv_ToleranceSetting.Rows[idx_Tolerance0].Cells[3].Value = B515_Standard_Tolerance[2 * idx_Tolerance0] = Convert.ToDouble(dt.Rows[0][2 * idx_Tolerance0 + 2]);//上公差
                        //        dgv_ToleranceSetting.Rows[idx_Tolerance0].Cells[4].Value = B515_Standard_Tolerance[2 * idx_Tolerance0 + 1] = Convert.ToDouble(dt.Rows[0][2 * idx_Tolerance0 + 3]);//下公差

                        //    }
                        //}
                        dgv_ToleranceSetting.Rows[idx_Tolerance].Cells[3].Value = zessiTolDatRdFromDBBuffer.AllMeasurePoint_ToleranceInfo[2 * idx_Tolerance];     // Convert.ToDouble(0.3);
                        dgv_ToleranceSetting.Rows[idx_Tolerance].Cells[4].Value = zessiTolDatRdFromDBBuffer.AllMeasurePoint_ToleranceInfo[2 * idx_Tolerance + 1]; //Convert.ToDouble(-0.3);
                    }
                    // 添加公差名字
                    for (int row_idx = 0; row_idx < zessiFileParseOperate.MeasurePoint * 3; row_idx++)
                    {
                        dgv_ToleranceSetting.Rows[row_idx].Cells[1].Value = DGV_TolInfo[row_idx];
                    }
                    //
                    dgv_ToleranceSetting.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells;
                }
                else if (PersistentData.CallHistory_Date != "")
                {
                    dgv_ToleranceSetting.EditMode = DataGridViewEditMode.EditOnEnter;
                    // 序号 0
                    for (int idx_Tolerance = 0; idx_Tolerance < 75; idx_Tolerance++)
                    {
                        int cur_line_idx = dgv_ToleranceSetting.Rows.Add();
                        dgv_ToleranceSetting.Rows[idx_Tolerance].Cells[0].Value = idx_Tolerance + 1;
                    }
                    // 添加公差名字 1
                    for (int row_idx = 0; row_idx < zessiFileParseOperate.MeasurePoint * 3; row_idx++)
                    {
                        dgv_ToleranceSetting.Rows[row_idx].Cells[1].Value = DGV_TolInfo[row_idx];
                    }
                    dgv_ToleranceSetting.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells;

                    //读已经调用的数据
                    dt = DBOperate_Obj.Query_ToleranceStandard_SingleDay(PersistentData.CallHistory_Date);
                    // 更新dgv中的数据
                    if (dt.Rows.Count > 0 && dt.Rows.Count == 1)
                    {
                        for (int idx_Tolerance = 0; idx_Tolerance < (dt.Columns.Count - 2) / 2; idx_Tolerance++)                                                                            //75
                        {
                            dgv_ToleranceSetting.Rows[idx_Tolerance].Cells[3].Value = B515_Standard_Tolerance[2 * idx_Tolerance] = Convert.ToDouble(dt.Rows[0][2 * idx_Tolerance + 2]);     //上公差
                            dgv_ToleranceSetting.Rows[idx_Tolerance].Cells[4].Value = B515_Standard_Tolerance[2 * idx_Tolerance + 1] = Convert.ToDouble(dt.Rows[0][2 * idx_Tolerance + 3]); //下公差
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("当前调用历史记录时间为:" + PersistentData.CallHistory_Date + "\n启动调用历史界面异常,异常信息:" + ex.Message);
            }
        }