Пример #1
0
        private void OnEdit()
        {
            if (dgConfig.SelectedRows == null || dgConfig.SelectedRows.Count <= 0)
            {
                MsgBox.Show(this.Text, "Vui lòng chọn 1 cấu hình kết nối để sửa.", IconType.Information);
                return;
            }

            DataGridViewRow row        = dgConfig.SelectedRows[0];
            string          id         = row.Cells[0].Value.ToString();
            PortConfig      portConfig = Global.PortConfigCollection.GetPortConfigById(id);

            if (portConfig == null)
            {
                return;
            }
            dlgAddPortConfig dlg = new dlgAddPortConfig(portConfig);

            if (dlg.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
            {
                row.Cells[1].Value = dlg.PortConfig.TenMayXetNghiem;
                row.Cells[2].Value = dlg.PortConfig.LoaiMay.ToString();
                row.Cells[3].Value = dlg.PortConfig.PortName;
                Global.PortConfigCollection.Serialize(Global.PortConfigPath);
            }
        }
Пример #2
0
        private void OnAdd()
        {
            dlgAddPortConfig dlg = new dlgAddPortConfig();

            if (dlg.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
            {
                Global.PortConfigCollection.Add(dlg.PortConfig);
                dgConfig.Rows.Add(dlg.PortConfig.Id, dlg.PortConfig.TenMayXetNghiem, dlg.PortConfig.LoaiMay.ToString(), dlg.PortConfig.PortName);
                Global.PortConfigCollection.Serialize(Global.PortConfigPath);
            }
        }