コード例 #1
0
        // devuleve un registro en particular
        public static tipo_equipos GellIdtipoE(string c, int i)
        {
            tipo_equipos list = null;

            using (MySqlConnection conn = new MySqlConnection(ConfigurationManager.ConnectionStrings["default"].ToString()))
            {
                conn.Open();
                MySqlCommand cmd;
                if (i == 1)
                {
                    cmd = new MySqlCommand("SELECT * FROM tipo_equipo WHERE cod like @cod", conn);
                }
                else
                {
                    cmd = new MySqlCommand("SELECT * FROM tipo_equipo WHERE nom like @cod", conn);
                }

                cmd.CommandType = CommandType.Text;
                cmd.Parameters.AddWithValue("@cod", c);


                MySqlDataReader reader = cmd.ExecuteReader();
                if (reader.HasRows == true)
                {
                    while (reader.Read())
                    {
                        list = LoadtipoE(reader);
                    }
                }
            }

            return(list);
        }
コード例 #2
0
        // hace las operaciones correspondiente al procedimiento almacenado.
        public static int accion(tipo_equipos c, int op)
        {
            int rowsAffected = 0;

            try
            {
                using (MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["default"].ToString()))
                {
                    con.Open();
                    MySqlCommand command = new MySqlCommand("SP_tip_maquinas", con);
                    command.CommandType = CommandType.StoredProcedure;

                    MySqlParameter paramId = new MySqlParameter("msj", MySqlDbType.Int32);
                    paramId.Direction = ParameterDirection.Output;
                    command.Parameters.Add(paramId);

                    command.Parameters.AddWithValue("cod1", c.cod);
                    command.Parameters.AddWithValue("nom1", c.nom);
                    command.Parameters.AddWithValue("tip1", c.tip);
                    command.Parameters.AddWithValue("opc", op);

                    command.ExecuteNonQuery();
                    rowsAffected = int.Parse(command.Parameters["msj"].Value.ToString());
                }
            }
            catch (MySqlException ex)
            {
                MessageBox.Show("Error de acceso a datos: " + ex.Message.ToString(), Application.ProductName.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex1)
            {
                MessageBox.Show("Error: " + ex1.Message.ToString(), Application.ProductName.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(rowsAffected);
        }
コード例 #3
0
ファイル: frmequipos.cs プロジェクト: hmoscote/smacop2
        private void eliminarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int i = listView1.SelectedIndices[0];

            try
            {
                int a = Convert.ToInt32(MessageBox.Show("Está seguro que desea eliminar el registro", Application.ProductName.ToString(), MessageBoxButtons.YesNo, MessageBoxIcon.Information));
                if (a == 6)
                {
                    tipo_equipos c = new tipo_equipos();
                    c.cod = this.listView1.Items[i].Text;
                    op_tipo_equipos.accion(c, 3);
                    frmequipos_Load(this, e);
                }
            }
            catch (MySqlException ex)
            {
                if (ex.Number == 1451)
                {
                    MessageBox.Show("El dato está siendo utilizado, por lo tanto es imposible de eliminar", Application.ProductName.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    MessageBox.Show(ex.Message, Application.ProductName.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
コード例 #4
0
ファイル: frmequipos.cs プロジェクト: hmoscote/smacop2
        private void listView1_Click(object sender, EventArgs e)
        {
            try
            {
                int i = listView1.SelectedIndices[0];


                tipo_equipos c = op_tipo_equipos.GellIdtipoE(this.listView1.Items[i].Text, 1);
                if (c != null)
                {
                    this.label6.Text = c.cod;
                    this.label5.Text = c.nom;
                    if (c.tip == "1")
                    {
                        this.label4.Text = "AMARILLA";
                    }
                    else
                    {
                        this.label4.Text = "BLANCA";
                    }
                    this.label7.Text = op_sql.contar("select count(codeq) from equipos where tipeq='" + c.cod + "'");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message.ToString(), Application.ProductName.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #5
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            if (!validacion())
            {
                return;
            }

            tipo_equipos c = new tipo_equipos();

            c.tip = this.comboBox1.SelectedValue.ToString();
            c.cod = this.textBox1.Text;
            c.nom = this.textBox2.Text;

            int rowsAffected = 0;

            if (string.IsNullOrEmpty(_id))
            {
                rowsAffected = op_tipo_equipos.accion(c, 1);
            }
            else
            {
                this.textBox1.ReadOnly = true;
                rowsAffected           = op_tipo_equipos.accion(c, 2);
            }

            if (rowsAffected > 0)
            {
                if (rowsAffected == 1)
                {
                    MessageBox.Show(mensajes.MsjProc1, Application.ProductName.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    operacion();
                    this.toolStripButton3.Visible = true;
                }
                if (rowsAffected == 2)
                {
                    MessageBox.Show(mensajes.MsjProc2, Application.ProductName.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    operacion();
                    this.toolStripButton3.Visible = true;
                }
                if (rowsAffected == 3)
                {
                    MessageBox.Show(mensajes.MsjProc3, Application.ProductName.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    operacion();
                    this.toolStripButton3.Visible = true;
                }
                if (rowsAffected == 4)
                {
                    if (MessageBox.Show(mensajes.MsjProc4 + " " + mensajes.MsjProc5, Application.ProductName.ToString(), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        rowsAffected = op_tipo_equipos.accion(c, 2);
                    }
                }
            }
            else
            {
                MessageBox.Show(mensajes.MsjProc0, Application.ProductName.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
コード例 #6
0
        // Escribe los valores en la clase cargos

        private static tipo_equipos LoadtipoE(IDataReader reader)
        {
            tipo_equipos item = new tipo_equipos();

            item.cod = Convert.ToString(reader["cod"]);
            item.nom = Convert.ToString(reader["nom"]);
            item.tip = Convert.ToString(reader["tip"]);
            return(item);
        }
コード例 #7
0
        private void frmtipoequipos_Load(object sender, EventArgs e)
        {
            IntPtr hmenu = GetSystemMenu(this.Handle, 0);
            int    cnt   = GetMenuItemCount(hmenu);

            // remove 'close' action
            RemoveMenu(hmenu, cnt - 1, MF_DISABLED | MF_BYPOSITION);
            // remove extra menu line
            RemoveMenu(hmenu, cnt - 2, MF_DISABLED | MF_BYPOSITION);
            DrawMenuBar(this.Handle);

            this.comboBox1.DataSource = op_documentos.linea();
            comboBox1.DisplayMember   = "nom";
            comboBox1.ValueMember     = "cod";
            comboBox1.Text            = null;

            if (!string.IsNullOrEmpty(_id))
            {
                tipo_equipos c = op_tipo_equipos.GellIdtipoE(_id, 1);

                if (c != null)
                {
                    this.Text                    = "Editando Tipo de Equipo: " + c.cod;
                    this.textBox1.Text           = c.cod;
                    this.textBox2.Text           = c.nom;
                    this.comboBox1.SelectedValue = c.tip;

                    toolStripButton5.Visible = true;
                    toolStripButton1.Visible = false;

                    operacion();
                    toolStripButton3.Visible = false;
                    foreach (Control u in this.Controls)
                    {
                        if (u is Button)
                        {
                            u.Enabled = true;
                        }
                    }
                }
            }
            else
            {
                foreach (Control u in this.Controls)
                {
                    if (u is Button)
                    {
                        u.Enabled = false;
                    }
                }
                this.Text = "Nuevo Registro Tipo de Equipo";
                toolStripButton3.Visible = false;
                toolStripButton5.Visible = false;
                toolStripButton1.Visible = true;
            }
        }