Exemplo n.º 1
0
        /// <summary>
        /// 将类中的数据显示到界面
        /// </summary>
        /// <param name="mFrmKb">frmKB,要显示的界面,好像没什么用,就当备用,用的时候传this就行了</param>
        /// <param name="mKBValue">cKBValue,存储了KB值的类</param>
        /// <returns>bool,返回是否显示成功</returns>
        public static bool DataClassToFrm(frmKB mFrmKb, cKBValue mKBValue)//将KB显示在界面上.
        {
            bool isOk = false;

            try
            {
                int i        = 0;
                int rowCount = 0;
                rowCount = (int)Math.Ceiling((double)(cMain.DataAll / 2.000));
                for (i = 0; i < cMain.DataAll; i++)
                {
                    DataGridViewRow dr;
                    if (i < rowCount)
                    {
                        dr = mFrmKb.KBGrid.Rows[i];
                        dr.Cells[3].Value = mKBValue.valueK[i];
                        dr.Cells[4].Value = mKBValue.valueB[i];
                    }
                    else
                    {
                        dr = mFrmKb.KBGrid.Rows[i - rowCount];
                        dr.Cells[9].Value  = mKBValue.valueK[i];
                        dr.Cells[10].Value = mKBValue.valueB[i];
                    }
                }
                isOk = true;
            }
            catch (Exception exc)
            {
                cMain.WriteErrorToLog("FrmKb DataClassToFrm is Error " + exc.ToString());
                isOk = false;
            }
            return(isOk);
        }
Exemplo n.º 2
0
        public static bool DataFrmToClass(frmKB mfrmKb, out cKBValue KBValue)
        {
            bool     isOk     = false;
            cKBValue mKBValue = new cKBValue();
            int      rowCount = 0;

            rowCount = (int)Math.Ceiling((double)(cMain.DataAll / 2.000));
            int i;

            try
            {
                for (i = 0; i < cMain.DataAll; i++)
                {
                    DataGridViewRow dr;
                    if (i < rowCount)
                    {
                        dr = mfrmKb.KBGrid.Rows[i];
                        mKBValue.valueK[i] = Num.DoubleParse(dr.Cells[3].Value);
                        mKBValue.valueB[i] = Num.DoubleParse(dr.Cells[4].Value);
                    }
                    else
                    {
                        dr = mfrmKb.KBGrid.Rows[i - rowCount];
                        mKBValue.valueK[i] = Num.DoubleParse(dr.Cells[9].Value);
                        mKBValue.valueB[i] = Num.DoubleParse(dr.Cells[10].Value);
                    }
                }
                isOk = true;
            }
            catch (Exception exc)
            {
                cMain.WriteErrorToLog("FrmKb DataFrmToClass is Error " + exc.ToString());
                isOk = false;
            }
            KBValue = mKBValue;
            return(isOk);
        }