Exemplo n.º 1
0
        public static bool DataFrmToClass(frmJiLiang mfrmKb)
        {
            bool isOk = false;

            string[] tempStr = cMain.DataAllTitleStr[cMain.IndexLanguage].Split(',');
            try
            {
                for (int j = 0; j < mfrmKb.readGrid.Columns.Count; j++)
                {
                    for (int i = 0; i < cMain.DataAll; i++)
                    {
                        if (tempStr[i] == mfrmKb.readGrid.Columns[j].HeaderText)
                        {
                            for (int k = 0; k < 10; k++)
                            {
                                DataGridViewRow dr = mfrmKb.KBGrid.Rows[k];
                                mfrmKb.mJiLiang.jiLiangTempClass[i].IsUseData[k] = (dr.Cells[j * 3].Value == null) ? false : (bool)dr.Cells[j * 3].Value;
                                mfrmKb.mJiLiang.jiLiangTempClass[i].ReadData[k]  = Num.DoubleParse(dr.Cells[j * 3 + 1].Value);
                                mfrmKb.mJiLiang.jiLiangTempClass[i].CureData[k]  = Num.DoubleParse(dr.Cells[j * 3 + 2].Value);
                            }
                            break;
                        }
                    }
                }
                isOk = true;
            }
            catch (Exception exc)
            {
                cMain.WriteErrorToLog("FrmJiLiang DataFrmToClass is Error " + exc.ToString());
                isOk = false;
            }
            return(isOk);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 将类中的数据显示到界面
        /// </summary>
        /// <param name="mFrmKb">frmKB,要显示的界面,好像没什么用,就当备用,用的时候传this就行了</param>
        /// <param name="mKBValue">cKBValue,存储了KB值的类</param>
        /// <returns>bool,返回是否显示成功</returns>
        public static bool DataClassToFrm(frmJiLiang mFrmKb, cJiLiang mKBValue)//将KB显示在界面上.
        {
            bool isOk = false;

            try
            {
                for (int j = 0; j < 10; j++)
                {
                    DataGridViewRow dr    = mFrmKb.KBGrid.Rows[j];
                    int             index = 0;
                    for (int i = 0; i < cMain.DataAll; i++)
                    {
                        if (mFrmKb.isJiLiang[i])
                        {
                            dr.Cells[index * 3].Value     = mKBValue.jiLiangTempClass[i].IsUseData[j];
                            dr.Cells[index * 3 + 1].Value = mKBValue.jiLiangTempClass[i].ReadData[j];
                            dr.Cells[index * 3 + 2].Value = mKBValue.jiLiangTempClass[i].CureData[j];
                            index++;
                        }
                    }
                }
                isOk = true;
            }
            catch (Exception exc)
            {
                cMain.WriteErrorToLog("FrmJiLiang DataClassToFrm is Error " + exc.ToString());
                isOk = false;
            }
            return(isOk);
        }
Exemplo n.º 3
0
        private void toolBtnJiLiang_Click(object sender, EventArgs e)
        {
            KBGrid.EndEdit();
            int jiLiangCount = 0;

            bool[] isJiLiang = new bool[cMain.DataAll];
            int    tempLen   = (int)Math.Ceiling(cMain.DataAll / 2.000);

            for (int i = 0; i < cMain.DataAll; i++)
            {
                DataGridViewCell dc;
                if (i < tempLen)
                {
                    dc = KBGrid.Rows[i].Cells[1];
                }
                else
                {
                    dc = KBGrid.Rows[i - tempLen].Cells[7];
                }
                if (dc.Value != null)
                {
                    if (dc.Value.Equals(true))
                    {
                        jiLiangCount++;
                        isJiLiang[i] = true;
                    }
                    else
                    {
                        isJiLiang[i] = false;
                    }
                }
                else
                {
                    isJiLiang[i] = false;
                }
            }
            if (jiLiangCount == 0)
            {
                MessageBox.Show("Have No Choice,当前没有选中要计量的项目,请选择要计量的项目".Split(',')[cMain.IndexLanguage], "Info,提示".Split(',')[cMain.IndexLanguage], MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            timer1.Enabled = false;
            frmJiLiang fj = new frmJiLiang(isJiLiang);

            fj.ShowDialog();
            DataFileToClass(cMain.AppPath + "\\KBValue.txt", out cMain.mKBValue);
            DataClassToFrm(this, cMain.mKBValue);
            timer1.Enabled = true;
        }