Пример #1
0
        private async void dgModel_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (e.RowIndex < 0 || e.ColumnIndex <= 0)
            {
                return;
            }

            if (e.ColumnIndex <= 2)
            {
                var source     = dgModel.Rows[e.RowIndex].DataBoundItem as HWCfgModel;
                var modulelist = await AccessDBHelper.HWCfgModuleListByInstrumentName(source.HWName, source.InstrumentName, source.ModelName);

                dgModule.DataSource = modulelist;
            }

            if (dgModel.Columns[e.ColumnIndex].DataPropertyName == "Active")
            {
                var rect = dgModel.GetCellDisplayRectangle(dgModel.CurrentCell.ColumnIndex, dgModel.CurrentCell.RowIndex, false);
                cmbActive.Left    = rect.Left;
                cmbActive.Top     = rect.Top;
                cmbActive.Width   = rect.Width;
                cmbActive.Height  = rect.Height;
                cmbActive.Visible = true;
                cmbActive.Focus();
                dgModel.CurrentCell.Style.SelectionBackColor = Color.White;
                var sexValue = dgModel.CurrentCell.Value.ToString();
                cmbActive.Text = Util.GetActiveValToBoolDisplay(sexValue);
            }
        }
Пример #2
0
        private void tsmiDelFZ_Click(object sender, EventArgs e)
        {
            var memuItem = sender as ToolStripItem;
            var node     = memuItem.Tag as TreeNode;

            var array    = node.Tag.ToString().Split(splitchar);
            var question = string.Format(model_del_all_template, array[1]);
            var dialog   = MessageHelper.Confirm(question);

            if (dialog == DialogResult.Yes)
            {
                node.Nodes.Clear();
                //AccessDBHelper.DeleteModel(array[0], array[1]);
                AccessDBHelper.DeleteModule(array[0], array[1]);

                var model = modelList.Find(s => s.HWName == array[0] && s.InstrumentName == array[1]);
                modelList.Remove(model);

                var module = moduleList.Find(s => s.HWName == array[0] && s.InstrumentName == array[1]);
                moduleList.Remove(module);

                dgModel.DataSource  = null;
                dgModule.DataSource = null;
            }
        }
Пример #3
0
        private async void FrmDeviceType_Load(object sender, EventArgs e)
        {
            var list = await AccessDBHelper.InstrumentList();

            foreach (var item in list)
            {
                lbInstrumentType.Items.Add(item.InstrumentName);
            }
        }
Пример #4
0
 private void tsmiInstrumentDelAll_Click(object sender, EventArgs e)
 {
     if (MessageHelper.Confirm("确认删除所有仪器吗?") == DialogResult.Yes)
     {
         AccessDBHelper.DeleteInstrumentByHWName(hwFile.HWName);
         AccessDBHelper.DeleteModelByHWName(hwFile.HWName);
         AccessDBHelper.DeleteModuleByHWName(hwFile.HWName);
         root.Nodes.Clear();
     }
 }
Пример #5
0
        private async void FrmFZType_Load(object sender, EventArgs e)
        {
            var list = await AccessDBHelper.GetModelList();

            var modelList = list.Where(s => s.InstrumentName == instrumentname).ToList();

            foreach (var model in modelList)
            {
                lbModel.Items.Add(model);
            }
        }
Пример #6
0
        private async void FrmCfgList_Load(object sender, EventArgs e)
        {
            dgFiles.AutoGenerateColumns = false;
            dgFiles.MultiSelect         = false;

            var fileList = await AccessDBHelper.CfgList();

            dgFiles.DataSource    = fileList;
            this.txtFileName.Text = fileList.FirstOrDefault().HWName;

            dgFiles.TopLeftHeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            dgFiles.TopLeftHeaderCell.Value           = "No.";
            dgFiles.TopLeftHeaderCell.ValueType       = typeof(string);
        }
Пример #7
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            var tempate_str = "{0};{1},{2},{3},{4};{5}";
            var str         = string.Format(tempate_str,
                                            cmbPorts.Text.Substring(3),
                                            cmbBaud.Text,
                                            cmbCheck.SelectedIndex,
                                            cmbDataBit.Text,
                                            cmbStopBit.SelectedIndex,
                                            nudAdd.Value);

            AccessDBHelper.UpdateModel(model);
            this.DialogResult = DialogResult.OK;
        }
Пример #8
0
        private async void FrmMain_Load(object sender, EventArgs e)
        {
            root                  = new TreeNode("仪器-(" + hwFile.HWName + ")");
            root.Tag              = hwFile.HWName;
            root.ImageIndex       = 0;
            root.ContextMenuStrip = rootContextMenuStrip;
            tvTree.Nodes.Add(root);

            dgModel.TopLeftHeaderCell.Value  = "Device No.";
            dgModule.TopLeftHeaderCell.Value = "Model No.";

            //加载仪器
            instrumentList = await AccessDBHelper.GetInstrumentModelList(hwFile.HWName);

            modelList = await AccessDBHelper.HWCfgModelListByHWName(hwFile.HWName);

            //await AccessDBHelper.HWCfgModelListByInstrumentName(hwFile.HWName, item.InstrumentName);
            foreach (var item in instrumentList)
            {
                var node = new TreeNode(item.InstrumentName);
                node.Tag = hwFile.HWName + splitchar + item.InstrumentName;
                node.ContextMenuStrip = GetSecondContextMenuStrip(node);
                root.Nodes.Add(node);

                var subList = modelList.Where(s => s.HWName == hwFile.HWName && s.InstrumentName == item.InstrumentName);
                foreach (var device in subList)
                {
                    var subnode = new TreeNode(device.ModelName);
                    subnode.Tag = device;
                    subnode.ContextMenuStrip = GetDeleteContextMenuStrip(subnode);
                    node.Nodes.Add(subnode);
                }
            }
            root.Expand();

            moduleList = await AccessDBHelper.HWCfgModuleListByHWName(hwFile.HWName);
        }
Пример #9
0
        private void Save()
        {
            AccessDBHelper.RemoveAllByHWFileName(hwFile.HWName);
            //保存文件
            AccessDBHelper.SaveHWCfgFileModel(hwFile);

            //保存仪器
            foreach (var instrument in instrumentList)
            {
                AccessDBHelper.Insert(instrument);
            }

            //保存Model
            foreach (var model in modelList)
            {
                AccessDBHelper.Insert(model);
            }

            //保存Module
            foreach (var module in moduleList)
            {
                AccessDBHelper.InsertHWCfgModule(module);
            }
        }