コード例 #1
0
        private void btnBuscar_Click(object sender, EventArgs e)
        {
            int no_trabajador = int.Parse(txtBuscar.Text);

            btnEditar.Enabled   = true;
            btnEliminar.Enabled = true;
            btnGuardar.Enabled  = false;

            empleado = new DaoEmpleados().Select(no_trabajador);

            txtNombre.Text          = empleado.Nombre;
            txtApellidoMaterno.Text = empleado.Apellido_Materno;
            txtApellidoPaterno.Text = empleado.Apellido_Paterno;
            txtTelefono.Text        = empleado.Telefono;
            ckbAdmin.Checked        = empleado.Admin;

            if (!empleado.Admin)
            {
                empleado_taller   = new DaoEmpleadoTaller().Select(no_trabajador);
                ckbTaller.Enabled = false;
                if (empleado_taller != null)
                {
                    ckbTaller.Checked = true;
                    txtNo_Taller.Text = empleado_taller.No_Taller + "";
                }
                else
                {
                    empleado_sucursal   = new DaoEmpleadoSucursal().Select(no_trabajador);
                    ckbTaller.Checked   = false;
                    txtNo_Sucursal.Text = empleado_sucursal.No_Sucursal + "";
                }
            }
        }
コード例 #2
0
        public int Insert(EmpleadoSucursal objEmpleadoSucursal)
        {
            int             done = -1;
            MySqlConnection conn = Connention.Conn();

            try
            {
                String       cmdStr = @"Insert into empleado_sucursal (no_trabajador,no_sucursal) 
                values (@no_trabajador,@no_sucursal)";
                MySqlCommand cmd    = new MySqlCommand(cmdStr, conn);
                cmd.Parameters.AddWithValue("@no_trabajador", objEmpleadoSucursal.No_Trabajador);
                cmd.Parameters.AddWithValue("@no_sucursal", objEmpleadoSucursal.No_Sucursal);

                cmd.ExecuteNonQuery();
                done = (int)cmd.LastInsertedId;
            }
            catch (MySqlException ex)
            {
                Console.WriteLine(ex.ToString());
                done = -1;
            }
            finally
            {
                conn.Close();
                conn.Dispose();
            }

            return(done);
        }
コード例 #3
0
        public bool Update(EmpleadoSucursal objEmpleadoSucursal)
        {
            bool            done = false;
            MySqlConnection conn = Connention.Conn();

            try
            {
                String cmdStr = @"Update empleado_sucursal set 
                no_trabajador=@no_trabajador,
                no_sucursal=@no_sucursal where no_trabajador=@no_trabajador";

                MySqlCommand cmd = new MySqlCommand(cmdStr, conn);
                cmd.Parameters.AddWithValue("@no_trabajador", objEmpleadoSucursal.No_Trabajador);
                cmd.Parameters.AddWithValue("@no_sucursal", objEmpleadoSucursal.No_Sucursal);

                cmd.ExecuteNonQuery();
                done = true;
            }
            catch (MySqlException ex)
            {
                Console.WriteLine(ex.ToString());
                done = false;
            }
            finally
            {
                conn.Close();
                conn.Dispose();
            }

            return(done);
        }
コード例 #4
0
        public EmpleadoSucursal Select(int no_trabajador)
        {
            EmpleadoSucursal empleado_sucursal = null;

            MySqlConnection conn = Connention.Conn();

            try
            {
                String       cmdStr = "Select * from empleado_sucursal where no_trabajador=@no_trabajador";
                MySqlCommand cmd    = new MySqlCommand(cmdStr, conn);
                cmd.Parameters.AddWithValue("@no_trabajador", no_trabajador);

                MySqlDataReader dr = cmd.ExecuteReader();

                while (dr.Read())
                {
                    empleado_sucursal               = new EmpleadoSucursal();
                    empleado_sucursal.No_Sucursal   = int.Parse(dr["no_sucursal"].ToString());
                    empleado_sucursal.No_Trabajador = int.Parse(dr["no_trabajador"].ToString());
                }
            }
            catch (MySqlException ex)
            {
                Console.WriteLine(ex.ToString());
                empleado_sucursal = null;
            }
            finally
            {
                conn.Close();
                conn.Dispose();
            }

            return(empleado_sucursal);
        }