private void grid_DoubleClick(object sender, EventArgs e) { Rele obj = bll.get(Convert.ToInt32(grid.Rows[grid.SelectedCells[0].RowIndex].Cells[0].Value.ToString())); TipoRele objtiporele = blltiporele.get(obj.tipo); mostrar(obj, objtiporele); }
public void mostrar(Rele obj, TipoRele objTipoRele) { this.obj = obj; txtCodigo.Text = obj.id.ToString(); txtCodigoRele.Text = obj.codigo; txtNome.Text = obj.nome; if (objTipoRele == null) { cboTipo.SelectedIndex = -1; } else { cboTipo.SelectedItem = objTipoRele.id + "-" + objTipoRele.nome; } tabControl1.SelectedIndex = 1; }
private void btnConfirmar_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtCodigoRele.Text)) { MessageBox.Show("Informe o código do Rele!"); return; } if (string.IsNullOrEmpty(txtNome.Text)) { MessageBox.Show("Informe o nome do Rele!"); return; } if (cboTipo.SelectedIndex == -1) { MessageBox.Show("Selecione o tipo do Rele!"); return; } Rele obj = new Rele(); if (string.IsNullOrEmpty(txtCodigo.Text)) { obj.codigo = txtCodigoRele.Text; obj.nome = txtNome.Text; obj.tipo = Convert.ToInt32(cboTipo.SelectedItem.ToString().Split('-').GetValue(0)); obj.dateinsert = DateTime.Now; bll.insert(obj); MessageBox.Show("Rele cadastrado com sucesso!"); } else { obj.id = Convert.ToInt32(txtCodigo.Text); obj.codigo = txtCodigoRele.Text; obj.nome = txtNome.Text; obj.tipo = Convert.ToInt32(cboTipo.SelectedItem.ToString().Split('-').GetValue(0)); obj.dateupdate = DateTime.Now; obj.dateinsert = this.obj.dateinsert; bll.update(obj); MessageBox.Show("Rele atualizado com sucesso!"); } tabControl1.SelectedIndex = 0; atualiza(""); }
private string PressButtonRele(string command, int part) { Controller controller = new Controller(); Rele rele = new Rele(); ICommand typeCommand = null; if (command == "ON") { //typeCommand how releOn typeCommand = new ReleOnCommand(rele); controller.setCommand(typeCommand); } else { //typeCommand how releOff typeCommand = new ReleOffCommand(rele); controller.setCommand(typeCommand); } return(controller.SendCommand(part)); }
internal string ButtonRelePress(string comando) { Controller controller = new Controller(); Rele rele = new Rele(); ICommand typeCommand = null; if (comando == "ON") { //typeCommand how releOn typeCommand = new ReleOnCommand(rele); controller.setCommand(typeCommand); } else { //typeCommand how releOff typeCommand = new ReleOffCommand(rele); controller.setCommand(typeCommand); } string retorno = controller.SendCommand(0); return(retorno); }