Esempio 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);
        }
Esempio n. 2
0
        public static bool DataFileToClass(string FileStr, out cKBValue KBValue)//从文件加载KB值到变量
        {
            bool     isOk = false;
            cKBValue mKBValue;
            string   readFile = cMain.ReadFile(FileStr);

            string[] tempStr;
            int      i = 0;

            try
            {
                mKBValue = new cKBValue();
                tempStr  = readFile.Split('~');
                for (i = 0; i < cMain.DataAll; i++)
                {
                    mKBValue.valueK[i] = Num.DoubleParse(tempStr[2 * i]);
                    mKBValue.valueB[i] = Num.DoubleParse(tempStr[2 * i + 1]);
                }
                isOk = true;
            }
            catch (Exception exc)
            {
                mKBValue = new cKBValue();
                cMain.WriteErrorToLog("FrmKb DataFileToClass is Error " + exc.ToString());
                isOk = false;
            }
            KBValue = mKBValue;
            return(isOk);
        }
Esempio n. 3
0
        public static bool DataClassToFile(cKBValue KBValue)
        {
            bool   isOk    = false;
            string TempStr = "";
            int    i       = 0;

            try
            {
                for (i = 0; i < cMain.DataAll; i++)
                {
                    TempStr = TempStr + KBValue.valueK[i].ToString() + "~";
                    TempStr = TempStr + KBValue.valueB[i].ToString() + "~";
                }
                cMain.WriteFile(cMain.AppPath + "\\KBValue.txt", TempStr, false);
                isOk = true;
            }
            catch (Exception exc)
            {
                cMain.WriteErrorToLog("FrmKb DataClassToFile is Error " + exc.ToString());
                isOk = false;
            }
            return(isOk);
        }
Esempio n. 4
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);
        }