예제 #1
0
        private void btnAddVoltage_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(txtCurVoltage.Text) || string.IsNullOrWhiteSpace(txtPreVoltage.Text) || string.IsNullOrWhiteSpace(txtVoltageLevel.Text))
            {
                MessageBoxHelper.ShowInformationMessageBox("存在数值为空,请填全!");
                return;
            }
            if (decimal.Parse(txtCurVoltage.Text.ToString()) < decimal.Parse(txtPreVoltage.Text))
            {
                MessageBoxHelper.ShowInformationMessageBox("前值必须小于后值,请修改!");
                return;
            }
            if (txtVoltageLevel.Text == "0")
            {
                MessageBoxHelper.ShowInformationMessageBox("电压等级不能为0,请修改!");
                return;
            }
            VoltageBLL      voltageBLL = new VoltageBLL();
            VM_VoltageParam vm_vp      = new VM_VoltageParam();

            vm_vp.CurVoltage   = decimal.Parse(txtCurVoltage.Text);
            vm_vp.PreVoltage   = decimal.Parse(txtPreVoltage.Text);
            vm_vp.VoltageLevel = int.Parse(txtVoltageLevel.Text);
            voltageBLL.GetVoltageList("");
            if (voltageBLL.InsertVoltageParam(vm_vp))
            {
                RefreshVoltageUI();
            }
        }
예제 #2
0
        private void RefreshVoltageUI()
        {
            DataTable  dt         = new DataTable();
            VoltageBLL voltageBLL = new VoltageBLL();
            DataSet    ds         = voltageBLL.GetVoltageList("");

            dt = ds.Tables[0];
            dataGridView3.DataSource = null;
            dataGridView3.Rows.Clear();
            dataGridView3.DataSource = dt;
        }
예제 #3
0
        private void btnVoltageDelete_Click(object sender, EventArgs e)
        {
            if (dataGridView3.CurrentRow == null)
            {
                return;
            }
            VoltageBLL      voltageBLL = new VoltageBLL();
            DataGridViewRow dgvr       = dataGridView3.CurrentRow;
            int             ID         = int.Parse(dgvr.Cells["ID"].Value.ToString());

            voltageBLL.DeleteVoltageParamById(ID);
            RefreshVoltageUI();
        }
예제 #4
0
        public bool PrintVoltageValueChanged(VM_VoltageInfo vi)
        {
            decimal retValue = 0;

            if (vi == null)
            {
                return(false);
            }
            decimal voltageValue = 0;
            string  v0           = vi.V0.ToString().Replace("V", "");
            string  v1           = vi.V1.ToString().Replace("V", "");
            string  v2           = vi.V2.ToString().Replace("V", "");

            if (decimal.Parse(v0) < 0)
            {
                v0 = "0";
            }
            if (decimal.Parse(v1) < 0)
            {
                v1 = "0";
            }
            if (decimal.Parse(v2) < 0)
            {
                v2 = "0";
            }
            voltageValue = (decimal.Parse(v0) + decimal.Parse(v1) + decimal.Parse(v2)) / 3;
            retValue     = voltageValue;
            if (VoltageBLL == null)
            {
                VoltageBLL = new VoltageBLL();
            }
            IList <VM_VoltageParam> vm_vp = VoltageBLL.GetVoltageDsToListInfo();

            vm_vp = vm_vp.Where(a => a.PreVoltage <= retValue && a.CurVoltage > retValue).ToList();
            if (vm_vp == null || vm_vp.Count <= 0)
            {
                return(false);
            }
            foreach (VM_VoltageParam item in vm_vp)
            {
                n_VoltageLevel = item.VoltageLevel;
            }
            return(true);
        }